集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: CTT

请教fpga高手:状态机状态不稳定的原因

[复制链接]
longtim 发表于 2010-6-26 14:02:54 | 显示全部楼层
youhui,你好,我的问题解决了,简单总结一下:<br>
根据Altera的资料,状态机进入非法状态的原因有两种:<br>
1、状态机的状态转换条件判断信号如果是异步时钟域信号,很容易产生亚稳态,使状态机进入非法状态。<br>
2、FPGA工作于高温或放射线环境下。<br>
<br>
我的情况就是第1种,你的也应该是。<br>
解决方法是将异步时钟域信号同步化,我的异步输入信号比我的主时钟频率低得多,于是将其做了两次采样,使用采样后的信号作为判断条件就解决了。<br>
<br>
你的程序中将异步信号serial_signal_in 作为状态跳转判断条件,仅将其写入敏感表是不行的,必须对其做同步化处理,对于串口信号来讲,一般情况下能满足比FPGA的时钟慢得多的条件,所以可以使用两次采样的方法。试一试吧。<br>
<br>
另外,状态机中的When others(default)语句,作用只是指定了状态机的初始状态,而不能保证将电路状态从非法跳回默认状态。原因是综合工具默认将从非法状态跳回合法状态的电路综合掉了,可以使用安全状态机选项使其不被综合掉。(from Altera)<br>
我不用QQ,可以使用论坛的短消息功能交流。
inter 发表于 2010-6-26 14:34:02 | 显示全部楼层
谢谢!!thuder了.我明白了,我那句,可能避免了综合时把&ldquo;从非法状态跳回合法状态的电路综合掉了&rdquo;!很高兴认识你!!
       
<br>
<br>
[ 本帖最后由 youhui 于 2007-4-2 11:40 编辑 ]
VVIC 发表于 2010-6-26 15:10:15 | 显示全部楼层
youhui,我后面的那段话可能误导你了,你加的那句temp肯定是不能避免将这部分电路综合掉的,这需要在开发环境中选择安全状态机选项来做到,只不过你的那条语句影响了电路的时序,在当前条件下暂时没有出现亚稳态。根本的解决方法还是将异步信号同步化。
VVC 发表于 2010-6-26 15:16:29 | 显示全部楼层
我用的编程环境是ise7.1 ,我在属性设置里看到一下三个选项:<br>
hdl options<br>
1 :FSM&nbsp;&nbsp;Enconding Algorithm&nbsp; &nbsp;<br>
2: safe implementation&nbsp; &nbsp; <br>
3:case implementation style<br>
你所说的应该是第二项吧!<br>
那是不是选择了第二项,就不用转serial_in为同步信号呢??<br>
如果我用时钟作为化状态转移 模块的触发条件,应该相当于同步了serial_in.<br>
<br>
??????????
       
ATA 发表于 2010-6-26 16:19:03 | 显示全部楼层
我没有用过ISE,QII6.1有个选项好像叫&ldquo;Safe StateMachine....&rdquo;。不要将希望寄托于此项,必须要将异步信号同步化。<br>
<br>
现将你的代码摘出来一段:<br>
case(state)<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;idle:&nbsp; &nbsp; if(serial_signal_in == 0)<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;begin<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;next_state = starting;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;clr_Sample_counter = 1;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; //校正采样寄存器,找到一个合适的采样起始时刻<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;end&nbsp;&nbsp;else<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;begin<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; //next_state =&nbsp;&nbsp;idle;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; if(sample_counter&gt;7)&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;//在没有数据输入的情况下,提供时钟,<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;begin<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;clr_Sample_counter = 1; //<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;flag_wclk&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; = 1;&nbsp; &nbsp;&nbsp; &nbsp;//<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;w_rst1&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; = 1;&nbsp; &nbsp;&nbsp;&nbsp;//<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; end&nbsp;&nbsp;else<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;inc_Sample_counter = 1;//&nbsp;&nbsp;以上几段其实相当于分频<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; end<br>
<br>
<br>
你这里的serial_signal_in 就是状态跳转的判断条件,必须将其同步化。<br>
<br>
例如用一个always模块<br>
always@(posedge clk)<br>
...<br>
serial_signal_in1&lt;=serial_signal_in;<br>
serial_signal_in2&lt;serial_signal_in1;<br>
....<br>
<br>
将上面的状态跳转条件serial_signal_in用serial_signal_in2代替。
Sunlife 发表于 2015-6-25 10:14:48 | 显示全部楼层

综合工具综合出的结果肯定是你代码的表述,如果综合结果与你的设计思路有冲突,首先应该考虑是自己在代码表述时候是否有错,看了你的代码,感觉综合工具没出问题,因为你低电平复位,所以每个状态转到s0都会有(!rst)这个条件的
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-5-6 19:07 , Processed in 0.061740 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表