VHDL中如何避免简单进程语句输出延迟

VHDL中如何避免简单进程语句输出延迟,vhdl,Vhdl,我是VHDL的初学者。我想知道为什么在下面的代码中有一个周期的延迟,以及如何避免它同时在verilog中语句everys@(posedge clk)没有任何延迟。。如何在VHDL中实现同样的功能 library IEEE; use IEEE.std_logic_1164.all; -- entity entity t_ff_s is port ( T,S,CLK : in std_logic; Q : out std_logic); end t_ff_s; -- entity a

我是VHDL的初学者。我想知道为什么在下面的代码中有一个周期的延迟,以及如何避免它同时在verilog中语句everys@(posedge clk)没有任何延迟。。如何在VHDL中实现同样的功能

library IEEE;
 use IEEE.std_logic_1164.all;

   -- entity
entity t_ff_s is
port ( T,S,CLK : in std_logic;
Q : out std_logic);
 end t_ff_s;
 -- entity
 architecture my_t_ff_s of t_ff_s is
signal t_tmp : std_logic; -- intermediate signal declaration
  begin
    tff: process (S,rising_edge(clk))
     begin
        if (S = '0') then
     t_tmp <= '1';
      --elsif (rising_edge(CLK)) then
     else 
     t_tmp <= T XOR t_tmp; -- temp output assignment
     end if;
    end process tff;
     Q <= t_tmp; -- final output assignment
     end my_t_ff_s;
IEEE库;
使用IEEE.std_logic_1164.all;
--实体
实体t_ff_s是
端口(T、S、CLK:标准逻辑中;
Q:输出标准(U逻辑);
结束t_ff_s;
--实体
架构我的t______________________s是
信号t_tmp:std_逻辑;——中间信号声明
开始
tff:过程(S、上升沿(clk))
开始
如果(S='0'),则

VHDL中的灵敏度列表不像Verilog那样采用边缘规范。VHDL更灵活,因为您可以在进程中的任意位置自由使用
'event
signal属性来实现边缘触发行为。您可以混合使用电平和边缘敏感逻辑,而无需借助分割块/进程或类似
negedge
的黑客进行重置。灵敏度列表中不允许使用函数调用,如
上升沿(clk)
(它实现了对
clk'事件的测试)。它只包含信号名。您的代码无法按原样编译

如果您的代码的其他语法正确的版本编译得很干净,那么您看到的延迟是仿真模型的工件,或者是敏感度列表被破坏了。如果您想要同步时钟驱动的过程,那么您只需要时钟信号,并且可能需要灵敏度列表中的异步重置

考虑以下过程:

tff:进程(S,clk)
开始
如果S='0',则--异步重置(级别敏感)

VHDL中的灵敏度列表不像Verilog那样采用边缘规范。VHDL更灵活,因为您可以在进程中的任意位置自由使用
'event
signal属性来实现边缘触发行为。您可以混合使用电平和边缘敏感逻辑,而无需借助分割块/进程或类似
negedge
的黑客进行重置。灵敏度列表中不允许使用函数调用,如
上升沿(clk)
(它实现了对
clk'事件的测试)。它只包含信号名。您的代码无法按原样编译

如果您的代码的其他语法正确的版本编译得很干净,那么您看到的延迟是仿真模型的工件,或者是敏感度列表被破坏了。如果您想要同步时钟驱动的过程,那么您只需要时钟信号,并且可能需要灵敏度列表中的异步重置

考虑以下过程:

tff:进程(S,clk)
开始
如果S='0',则--异步重置(级别敏感)

t_tmp问题

与Kevin相比,rising_edge更简洁一点,它是一个表达式而不是一个信号,敏感度列表需要一个命名的信号,一个事务,在该事务上恢复执行挂起的进程。将elsif放回,灵敏度列表中只有S和clk

注意,因为t_tmp不在灵敏度列表中,所以在导致您注意到的延迟的下一个时钟事件之前,您不会看到Q follow t_tmp

固定语法过程:

     tff: process (S,clk) -- was (S, risingedge(CLK)), a syntax error)
     begin
        if (S = '0') then
     t_tmp <= '1';
      elsif (rising_edge(CLK)) then  -- put back
     -- else
     t_tmp <= T XOR t_tmp; -- temp output assignment
     end if;
      Q <= t_tmp; -- final output assignment
      end process tff;
tff:process(S,clk)——was(S,risingedge(clk)),一个语法错误)
开始
如果(S='0'),则

t_tmp问题

与Kevin相比,rising_edge更简洁一点,它是一个表达式而不是一个信号,敏感度列表需要一个命名的信号,一个事务,在该事务上恢复执行挂起的进程。将elsif放回,灵敏度列表中只有S和clk

注意,因为t_tmp不在灵敏度列表中,所以在导致您注意到的延迟的下一个时钟事件之前,您不会看到Q follow t_tmp

固定语法过程:

     tff: process (S,clk) -- was (S, risingedge(CLK)), a syntax error)
     begin
        if (S = '0') then
     t_tmp <= '1';
      elsif (rising_edge(CLK)) then  -- put back
     -- else
     t_tmp <= T XOR t_tmp; -- temp output assignment
     end if;
      Q <= t_tmp; -- final output assignment
      end process tff;
tff:process(S,clk)——was(S,risingedge(clk)),一个语法错误)
开始
如果(S='0'),则

t_tmp虽然您的答案基本正确,但选择一种方法与另一种方法的原因最适合于对VHDL有学术兴趣而不是实际兴趣的人。保存delta循环虽然很好,但几乎从来都不是选择一种模式而不是另一种模式的好理由。清晰的意图和可维护性更为重要。我会带来
Q@QuatumRipple-风格的指南是组织叠加的约束,而不是通用需求,也不是VHDL语言本身的限制。这四种语言的合成都是正确的,而原始语言的模拟并不正确——这两种语言在使用VHDL时几乎是通用的。如果意见重要,我会选择与你或Kevin相同的方法,尽管可能是因为不同于你所声称的原因。虽然你的答案基本正确,但选择一种方法与另一种方法的原因最适合于对VHDL有学术兴趣而非实际兴趣的人。保存delta循环虽然很好,但几乎从来都不是选择一种模式而不是另一种模式的好理由。清晰的意图和可维护性更为重要。我会带来
Q@QuatumRipple-风格的指南是组织叠加的约束,而不是通用需求,也不是VHDL语言本身的限制。这四种语言的合成都是正确的,而原始语言的模拟并不正确——这两种语言在使用VHDL时几乎是通用的。如果意见重要的话,我会选择和你或凯文一样的方法,尽管原因可能与你所声称的不同。
tff:
    process (S, clk)
    begin
        if S = '0' then
            t_tmp <= '1';
        elsif  rising_edge(clk) then
            t_tmp <= T xor t_tmp;
        end if;
    end process;
    Q <= t_tmp;   -- concurrent signal assignment
tff:
    process (S, clk)
        variable t_tmp:  std_logic;
    begin
        if S = '0' then
            t_tmp := '1';
        elsif  rising_edge(clk) then
            t_tmp := T xor t_tmp;
        end if;
        Q <= t_tmp;
    end process;
tff:
    process (S, clk, t_tmp)
    begin
        if S = '0' then
            t_tmp <= '1';
        elsif  rising_edge(clk) then
            t_tmp <= T xor t_tmp;
        end if;
        Q <= t_tmp;
    end process;
library IEEE;
 use IEEE.std_logic_1164.all;

   -- entity
entity t_ff_s is
port ( T,S,CLK : in std_logic;
Q : out std_logic);
 end entity t_ff_s;

architecture my_t_ff_s of t_ff_s is
signal t_tmp : std_logic; -- intermediate signal declaration
  begin
    tff: process (S,clk) -- was (S, risingedge(CLK)), a syntax error)
     begin
        if (S = '0') then
            t_tmp <= '1';
        elsif (rising_edge(CLK)) then  -- put back
        -- else
            t_tmp <= T XOR t_tmp; -- temp output assignment
        end if;
             Q <= t_tmp; -- final output assignment
    end process tff;
end my_t_ff_s;

architecture foe of t_ff_s is
    signal t_tmp: std_logic;
begin
tff:
    process (S, clk)
    begin
        if S = '0' then
            t_tmp <= '1';
        elsif  rising_edge(clk) then
            t_tmp <= T xor t_tmp;
        end if;
    end process;
    Q <= t_tmp;   -- concurrent signal assignment
end architecture;

architecture fie of t_ff_s is
begin
tff:
    process (S, clk)
        variable t_tmp:  std_logic;
    begin
        if S = '0' then
            t_tmp := '1';
        elsif  rising_edge(clk) then
            t_tmp := T xor t_tmp;
        end if;
        Q <= t_tmp;
    end process;
end architecture;

architecture fee of t_ff_s is
    signal t_tmp: std_logic;
begin
tff:
    process (S, clk, t_tmp)
    begin
        if S = '0' then
            t_tmp <= '1';
        elsif  rising_edge(clk) then
            t_tmp <= T xor t_tmp;
        end if;
        Q <= t_tmp;
    end process;
end architecture;

library ieee;
use ieee.std_logic_1164.all;

entity test_tff is
end entity;

architecture foo of test_tff is
    signal CLK: std_logic := '0';
    signal T:   std_logic := '0';
    signal S:   std_logic := '0';
    signal Q:   std_logic;

    component t_ff_s is
        port (
            signal CLK:     in  std_logic;
            signal T:       in  std_logic;
            signal S:       in  std_logic;
            signal Q:       out std_logic
        );
    end component;
begin

DUT: 
    t_ff_s
        port map (
            T => T,
            S => S,
            CLK => CLK,
            Q => Q
        );
CLOCK:
    process
    begin
        wait for 10 ns;
        CLK <= not CLK;
        if Now > 250 ns then
            wait;
        end if;
    end process;

SET:
    process
    begin
        S <= '0';
        wait for 20 ns;
        S <= '1';
        wait;
    end process;

TOGGLE:
    process
    begin
        wait for 20 ns;
        T <= '1';
        wait for 60 ns;
        T <= '0';
        wait for 40 ns;
        T <= '1';
        wait;
    end process;

end architecture;

configuration my_t_ff_s_config of test_tff is
    for foo 
        for  DUT: t_ff_s
            use entity work.t_ff_s(my_t_ff_s);
        end for;
    end for;
end configuration;

configuration concurrent_config of test_tff is
    for foo 
        for  DUT: t_ff_s
            use entity work.t_ff_s(foe);
        end for;
    end for;
end configuration;

configuration variable_config of test_tff is
    for foo 
        for  DUT: t_ff_s
            use entity work.t_ff_s(fie);
        end for;
    end for;
end configuration;

configuration sensitivity_config of test_tff is
    for foo 
        for  DUT: t_ff_s
            use entity work.t_ff_s(fee);
        end for;
    end for;
end configuration;