状态机结构请教
时间:10-02
整理:3721RD
点击:
本人初学状态机,不知道状态机的结构,请各位大虾指教
本人的状态机结构是3段式:
1。时序电路:现代状态的赋值
always@(posedge[/email] clock or posedge reset)
begin
if(reset)
present_state<=s5;
else
present_state<=next_state;
end
2.组合电路:次态的赋值
always@(reset[/email] or din or present_state)
begin
if(reset)
next_state=s5;
else
begin
case(present_state)
s5:
begin
if(din)
next_state=s0;
else
next_state=s5;
end
s0:
begin
if(!din)
next_state<=s1;
else
next_state<=s0;
end
s1:
begin
if(!din)
next_state=s2;
else
next_state=s0;
end
s2:
begin
if(din)
next_state=s3;
else
next_state=s5;
end
s3:
begin
if(!din)
next_state=s4;
else
next_state=s0;
end
s4:
begin
if(din)
next_state=s0;
else
next_state=s2;
end
default:next_state=s5;
endcase
end
end
3.时序电路
输出变量的赋值
always@(posedge[/email] reset or posedge clock )
begin
if(reset)
dout<=0;
else if(next_state==s4)
dout<=1;
else
dout<=0;
end
请问标准的3段式结构是这样的么?标准的应该是怎样的?请指教
总源代码如下:序列检测
module seqdet(
clock,
reset,
din,
dout);
input clock,reset,din;
output dout;
reg dout;
reg[5:0] present_state,next_state;
parameter s0=6'b100000,s1=6'b010000,s2=6'b001000;
parameter s3=6'b000100,s4=6'b000010,s5=6'b000000;
always@(posedge[/email] clock or posedge reset)
begin
if(reset)
present_state<=s5;
else
present_state<=next_state;
end
always@(reset[/email] or din or present_state)
begin
if(reset)
next_state=s5;
else
begin
case(present_state)
s5:
begin
if(din)
next_state=s0;
else
next_state=s5;
end
s0:
begin
if(!din)
next_state<=s1;
else
next_state<=s0;
end
s1:
begin
if(!din)
next_state=s2;
else
next_state=s0;
end
s2:
begin
if(din)
next_state=s3;
else
next_state=s5;
end
s3:
begin
if(!din)
next_state=s4;
else
next_state=s0;
end
s4:
begin
if(din)
next_state=s0;
else
next_state=s2;
end
default:next_state=s5;
endcase
end
end
always@(posedge[/email] reset or posedge clock )
begin
if(reset)
dout<=0;
else if(next_state==s4)
dout<=1;
else
dout<=0;
end
endmodule
本人的状态机结构是3段式:
1。时序电路:现代状态的赋值
always@(posedge[/email] clock or posedge reset)
begin
if(reset)
present_state<=s5;
else
present_state<=next_state;
end
2.组合电路:次态的赋值
always@(reset[/email] or din or present_state)
begin
if(reset)
next_state=s5;
else
begin
case(present_state)
s5:
begin
if(din)
next_state=s0;
else
next_state=s5;
end
s0:
begin
if(!din)
next_state<=s1;
else
next_state<=s0;
end
s1:
begin
if(!din)
next_state=s2;
else
next_state=s0;
end
s2:
begin
if(din)
next_state=s3;
else
next_state=s5;
end
s3:
begin
if(!din)
next_state=s4;
else
next_state=s0;
end
s4:
begin
if(din)
next_state=s0;
else
next_state=s2;
end
default:next_state=s5;
endcase
end
end
3.时序电路
输出变量的赋值
always@(posedge[/email] reset or posedge clock )
begin
if(reset)
dout<=0;
else if(next_state==s4)
dout<=1;
else
dout<=0;
end
请问标准的3段式结构是这样的么?标准的应该是怎样的?请指教
总源代码如下:序列检测
module seqdet(
clock,
reset,
din,
dout);
input clock,reset,din;
output dout;
reg dout;
reg[5:0] present_state,next_state;
parameter s0=6'b100000,s1=6'b010000,s2=6'b001000;
parameter s3=6'b000100,s4=6'b000010,s5=6'b000000;
always@(posedge[/email] clock or posedge reset)
begin
if(reset)
present_state<=s5;
else
present_state<=next_state;
end
always@(reset[/email] or din or present_state)
begin
if(reset)
next_state=s5;
else
begin
case(present_state)
s5:
begin
if(din)
next_state=s0;
else
next_state=s5;
end
s0:
begin
if(!din)
next_state<=s1;
else
next_state<=s0;
end
s1:
begin
if(!din)
next_state=s2;
else
next_state=s0;
end
s2:
begin
if(din)
next_state=s3;
else
next_state=s5;
end
s3:
begin
if(!din)
next_state=s4;
else
next_state=s0;
end
s4:
begin
if(din)
next_state=s0;
else
next_state=s2;
end
default:next_state=s5;
endcase
end
end
always@(posedge[/email] reset or posedge clock )
begin
if(reset)
dout<=0;
else if(next_state==s4)
dout<=1;
else
dout<=0;
end
endmodule
Thanks
总是对三段式的时序不大清楚。请指教。
去这里看看就都懂了。
http://www.sunburst-design.com/papers/
飘过
网海逍遥乐 - 飘过顶一个!
,,,,,床上电脑桌
清明上河图十字绣
网上购物商城网站
