反问题

时间:2016-12-01 22:33:34

标签: vhdl

之前有一个测量四个时钟周期的问题,但我相信我的代码可以工作,但是会延迟一个时钟周期。另一篇文章提到了这个问题。

1 个答案:

答案 0 :(得分:1)

菊花链计数器可以采用一般原则:

ENABLE_TO_NEXT_COUNTER <= ENABLED when PREVIOUS_COUNTER=MAXIMUM_COUNT and ENABLE_TO_PREVIOUS_COUNTER=ENABLED else NOT_ENABLED;

PREVIOUS_COUNTER=MAXIMUM_COUNT的检查很明显,但我们需要在andENABLE_TO_PREVIOUS_COUNTER,以便ENABLE_TO_NEXT_COUNTER脉冲只有一个时钟宽。

所以,我已将您的第二个架构更改为

architecture behavior of counter_4 is
  signal count1, count2, enable2 : std_logic;

  component counter_2 is port(
    clock, reset, enable : in std_logic;
    f : out std_logic
    );
  end component;

begin

  Enable2 <= '1' when Enable = '1' and count1 = '0' else '0';

  c0: counter_2 port map (clock => Clock, reset => Reset, enable => Enable, f => count1);
  c1: counter_2 port map (clock => Clock, reset => Reset, enable => Enable2, f => count2);

  f <= count2;

end behavior;

https://www.edaplayground.com/x/5BhA