0
我刚开始学习vhdl代码,并且我编写了一个D型异步触发器的代码。我应该如何修改我的代码,使其具有第二个D型输入,第二个输入是从第一个输出输入的。VHDL,D型异步触发器
library ieee;
use ieee.std_logic_1164.all;
entity FLIPFLOP is
port (
clk : in std_logic ;
clr : in std_logic ;
D : in std_logic ;
Q : out std_logic
);
end FLIPFLOP;
architecture behav of FLIPFLOP is
begin
process (clk,clr,D)
begin
if clr = '1' then
Q<= '0';
elsif rising_edge (clk) then
Q<= D;
end if;
end process;
end behav;
在过程敏感性列表中不需要D.参见[VHDL D型异步触发器](https://electronics.stackexchange.com/questions/333403/vhdl-d-type-asynch-flip-flop)。它被称为移位寄存器。参见[VHDL中移位寄存器的结构设计](https://stackoverflow.com/questions/37082327/structural-design-of-shift-register-in-vhdl)和[用VHDL设计移位寄存器](https:/例如,/stackoverflow.com/questions/29840819/design-a-shift-register-in-vhdl)。 – user1155120
'process(clk,clr)variable reg:std_logic_vector(1 downto 0); begin if clk ='1'then reg:=“00”; elsif rising_edge(clk)then reg:= D&reg(1);万一; Q <= reg(0);末端过程; “如果这不是你想要的,它表明你的问题不清楚,它符合你的所有标准。两个触发器分别是reg(1)和reg(0)。变量reg也可能是一个信号,要求在另一个进程中进行Q分配(例如在并发信号分配中详细描述为进程声明)。 – user1155120