在上升沿和下降沿设置和复位

时间:2013-09-06 16:02:38

标签: vhdl

如何在上升沿设置一个位并在时钟信号的下降沿复位该位? 我想知道如何实现同样的目标。取决于我想要在上升沿设置并在下降沿复位的条件。这就像在输出端获取时钟脉冲一样。

我实现了两种不同的时钟脉冲,但我遇到了类似的故障。

enter image description here

我的代码就是这个

process(clk)
begin 
   if rising_edge(clk) then
      d0 <= new_data;
   end if;
end process;

process(clk)
begin 
   if falling_edge(clk) then
      d1 <= new_data;
   end if;
end process;

out <= d0 when clk = '1' else d1;

enter image description here

3 个答案:

答案 0 :(得分:1)

如果您想要DDR数据,这是我唯一能够看到您真正想要这样做的时间,那么可以通过多种方式对其进行建模。如果要进行综合,请实例化相应的供应商原语

但是,对于模型:

process(clk)
begin
   -- you could use this
   if clock'event = '1' then
      bit <= new_data;
   end if;
   -- or this
   if rising_edge(clk) ot falling_edge(clk) then
     bit <= new_data;
   end if;
end process;

您还可以将其建模为2个进程和多路复用器

process(clk)
begin 
   if rising_edge(clk) then
      d0 <= new_data;
   end if;
end process;

process(clk)
begin 
   if falling_edge(clk) then
      d1 <= new_data;
   end if;
end process;

out <= d0 when clk = '1' else d1;

答案 1 :(得分:0)

现在看到你的波形,你可以做以下几点来获得无干扰的脉冲序列

process(clk)
begin
    if falling_edge(clk) then
       if pass_next_clock = '1' then
          mask <= '1';
       else
          mask <= '0';
       end if;
    end if;
end process;

pulse <= clk and mask;

这需要你有一个名为pass_next_clock的信号,它可以与时钟边沿对齐,以表示你希望输出下一个时钟高脉冲。

答案 2 :(得分:0)

好的,我搞定了。我的最终代码看起来像是

shared variables d0 ,d1 : std_logic;
process(clk)
begin 
   if rising_edge(clk) then
      d0 := new_data;
   end if;
end process;

process(clk)
begin 
   if falling_edge(clk) then
      d1 := new_data;
   end if;
end process;

out <= d0 when clk = '1' else d1;

Final waveform

相关问题