在FSM中处理异步信号的正确实现是什么? [英] What is the correct implementation of handling asynchronous signals in an FSM?
本文介绍了在FSM中处理异步信号的正确实现是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们正在用VHDL实现一个以太网MAC控制器。
开始时,这里是我的代码的一段代码片段。-- next state
PROCESS(p_state, phy_start, phy_ctr, phy_clk)
BEGIN
CASE p_state IS
WHEN sIDLE =>
IF(phy_start = '1' or rising_edge(phy_start)) THEN
n_state <= sPRE;
ELSIF(phy_start'event AND phy_start='0') THEN
n_state <= n_state;
ELSE
n_state <= sIDLE;
END IF;
............
问题是,我的教授告诉我,我将PHY_START关联为时钟信号,而在RISING_EDGE()中,只能与一个时钟相关联,即PHY_CLK。我希望发生的是,当PHY_START断言时,它将在下一个时钟周期进入sPRE状态。断言是在时钟的上升沿完成的。我已尝试
PROCESS(p_state, phy_start, phy_ctr, phy_clk)
BEGIN
CASE p_state IS
WHEN sIDLE =>
IF(phy_start = '1') THEN
n_state <= sPRE;
ELSIF(phy_start'event AND phy_start='0') THEN
n_state <= n_state;
ELSE
n_state <= sIDLE;
.............
但它不会输入PHY_START=‘1’,因为它发生在转换过程中。(我们称之为设置时间,在此时间内数据必须稳定才能正确读取)。那么正确的实现是什么呢?或者,如果断言发生在上升沿,则我别无选择,只能在2个时钟周期内断言PHY_START,或者必须在时钟的下降沿断言PHY_START。另外,下一个状态逻辑的敏感度列表的正确设置是什么?
推荐答案
如果一切都在phy_clk
下计时,则不应对其他信号使用RISING_EDGE()或‘EVENT。这些事件与时钟关联,而不是与信号关联。
如果要检测phy_clk
计时的信号何时上升,则应按如下方式操作:
process(phy_clk,nreset)
begin
if nreset = '0' then
phy_start_d <= '0';
elsif phy_clk = '1' and phy_clk'event then
phy_start_d <= phy_start;
end if;
end process;
phy_start_p <= phy_start and not phy_start_d;
phy_start_p
信号仅在phy_start
上升时置1,且与phy_clk
完全同步;
这篇关于在FSM中处理异步信号的正确实现是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文