VUnit 测试顺序组件

VUnit test sequential components

如何使用 VUnit 测试库和 VHDL 正确测试顺序组件?我一直在使用它来测试使用 wait for 语句等的组合组件。它的示例 here 在我的 github 仓库中。

显然我必须用 clk <= not clk after half_period; 生成时钟信号,但如何等待它?我会写类似 wait until rising_edge(clk) 的东西吗?但是如果我想将时钟提前多个时钟周期呢?有比多次复制以上行更好的方法吗?

我通常有这方面的东西

    procedure walk (
        signal   clk   : in std_logic;
        constant steps : natural := 1) is
    begin
        if steps /= 0 then
            for step in 0 to steps - 1 loop
                wait until rising_edge(clk);
            end loop;
        end if;
    end procedure;

请确保如果您等待其他信号,您可能需要 re-synchronize 时钟。

例如

    clk <= not clk after 5 ns;
    ...

    wait for 1.5 ns;

    -- This assignment will happen at 1.5 ns, not at a clock edge!
    a <= '1'; 
    walk(clk, 1);

    -- If you need somethign happening at a clock edge and you're not sure of where in
    -- time you are, might be worth synchronizing at the start
    walk(clk, 1);

    --
    a <= '1';
    walk(clk, 1);
    a <= '0';
    walk(clk, 0);
    ...

希望对您有所帮助!

如果您使用的是 VUnit,那么您已经可以使用这样的过程。 VUnit 随 OSVVM 库一起提供随机化功能,但它还包含其他内容,例如 WaitForClock。要启用 OSVVM,您需要在 Python 脚本中添加以下内容。

ui = VUnit.from_argv()
ui.add_osvvm()