【问题标题】:Delay in VHDL process between adjacent statements相邻语句之间的 VHDL 过程延迟
【发布时间】:2015-10-25 15:45:47
【问题描述】:

我正在尝试使用 VHDL,但遇到了无法摆脱的延迟。

我正在尝试在测试台上编写一个非常简单的 3 输入与门,该测试台循环遍历 AND3 的所有可能输入和后续输出。我将一个输入绑定到高电平以使其在模拟中的评估更简单。

我已经运行了在 3 个输入的 8 个值之间循环的模拟(忽略了第 3 个输入),然而,在迭代数字和将其分配给输入之间,尽管这些语句紧随其后,但是 100ns 延迟 - 为什么?迭代之间有 100ns 的延迟是可以理解的,因为这是故意的,但我不明白为什么下面所示的两条线在顺序运行时会有 100ns 的延迟?

我已经把定义,测试台放在下面,

非常感谢!

--ENTITY AND3 (3 input AND gate) --
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity and3 is
    port(
        a, b, c : in  std_logic;
        o       : out std_logic
    );
end entity and3;
architecture RTL of and3 is
begin
    o <= (a and b and c) after 5 ns;
end architecture RTL;

--TESTBENCH FOR AND3 with 3rd input left open (tied high)
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity testAnd3 is
end entity testAnd3;                    -- no ports for a test bench

architecture io of testAnd3 is
    component And3 is
        port(x, y, z : in  std_logic:= '1'; --Sets default value if left open; 
             o       : out std_logic
        );
    end component And3;
    signal a, b, c   : std_logic:='0';
   signal iteration : unsigned(2 downto 0):= (others => '0');

begin
    g1 : And3 port map(x => a, y => b, z => open, o => c); --map signals to And ports 
    stim_process : process 
    begin
        iteration <= iteration + 1;     --//100 ns delay between here and next line!?
        a <= iteration(0);
        b <= iteration(1);
        wait for 100 ns;
    end process;

end architecture io;

【问题讨论】:

    标签: vhdl delay simulation xilinx test-bench


    【解决方案1】:

    问题是&lt;= 赋值:

    iteration <= iteration + 1;
    

    这个&lt;= 直到在一个增量延迟之后才更新iteration 的读取值,所以a &lt;= iteration(0); 不会立即看到增加的值,但会在下一次迭代中首先看到它,因此在wait for 100 ns;.

    这可以通过以下任一方式解决:

    • 将分配移动到进程外的ab(建议的解决方案,因为它与可合成代码的编码风格相匹配)
    • iteration &lt;= iteration + 1; 移动到wait for 100 ns; 之前,从而wait 将“隐藏”更新iteration 值的延迟(波形将相同;请参阅下面的评论)
    • iteration 更改为process 中的局部变量,因为使用:= 进行的变量分配会立即发生。

    请注意,&lt;= 分配的信号更新延迟是 VHDL 的一个关键特性,因为它确保所有时钟进程将看到相同的值,而与评估顺序无关。考虑阅读这个相关的好答案:Is process in VHDL reentrant?

    【讨论】:

    • 尝试了所有 3 种实验解决方案 - 只有移动迭代的中间一个不起作用 - 这并不重要,但出于好奇,您知道为什么不这样做吗?否则非常感谢(帮助我理解无止境)!
    • 你是对的,波形是一样的。但不同的是,使用&lt;=iteration更新的delta延迟是不可见的,所以波形会反映新的代码而不会显示任何delta延迟效果。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多