ISIM 信号分配延迟
ISIM signal assignment delay
我预计信号 'delay' 延迟一个时钟周期到实体的端口 'input',但 ISIM 显示没有相移。
我认为信号分配和实际值之间总是存在延迟(当进程挂起时),但我在这里没有看到它。
这是为什么?
代码:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity test is
Port ( clk: in std_logic;
input: in std_logic
);
end test;
architecture Behavioral of test is
signal delay: std_logic:= '0';
begin
proc1: process(clk)
begin
if(rising_edge(clk)) then
delay <= input; -- ISIM shows no delay between them
end if;
end process;
end Behavioral;
测试平台:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY tb_testbench_test IS
END tb_testbench_test;
ARCHITECTURE behavior OF tb_testbench_test IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT test
PORT(
clk: in std_logic;
input: in std_logic
);
END COMPONENT;
--Inputs
signal clk: std_logic := '0';
signal input: std_logic := '0';
-- Clock period definitions
constant clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: test PORT MAP (
clk => clk,
input => input
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
wait for clk_period * 9.5;
input <= '1';
wait for clk_period;
input <= '0';
wait;
end process;
end;
您的测试台描述 clk
和 input
同时变高。然后,您的实体中有一个进程正在寻找 clk
的 rising_edge
。因此,当您的进程运行并询问 'was there a rising edge of the clock?' 时,如果对此的回答是 'yes',即时钟信号刚刚变为 '1'
,则 input
的状态也必须是'1'
,因为两个信号是同时变化的。 delay
信号然后采用这个新的 input
,给出你看到的结果。
更现实的情况是 input
的变化 由 clk
的上升沿引起。您可以通过修改您的刺激过程轻松模拟这一点:
stim_proc: process
begin
wait for clk_period * 9.5;
wait until clk = '1'; -- Sit here until we have seen a rising edge of `clk`
input <= '1'; -- This assignment now happens *after* the clock edge
wait until clk = '1';
input <= '0';
wait;
end process;
信号分配与其值出现之间的延迟是...一个增量周期。而一个delta周期所花费的时间为0 fS。
您的测试台代表的是一种竞争条件,您可以在其中同时呈现输入信号和时钟信号 - 即在相同的增量周期中。
在真实的硬件中,无论输入是被这个时钟边沿还是下一个时钟边沿看到,都会发生抛硬币的情况,或者当时钟边沿出现时会是某个中间值,从而提高了 metastable 操作。
模拟不小心提醒了你这种误操作的可能性。
如果您将数据信号延迟一个增量周期(如果它是前一个时钟进程的输出,则肯定会发生),例如进程外的并发信号分配,您将消除时序风险并且查看您期望的延迟。
我预计信号 'delay' 延迟一个时钟周期到实体的端口 'input',但 ISIM 显示没有相移。 我认为信号分配和实际值之间总是存在延迟(当进程挂起时),但我在这里没有看到它。
这是为什么?
代码:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity test is
Port ( clk: in std_logic;
input: in std_logic
);
end test;
architecture Behavioral of test is
signal delay: std_logic:= '0';
begin
proc1: process(clk)
begin
if(rising_edge(clk)) then
delay <= input; -- ISIM shows no delay between them
end if;
end process;
end Behavioral;
测试平台:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY tb_testbench_test IS
END tb_testbench_test;
ARCHITECTURE behavior OF tb_testbench_test IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT test
PORT(
clk: in std_logic;
input: in std_logic
);
END COMPONENT;
--Inputs
signal clk: std_logic := '0';
signal input: std_logic := '0';
-- Clock period definitions
constant clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: test PORT MAP (
clk => clk,
input => input
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
wait for clk_period * 9.5;
input <= '1';
wait for clk_period;
input <= '0';
wait;
end process;
end;
您的测试台描述 clk
和 input
同时变高。然后,您的实体中有一个进程正在寻找 clk
的 rising_edge
。因此,当您的进程运行并询问 'was there a rising edge of the clock?' 时,如果对此的回答是 'yes',即时钟信号刚刚变为 '1'
,则 input
的状态也必须是'1'
,因为两个信号是同时变化的。 delay
信号然后采用这个新的 input
,给出你看到的结果。
更现实的情况是 input
的变化 由 clk
的上升沿引起。您可以通过修改您的刺激过程轻松模拟这一点:
stim_proc: process
begin
wait for clk_period * 9.5;
wait until clk = '1'; -- Sit here until we have seen a rising edge of `clk`
input <= '1'; -- This assignment now happens *after* the clock edge
wait until clk = '1';
input <= '0';
wait;
end process;
信号分配与其值出现之间的延迟是...一个增量周期。而一个delta周期所花费的时间为0 fS。
您的测试台代表的是一种竞争条件,您可以在其中同时呈现输入信号和时钟信号 - 即在相同的增量周期中。
在真实的硬件中,无论输入是被这个时钟边沿还是下一个时钟边沿看到,都会发生抛硬币的情况,或者当时钟边沿出现时会是某个中间值,从而提高了 metastable 操作。 模拟不小心提醒了你这种误操作的可能性。
如果您将数据信号延迟一个增量周期(如果它是前一个时钟进程的输出,则肯定会发生),例如进程外的并发信号分配,您将消除时序风险并且查看您期望的延迟。