VHDL上升沿函数是否使用下降沿?

VHDL上升沿函数是否使用下降沿?,vhdl,Vhdl,一段时间以来,我一直在尝试编写一个模拟a触发器。我在这里找不到我的代码有任何错误,但出于某种原因,当我模拟它时,输出在时钟的下降沿而不是上升沿上切换。有我错过的错误吗 library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity TFF is Port (EN, T, CLK : in std_logic; Q : out std_logic); end TFF; architecture Behavioral of TFF is

一段时间以来,我一直在尝试编写一个模拟a触发器。我在这里找不到我的代码有任何错误,但出于某种原因,当我模拟它时,输出在时钟的下降沿而不是上升沿上切换。有我错过的错误吗

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity TFF is
  Port (EN, T, CLK : in std_logic; 
        Q : out std_logic);
end TFF;

architecture Behavioral of TFF is

signal temp_q : std_logic := '0';

begin
    proc1 : process (EN, T, CLK)
    begin
        if EN = '1' then
            if rising_edge(CLK) then
                if T = '1' then temp_q <= (not temp_q);
                else temp_q <= temp_q; end if;
            end if;
        else Q <= temp_q; end if;
        Q <= temp_q;
    end process proc1;
end Behavioral;
IEEE库;
使用IEEE.STD_LOGIC_1164.ALL;
实体TFF是
端口(EN、T、CLK:标准逻辑中;
Q:输出标准(U逻辑);
结束TFF;
TFF的体系结构是
信号温度q:std逻辑:='0';
开始
过程1:过程(EN、T、CLK)
开始
如果EN='1',则
如果上升沿(CLK),则

如果T='1',则temp_q在下降沿切换,因为在上升沿中,它使用旧值
temp_q
(请记住,分配给信号不是一次完成的,它是安排好的,并在过程结束时完成),并且因为您在上升沿()之外有分配,如果是在下降沿完成的,则在下降沿进行分配


你不应该在上升边缘()之外有任何东西。每次时钟边缘变化时,此过程都会启动,下降沿也是如此。除了灵敏度列表中的CLK之外,您也不需要任何东西。分配给
Q
也不必在过程中完成-它可以同时完成。您也可以移动分配给您的
temp\q非常感谢您的帮助。我想这解决了我的问题!你不需要这个:
temp_q如果没有这个行工具,不是可以推断闩锁吗?我想你会受益于更一致的代码缩进风格。你能添加你的测试台吗?顺便说一下,除了所有更好的解决方案,您还可以通过将
temp_q
添加到流程敏感度列表中来解决此问题。除了JHBonarius建议在敏感度列表中需要q_temp,或者将分配到q的语句移动到它自己的流程/并发语句之外,您不需要在敏感度列表中。它在带有上升沿条件的if语句中。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity TFF is
  Port (EN, T, CLK : in std_logic; 
        Q : out std_logic);
end TFF;

architecture Behavioral of TFF is

signal temp_q : std_logic := '0';

begin

Q <= temp_q;

    proc1 : process (CLK)
    begin
        if rising_edge(CLK) then
            if EN = '1' then

                temp_q <= temp_q;

                if T = '1' then 
                    temp_q <= not temp_q;
                end if;

            end if;
        end if;
    end process proc1;
end Behavioral;