敏感列表中变量的更改何时会触发 vhdl 中的进程?

when does a change in a variable in the sensitivity list trigger a process in vhdl?

我很难理解这段代码的效果: 我的组件:

library IEEE;
use IEEE.std_logic_1164.all;

entity problem is
  port(
    clk : in std_logic;
    a : in std_logic);
end problem;

architecture impl of problem is
  signal a_sig : std_logic;

begin
  clk_proc : process(clk)
  begin
    if rising_edge(clk) then
      a_sig <= '0';
    end if;
  end process;

  a_proc : process(a)
  begin
    report "a received : " & std_logic'image(a);
    a_sig <= a;
  end process;

  a_sig_proc : process(a_sig)
  begin
    report "a_sig set : " & std_logic'image(a_sig);
  end process;
end impl;

这是我的 testbench.vhd:

library IEEE;
use IEEE.std_logic_1164.all;

entity testbench is
end testbench;

architecture tb of testbench is
  component problem is
    port ( clk : in std_logic;
           a : in std_logic);
  end component;

  constant clk_period : time := 1 ms;
  signal clk_sig : std_logic;
  signal a_sig : std_logic;
begin
  dut : problem port map (clk_sig, a_sig);

  process
  begin
    clk_sig <= '1';
    wait for clk_period/2;
    clk_sig <= '0';
    wait for clk_period/2;
  end process;

  process
  begin
    wait for clk_period * 0.75;
    a_sig <= '1';
  end process;

end tb;

和运行代码的结果如下:

$ ghdl -r testbench --vcd=testbench.vcd --stop-time=2ms
problem.vhd:23:5:@0ms:(report note): a received : 'U'
problem.vhd:29:5:@0ms:(report note): a_sig set : 'U'
problem.vhd:23:5:@750us:(report note): a received : '1'
problem.vhd:29:5:@1ms:(report note): a_sig set : 'X'
./testbench:info: simulation stopped by --stop-time

我可以理解在 0 毫秒接收到的 'U' 信号,我可以理解在 750 微秒的 problem.a_proc 接收到的“1”信号。让我感到困惑的第一件事是,为什么 problem.a_sig_proc 不是由 a_sig 触发的,而是在同一过程中设置的? 然后,当 problem.a_sig_proc 被触发时, a_sig 的值为 'X'。如果有人可以指出我的资源来解释这一点,那就太好了:)

提前致谢!

您正在驱动来自多个进程(clk_proc 和 a_proc)的 a_sig 信号。您将需要在其中一个进程中删除对 a_sig 的分配(因为模拟器无法确定哪个分配优先),或者将 'Z'(高阻抗)从进程驱动到 a_sig , 而不是 "their turn"。有很好的解释here and here