为什么VHDL移位寄存器需要2个时钟上升沿来移位?
我想用D触发器制作一个8位移位寄存器。 问题是,在模拟时,寄存器需要两个时钟上升沿移位,一个用于D输入改变,另一个用于Q改变。我不知道为什么为什么VHDL移位寄存器需要2个时钟上升沿来移位?,vhdl,Vhdl,我想用D触发器制作一个8位移位寄存器。 问题是,在模拟时,寄存器需要两个时钟上升沿移位,一个用于D输入改变,另一个用于Q改变。我不知道为什么 entity Registry_8 is port (input : in std_logic; output : out std_logic; clk : in std_logic; clear : in std_logic; load : in std_logic
entity Registry_8 is
port (input : in std_logic;
output : out std_logic;
clk : in std_logic;
clear : in std_logic;
load : in std_logic;
LR : in std_logic;
pIn : in std_logic_vector (7 downto 0);
pOut : out std_logic_vector (7 downto 0);
shift : in std_logic);
end Registry_8;
architecture Behavioral of Registry_8 is
component D_flipflop
port(D, clk, clear, preset : in std_logic;
Q, Q_b : out std_logic);
end component;
signal D, Q : std_logic_vector (7 downto 0);
begin
GEN_FLIP :
for i in 0 to 7 generate
D_i : D_flipflop port map(clk => clk, preset => '0', clear => clear, D => D(i), Q => Q(i));
end generate GEN_FLIP;
process (clk, load, LR, shift)
begin
if (load = '1')
then D <= pIn;
end if;
if (clk'event and clk = '1' and shift = '1')
then
if (LR = '0')
then D(7 downto 0) <= Q(6 downto 0) & input;
output <= Q(7);
else
D(7 downto 0) <= input & Q(7 downto 1);
output <= Q(0);
end if;
end if;
end process;
pOut <= Q;
end Behavioral;
实体注册表_8是
端口(输入:标准_逻辑中;
输出:输出标准逻辑;
clk:标准逻辑中;
清除:在标准逻辑中;
负载:在标准逻辑中;
LR:标准逻辑中;
引脚:标准逻辑向量(7到0);
pOut:out标准逻辑向量(7到0);
移位:在标准逻辑中);
结束注册(8);;
注册表_8的体系结构是
分量D_触发器
端口(D、clk、clear、preset):在标准逻辑中;
Q、 Q_b:输出标准逻辑);
端部元件;
信号D,Q:标准逻辑向量(7到0);
开始
GEN_FLIP:
对于0到7中的i,生成
D_i:D_触发器端口映射(clk=>clk,预置=>0',clear=>clear,D=>D(i),Q=>Q(i));
结束生成GEN_翻转;
过程(时钟、负载、LR、班次)
开始
如果(加载='1')
然后D在此过程中,存在时钟边缘敏感条件,表达式为:
clk'event and clk = '1'
因此,该过程实现了额外级别的顺序逻辑(flip)
失败),但您可能想创建一个纯组合的过程
设计,比如:
process (all) is
begin
if (load = '1') then
D <= pIn;
end if;
if shift = '1' then
if (LR = '0') then
D(7 downto 0) <= Q(6 downto 0) & input;
output <= Q(7);
else
D(7 downto 0) <= input & Q(7 downto 1);
output <= Q(0);
end if;
end if;
end process;
过程(全部)是
开始
如果(加载='1'),则
D