verilog的数据接收分析 状态机?
本帖最后由 atom100 于 2014-5-29 07:28 编辑请教大家,写了一个三段状态机,但状态停留在 原始状态,即:sta_idle不动
//rcv_and_analyse为数据报文接收解析模块,数据 rcv_data来自于上一个模块(数据接收模块)的一个8位寄存器 rcv_temp_r
modulercv_and_analyse(
inputclk,
input rst_n,
inputrcv_data
)
parameter
sta_idle = 4'd0;
sta_head = 4'd1;
sta_end= 4'd5;
regcurr_state;
next_state;
always @( posedge clk or negedge rst_n)
if(!rst_n)
curr_state <= sta_idle ;
else
curr_state <= next_state;
always @(*)
case(curr_state)
sta_idle :
if(rcv_data == 8'h02)
next_state = 4'd1;
else if(rcv_data == 8'h05)
next_state =4'd2;
else
next_state =curr_state ;
sta_head: next_state = 4'd2;
。。。。。。。 //中间报文分析
sta_end: next_state = 4'd2;
default:;
endcase
always @( posedge clk or negedge rst_n)
第三段,状态输出;
clk时钟为25Mhz,
rcv_data来自于 上一个模块(串口数据接收模块,通过移位操作将串行数据转换为并行数据,存储到一个寄存器8位寄存器rcv_temp_r里,然后从数据接收模块输出,然后送到这个数据报文接收解析模块的rcv_data端口) ,这样 是否可以正确分析 接收到的报文?我使用signal tap查看发现 报文rcv_data数据已经北正确接收了,而且报文头是8'h02 ,但是状态机并没有进入 sta_head = 4‘d1,而是 停留在 sta_idle = 4‘d0未动,
是什么原因?
是否在 数据接收模块和数据分析模块 之间必须加一个 fifo??
还是组合逻辑的 always(*)这样写敏感变量表有问题??
还是哪里有问题?
{:smile:}{:smile:}{:smile:}{:smile:}{:smile:}{:smile:}
页:
[1]