【问题标题】:Delay output signal for 3 clock cycles in VHDL在 VHDL 中延迟 3 个时钟周期的输出信号
【发布时间】:2015-03-27 22:43:51
【问题描述】:

如果复位信号为“0”,则“EN”变为高电平,“clr”变为低电平。但是,如果复位信号在时钟的上升沿变高,则“EN”变低,“clr”变高。我在我的代码中完成了这一点,但是我需要将复位变高时产生的输出信号延迟 [EN = 0/ CLR = 1] 3 个时钟周期。我尝试使用计数器,但它产生了相同的答案。

BEGIN
    process ( Reset, Clk)
    begin
        if Reset = '0' then
                En <= '1';
                clr <= '0';
        elsif rising_edge(Clk) then
            if Reset = '1' then
                En <= '0';
                clr <= '1';
            end if;
        end if;
    end process;

END description;   

【问题讨论】:

  • 内部 if 无效:它始终为 true。

标签: delay vhdl


【解决方案1】:

延迟信号由 3 位移位寄存器或在您的情况下为 3 链式 D-FF 完成。

移位寄存器作为单行器:

architecture rtl of myEntity is
  signal clr_sr      : std_logic_vector(2 downto 0) := "000";
  signal en_sr       : std_logic_vector(2 downto 0) := "000";
  signal clr_delayed : std_logic;
  signal en_delayed  : std_logic;
  [...]
begin
  [...]
  process(Reset, Clk)
  begin
    if Reset = '0' then
      en  <= '1';
      clr <= '0';
    elsif rising_edge(Clk) then
      en  <= '0';
      clr <= '1';
    end if;
  end process;

  clr_sr      <= clr_sr(clr_sr'high - 1 downto 0) & clr when rising_edge(Clock);
  en_sr       <= en_sr(en_sr'high - 1 downto 0)   & en  when rising_edge(Clock);
  clr_delayed <= clr_sr(clr_sr'high);
  en_delayed  <= en_sr(en_sr'high);

  [...]
end;

甚至更短的函数sr_left 来封装移位功能:

clr_sr <= sr_left(clr_sr, clr) when rising_edge(Clock);

【讨论】:

  • 如何将它集成到我的代码中?很抱歉,我对 vhdl 真的很陌生。
  • 将第一行添加到架构的声明部分和流程下方的第 3-4 行。
  • 我在“process (Reset, Clk)”下使用了第 3-4 行[接近文本“temp”;期望开始或声明声明]以及结束过程声明。
  • 正在考虑一种状态机方法;这会是一个更好的主意吗?
  • FSM 不是延迟信号的好解决方案,除非您不会延迟信号,但希望在稍后的时间点生成它。这是 FSM 或计数器的情况。带有异步低电平有效复位的常量触发器的目的是什么?
猜你喜欢
  • 1970-01-01
  • 2017-02-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-17
  • 1970-01-01
  • 2020-09-18
相关资源
最近更新 更多