【问题标题】:Update data when clock goes low - VHDL时钟变低时更新数据 - VHDL
【发布时间】:2015-05-08 15:53:50
【问题描述】:

我需要在时钟变低而不是下一个上升沿时设置输出数据,我已经修改了代码以这种方式工作,但我有这个警告:

Clock on register Empty 绑定到一个常量 寄存器上的时钟 Full 绑定到一个常量

这是代码:

elsif rising_edge(Clock) then  
                if (Head = Tail) then
                    if Looped then
                        FullVar := '1';
                    else
                        EmptyVar := '1';
                    end if;
                else
                    EmptyVar := '0';
                    FullVar := '0';
                end if;
   else
      Full <= FullVar;
      Empty <= EmptyVar;
   end if;
end process;

为了消除这个警告,我以这种方式修改了代码:

elsif rising_edge(Clock) then  
                if (Head = Tail) then
                    if Looped then
                        FullVar := '1';
                    else
                        EmptyVar := '1';
                    end if;
                else
                    EmptyVar := '0';
                    FullVar := '0';
                end if;
   end if;
   Full <= FullVar;
   Empty <= EmptyVar;
end process;

但是当我编译代码和模拟时,在断言标志之前我有一个更高的延迟(在没有警告的更正代码中)。这是为什么?另外,代码可以工作,但是这种类型的代码或数据应该在上升沿时始终更新是正确的吗?

【问题讨论】:

  • 只使用falling_edge。
  • 正如 Brian 提到的,falling_edge() 函数可以满足您的需求。请注意,这有效地创建了一个延迟半个周期的新中时时钟域。在这些域之间的交叉点上,您将有更少的设置时间,并且需要在实际设计中考虑到时序约束。
  • 不,我不是这个意思。例如这是一个 FIFO,它不是在 FIFO 变空时断言空标志,而是在下一个时钟它变空。这样,在同一时钟周期的上升沿变空后,当时钟变低时,就会断言空标志。我要问的是,因为在我看来它不是标准编码,但这段代码有效,它会在长期运行中产生错误吗?
  • if rising_edge(clock) then 不能有 else 情况。它不可合成。

标签: vhdl fpga


【解决方案1】:

是的,您应该始终使用rising_edge(Clock),除非您“真的”需要第二个时钟域。在您的情况下,您不需要第二个时钟域。

在您的示例中也没有理由使用变量。如果 Head 等于 Tail 并且 Looped 在上升沿之前为“1”,则以下代码将在时钟的上升沿之后引发 Empty。

check : process (Clock)
if rising_edge(Clock) then
    if Head = Tail then
        if Looped then
            Full <= '1';
        else
            Empty <= '1';
        end if;
    else
        Empty <= '0';
        Full <= '0';
    end if;
end if;
end process;

如果你想在上升沿之前有 Empty raise,你应该组合地这样做,像这样:

check : process (Head,Tail,Looped)
Empty <= '0';
Full <= '0';
if Head = Tail then
    if Looped then
        Full <= '1';
    else
        Empty <= '1';
    end if;
end process;

我希望这会有所帮助。

【讨论】:

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