如何在VHDL中同时作用于两个信号(通信时钟)边缘?

问题描述 投票:-1回答:1

我想知道什么是 "最好的 "或至少是 "好的 "方法来实现一个过程,在总线或通信时钟上的两个信号边上都有作用。

假设你想为一个可以发送和接收数据的FiFo服务。通常接收到的数据被分配在总线的 "com_clk "的 "下降 "沿上,而发送出去的数据需要在 "com_clk "的 "上升 "沿上进行更新,以便当对方在下降沿上分配数据时最稳定。

对于这种情况,我可以想到多种实现方式,但我无法评估它们在硬件使用、鲁棒性或综合能力方面有多 "好",我也不知道一般情况下有什么好的资源来查找这样的东西。

我的方法是这样的,当然是在通常的框架下。

方法1:

wait until rising_edge(com_clk);
  if reading='1' then 
    wait until com_clk='0';
    internal_mem <= bus_data;  --read the data from the bus
  else
    bus_data <= internal_mem ; --write the data to the bus
  end if;

方法2:

wait until rising_edge(sys_clk);   --should be much faster than "clk" i guess about 10x(?)
  if reading='1' then 
    wait until com_clk='0';        --wait for the com_clk to become '0'
    internal_mem <= bus_data;      --read the data from the bus
  else
    wait until com_clk='1';        --wait for the com_clk to become '1'
    bus_data <= internal_mem ;     --write the data to the bus
  end if;

方法2的一个推导是建立一个com_clk的边缘检测器 并将该信号用于 "等待 "或 "if -lause"。那么,什么是 "好 "或 "最好 "的方法来作用于com_clk信号的两个边缘,我如何自己评估?

vhdl
1个回答
1
投票

你本质上想在FPGA上做双数据速率。

糟糕的方法: 你可以做两个过程,一个工作在上升沿,一个工作在下降沿。这可能会也可能不会合成,取决于你的技术,也可能会也可能不会合成使用硬件翻转。

坏的方法: 你可以不使用你的时钟并使用两个时钟的上升沿。你基本上是在两个时钟域工作。如果你的时序不对,你可能会得到转态性。你需要在这里做通常的可转移性处理电路。

更好的方法: 产生一个较慢的时钟。从你的时钟中产生上升和下降的边缘脉冲。这些脉冲将被送入您的倒装片的使能端口。

© www.soinside.com 2019 - 2024. All rights reserved.