【问题标题】:T Flip Flop with clear (VHDL)带清零的 T 触发器 (VHDL)
【发布时间】:2014-12-04 00:54:39
【问题描述】:

我在使用清除和重置的 T 触发器编码时遇到问题。如下图所示,t_in 作为使能输入运行,将从 mod-m 计数器设置为 1 或 0。然后 to_ldspkr 将切换。 clr_FF 将清除触发器。

Link to the block diagram

我现在确定我应该如何编写这个触发器。这是我的代码,但它不起作用:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;


entity T_FF is
    port(
        from_t_in : in std_logic;
        clk, reset : in std_logic;
        from_clr_FF : in std_logic;
        to_ldspkr : out std_logic
    );
end T_FF;

architecture Behavioral of T_FF is
    signal temp: std_logic;
    signal r_reg, r_next : std_logic;

    begin
    process(reset, clk, from_clr_FF, r_reg)
    begin
        if(reset = '1') then
            r_reg <= '0';   
        elsif(from_clr_FF = '1') then
            r_next  <= '0';
        elsif(clk'event and clk='1') then
            if(from_t_in = '1') then
                temp <= not temp;
            end if;
        end if;
    end process;
    to_ldspkr <= temp;
end Behavioral;

【问题讨论】:

  • 你没有限定“它不工作”。对于模拟不起作用,他最简单的做法是将分配to_ldspkr &lt;= temp; 从进程中移出并使其成为并发信号分配。 temp 不在进程的敏感度列表中。 r_regr_next 是什么?它们不会出现在分配的右侧、端口声明或条件中。 to_ldspkr 仅受 from_clr_FF 影响。
  • 您的 T-FF 有 2 个“重置”信号,称为 reset 和 from_clr_FF。一些文档使用术语“重置”作为同步重置,并将清除作为异步重置。如果两个信号都是同步或异步的,您可以将它们组合成一个带有 OR 的 if 语句。

标签: process vhdl fpga flip-flop


【解决方案1】:

temp 未初始化。我猜你不需要 r_reg 和 r_next。只需将它们替换为 temp,以便在重置时对其进行初始化。 r_reg 则不需要在灵敏度中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多