Is the use of rising_edge on non-clock signal bad practice? Are there alternatives?

我是研究僧i 提交于 2019-12-04 10:43:18
Paebbels

Yes, rising_edge()/falling_edge() should only be used for clock signal. While it works in simulation it can cause problems and unintended hardware in synthesis.

Synthesis tools infer a clock from the function's argument and place such signals/wires on special tracks in the FPGAs (assuming you are targeting an FPGA for your design). The tool will further infer special clock buffers and warn if your input clock pin is not a clock capable pin.

Introducing several clocks can lead to asynchronous designs and make it vulnerable for cross clock faults.

Detecting a rising or falling edge on a signal is done by an edge detection circuit like the following which compares the signal in the previous clock cycle to the current value.

Needed signals:

signal mySignal_d : std_logic := '0'; 
signal mySignal_re : std_logic;

Needed logic:

mySignal_d <= mySignal when rising_edge(Clock); 
mySignal_re <= not mySignal_d and mySignal; 

This first line translates to an 1-bit D-flipflop (You could also use a process). The second lines generates a one cycle strobe signal when mySignal changes from low to high. I'm using *_d to indicate a delayed signal of the original input and *_re for rising edge.

The generated signal is still synchronous to Clock.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!