Verilog 状态机代码编译不过问题在哪?

Verilog编写状态机的程序如下,始终有错误,求解决

module fsm(clk, button0, button1, UNLOCK);
input button0,button1;
output UNLOCK;

//define state space
parameter S0 = 2'b00;
parameter S1 = 2'b01;
parameter S2 = 2'b10;
parameter S3 = 2'b11;

//define clk
reg clk = 0;
always #50 clk = ~clk;

//internal variable
reg [1:0] current_state;
reg [1:0] next_state;
wire button0;
wire button1;
reg IN0 = button0;
reg IN1 = button1;
reg current_OUT0;
reg current_OUT1;
reg next_OUT0;
reg next_OUT1;

//transition
always @(posedge clk)
begin
IN0 = button0;
IN1 = button1;
end

always @(posedge IN0)
begin
current_OUT0 = next_OUT0;
next_OUT0 <= 1'b1;
#50 next_OUT0 <= 1'b0;
zero = current_OUT0;
end

always @(posedge IN1)
begin
current_OUT1 = next_OUT1;
next_OUT1 <= 1'b1;
#50 next_OUT1 <= 1'b0;
one = current_OUT1;
end

next_state = current_state;

//next state decision
always @(current_state)
begin
case(current_state)
S0:
begin
if(button0) next_state <= S3;
else next_state <= S0;
end

S1:
begin
    if(button1)  next_state = S0;
    else if(button0)  next_state = S2;
    else  next_state = S1;
end

S2:
begin
    if(button1)  next_state = S1;
    else if(button0)  next_state = S3;
    else  next_state = S2;
end

S3:
begin
    if(button1)  next_state = S0;
    else  next_state = S3;
end

endcase

end

//action
wire UNLOCK;
assign UNLOCK = (current_state == S2) ? 1'b1 : 1'b0;

endmodule

提示的错误是
Error (10170): Verilog HDL syntax error at try1.v(50) near text "="; expecting ".", or "("
Error (10112): Ignored design unit "fsm" at try1.v(1) due to previous errors

请问有人帮忙看一下吗

1个回答

找到try1.v(50),也就是try1.v的第50行,检查下=附近,有语法错误

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

0
Verilog三六九分频计数器拓展
0
新手Verilog问题,4路输入1路输出,4个输入任意一个只要出现上升沿,输出就翻转
1
关于无伸缩因子的cordic算法的verilog代码该怎么写?
1
π_4-DQPSK调制解调算法matlab仿真及FPGA硬件实现?
1
verilog数码管静态显示计数器
1
数字逻辑基础与verilog设计(加 斯蒂芬布朗)第三版习题答案(触发器,寄存器和计数器)
1
verilog使用串口调试助手发送数据处理后接受,出现如下问题?
2
verilog 中的reg类型变量不能根据其他变量控制位数吗?
1
用verilog写出来的计数器,编译成功,但是为什么在仿真时输出有7ns延时?
0
请问怎么去控制qsys搭建的SDRAM这个ip核
1
4-16译码器Verilog门级建模该怎么写?
0
用VerilogHDL 写一个A算术逻辑运算器ALU
1
我想用verilog HDL写一个电子时钟(只显示分秒),要附加一个秒表功能但是always不能加入两个posedge,应该怎么改进。
1
Verilog+niosⅡ 如何实现数字电子钟功能?
1
【Verilog语句】用的quartus17.1,程序编译没有问题,但模块一直调用不出来,求大佬帮看
1
求四选一数据选择器级联成八选一数据选择器verilog代码,急求!!!!!!!
0
有关verilog中例化参数传递的问题,是否不能在例化中传递二维数组参数?
1
求助,如何用门电路实现一个T触发器?
0
verilog结构描述方面的问题
2
verilog用状态机实现循环彩灯控制器(含清零功能)