當測試簡單的計數器實現時,GHDL仿真不會退出仿真。我的意圖是使用由主進程更改的共享變量來停止兩個併發進程。但主要過程並未停止時鐘進程。用等待語句停止VHDL仿真
我的計數器實現:
entity dff is
port(
direction, reset, clk, load : in std_logic;
din : in std_logic_vector(3 downto 0);
dout : out std_logic_vector(3 downto 0));
end dff;
architecture behav of dff is
signal temp : std_logic_vector(3 downto 0);
begin
process(clk, reset)
begin
if (reset='1') then
temp <= "0000";
elsif rising_edge(clk) then
if (load='1') then
temp <= din;
else
if (direction='0') then
temp <= std_logic_vector(unsigned(temp) + 1);
else
temp <= std_logic_vector(unsigned(temp) - 1);
end if;
end if;
end if;
dout <= temp;
end process;
end behav;
而我的測試平臺:
architecture behav of test_tb is
component dff port(
direction, reset, clk, load : in std_logic;
din : in std_logic_vector(3 downto 0);
dout : out std_logic_vector(3 downto 0));
end component;
signal direction, reset, clk, load : std_logic := '1';
signal din, dout : std_logic_vector(3 downto 0) := x"7";
shared variable simend : boolean := false;
begin
clkk : process
begin
if simend=false then
clk <= not clk after 50 ns;
else
wait;
end if;
end process clkk;
uut : dff port map(
direction, reset, clk, load, din, dout);
stim : process
begin
reset <= '0';
wait for 1 us;
load <= '0';
wait for 2 us;
direction <= '0';
wait for 2 us;
load <= '1';
wait for 1 us;
reset <= '1';
wait for 0.5 us;
simend := true;
wait;
end process stim;
end behav;
在最近的ghdl版本中,您可以結合使用[--assert-level =](http://ghdl.readthedocs.io/en/latest/Simulation_and_runtime.html?highlight=severity)和--ieee- asserts = 阻止來自標準包的警告,以允許在斷言語句中暫停SEVERITY_LEVEL HALT。您也可以將延遲從「等待50納秒; clk <=不是clk;如果simend = true,則等待;結束if;'進程語句自然循環。 –
user1155120
我建議避免時鐘殺手的開銷,而是使用@scary_jeff建議的std.env.stop。 –