在 VHDL 中同时具有异步和同步复位功能的 D 型锁存器
D-latch with both asynchro and synchro resetting in VHDL
我必须实现一个 D 锁存器,它在 aclrn=0 时跟随异步复位,在 sclrn=0 时跟随同步。实现应该能够遵循两种重置方法。
这是我在基于基本 D 型锁存器的 VHDL 中提出的(我只包括过程)。
process(aclrn,clock)
begin
if (aclrn='0') then
q <= '0';
elsif (rising_edge(clock)) then
if (sclrn='0') then
q <= '0';
else
q <= d;
end if;
end if;
end process;
哪里
clock, d, aclrn, sclrn : in std_logic; q : out std_logic
我说的对吗,进程不需要将 sclrn 作为参数,而只需将 aclrn 和时钟作为参数?还有其他不一致的地方吗?
提前致谢。
你说D-latch但是编码触发器。你真的需要 D-latch 还是你只是粗心地使用 latch 而不是 register?
如果您真的需要人字拖,那您就做对了。
您已将 aclrn 和 clock 放入正确的敏感度列表中。您不需要将 sclrn 放在列表中,因为它是同步的。
Flip-Flop 的 Xilinx XST 教程示例,带有 Positive-Edge 时钟和同步设置
architecture archi of registers_3 is
begin
process (C)
begin
if (C'event and C='1') then
if (S='1') then
Q <= '1';
else
Q <= D;
end if;
end if;
end process;
end archi;
和 Flip-Flop 的 XST 编码示例,带有 Positive-Edge 时钟和异步复位
architecture archi of registers_2 is
begin
process (C, CLR)
begin
if (CLR = '1')then
Q <= '0';
elsif (C'event and C='1')then
Q <= D;
end if;
end process;
end archi;
通过混合这两个你得到你的答案。我看不出你的代码有什么问题。了解您是否编写了所要求的代码的最佳方法是模拟它。
如果您需要锁存器,请注意锁存器对电平而不是边缘敏感。这是一个带正门和异步复位的 LATCH 示例
architecture archi of latches_2 is
begin
process (CLR, D, G)
begin
if (CLR='1') then
Q <= '0';
elsif (G='1') then
Q <= D;
end if;
end process;
end archi;
我必须实现一个 D 锁存器,它在 aclrn=0 时跟随异步复位,在 sclrn=0 时跟随同步。实现应该能够遵循两种重置方法。
这是我在基于基本 D 型锁存器的 VHDL 中提出的(我只包括过程)。
process(aclrn,clock)
begin
if (aclrn='0') then
q <= '0';
elsif (rising_edge(clock)) then
if (sclrn='0') then
q <= '0';
else
q <= d;
end if;
end if;
end process;
哪里
clock, d, aclrn, sclrn : in std_logic; q : out std_logic
我说的对吗,进程不需要将 sclrn 作为参数,而只需将 aclrn 和时钟作为参数?还有其他不一致的地方吗?
提前致谢。
你说D-latch但是编码触发器。你真的需要 D-latch 还是你只是粗心地使用 latch 而不是 register? 如果您真的需要人字拖,那您就做对了。 您已将 aclrn 和 clock 放入正确的敏感度列表中。您不需要将 sclrn 放在列表中,因为它是同步的。 Flip-Flop 的 Xilinx XST 教程示例,带有 Positive-Edge 时钟和同步设置
architecture archi of registers_3 is
begin
process (C)
begin
if (C'event and C='1') then
if (S='1') then
Q <= '1';
else
Q <= D;
end if;
end if;
end process;
end archi;
和 Flip-Flop 的 XST 编码示例,带有 Positive-Edge 时钟和异步复位
architecture archi of registers_2 is
begin
process (C, CLR)
begin
if (CLR = '1')then
Q <= '0';
elsif (C'event and C='1')then
Q <= D;
end if;
end process;
end archi;
通过混合这两个你得到你的答案。我看不出你的代码有什么问题。了解您是否编写了所要求的代码的最佳方法是模拟它。
如果您需要锁存器,请注意锁存器对电平而不是边缘敏感。这是一个带正门和异步复位的 LATCH 示例
architecture archi of latches_2 is
begin
process (CLR, D, G)
begin
if (CLR='1') then
Q <= '0';
elsif (G='1') then
Q <= D;
end if;
end process;
end archi;