VHDL - How should I create a clock in a testbench?

后端 未结 4 1432
你的背包
你的背包 2021-01-30 17:57

How should I create a clock in a testbench? I already have found one answer, however others on stack overflow have suggested that there are alternative or better ways of achievi

4条回答
  •  借酒劲吻你
    2021-01-30 18:09

    Concurrent signal assignment:

    library ieee;
    use ieee.std_logic_1164.all;
    
    entity foo is
    end;
    architecture behave of foo is
        signal clk: std_logic := '0';
    begin
    CLOCK:
    clk <=  '1' after 0.5 ns when clk = '0' else
            '0' after 0.5 ns when clk = '1';
    end;
    

    ghdl -a foo.vhdl
    ghdl -r foo --stop-time=10ns --wave=foo.ghw
    ghdl:info: simulation stopped by --stop-time
    gtkwave foo.ghw

    enter image description here

    Simulators simulate processes and it would be transformed into the equivalent process to your process statement. Simulation time implies the use of wait for or after when driving events for sensitivity clauses or sensitivity lists.

提交回复
热议问题