|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
RT. 遇到一个棘手的Problem,书中给的verilog源码用Quatus II 不能综合得到FSM,而自己修改了之后能够综合出FSM,而我却找不出二者的本质差别,希望高人指点,谢谢!
书中源码如下:
module mealyfsm2(a,clkc,reset,z);
input a,clkc,reset;
output z;
reg z;
parameter st0=2'd0,st1=2'd1,st2=2'd2;
reg [0:2] nextstate,mealystate;
//timing sequential logic
always @(posedge reset or posedge clkc)
if(reset)
begin
mealystate<=0;
mealystate[st0]<=1'b1;
end
else
mealystate<=nextstate;
//combinational logic
always @(mealystate or a)
begin
nextstate=3'b0;
z=1'b0;
case (1'b1)
mealystate[st0]:
if(a)
begin
z=1'b1;
nextstate[st2]=1'b1;
end
else
nextstate[st0]=1'b1;
mealystate[st1]:
if(a)
begin
z=1'b1;
nextstate[st0]=1'b1;
end
else
nextstate[st1]=1'b1;
mealystate[st2]:
if(a)
nextstate[st1]=1'b1;
else
nextstate[st2]=1'b1;
endcase
end
endmodule
自己修改后改的代码如下:
module mealyfsm2_2(a,clkc,reset,z);
input a,clkc,reset;
output z;
reg z;
reg [0:2] nextstate,mealystate;
parameter st0=3'b100,st1=3'b010,st2=3'b001;
//timing sequential logic
always @(posedge reset or posedge clkc)
if(reset)
mealystate<=st0;
else
mealystate<=nextstate;
//combinational logic
always @(mealystate or a)
case (mealystate)
st0:
begin
z=(a)?1:0;
nextstate=(a)?st2:st0;
end
st1:
begin
z=(a)?1:0;
nextstate=(a)?st0:st1;
end
st2:
begin
z=0;
nextstate=(a)?st1:st2;
end
default:
begin
z=0;
nextstate=st0;
end
endcase
endmodule |
|