If statement 应为左括号(';(';)[12.1.3.3(IEEE 2001)]

If statement 应为左括号(';(';)[12.1.3.3(IEEE 2001)],if-statement,verilog,If Statement,Verilog,我一直得到以下日志: file: lab1.v if (in1 == 1) | ncvlog: *E,EXPLPA (lab1.v,25|1): expecting a left parenthesis ('(') [12.1.3.3(IEEE 2001)]. (#1 y = 1'b1; | ncvlog: *E,EXPENM (lab1.v,26|1): expecting the keyword 'endmodule' [12.1(IEEE)].

我一直得到以下日志:

file: lab1.v
if (in1 == 1)
 |
ncvlog: *E,EXPLPA (lab1.v,25|1): expecting a left parenthesis ('(') [12.1.3.3(IEEE 2001)].
        (#1 y = 1'b1;
        |
ncvlog: *E,EXPENM (lab1.v,26|1): expecting the keyword 'endmodule' [12.1(IEEE)].
        module worklib.ex1:v
                errors: 2, warnings: 0
ncvlog: *F,NOTOPL: no top-level unit found, must have recursive instances.
irun: *E,VLGERR: An error occurred during parsing.  Review the log file for errors with the code *E and fix those identified problems to proceed.  Exiting with code (status 2).
对于以下代码:

module ex1 (in1, in2 ,clk , out1 , out2, bus);

//input&outputs
//==============
input in1,in2,clk;
output out1,out2,bus;

//reg
//====
reg out1= 1'b0, out2=1'b0, y=1'b0 ;//y = previos state
reg [2:0] bus=3'b000;

//on clk pose edge
//=================
always @(posedge clk) begin
if ((in1==1)&&(y==0))
    out1=1;
else if ((in1==0)&&(y==1))
    out2 = 1;
else 
    out1 = 0;
    out2 = 0;
end if

if (in1 == 1)
    #1 y = 1'b1;
else if (in1 == 0)
    #1 y = 1'b0;
end if 


if((negedge in2)&&(in1==1))
    bus = 3'b001;
else if ((negedge in2)&&(in1==0))
    bus = 3'b000;
else
    bus <= bus + 1;

end if

end

endmodule
模块ex1(in1、in2、时钟、out1、out2、总线);
//输入与输出
//==============
输入in1,in2,时钟;
输出out1,out2,总线;
//注册
//====
reg out1=1'b0,out2=1'b0,y=1'b0;//y=previos状态
reg[2:0]总线=3'b000;
//关于clk姿势边缘
//=================
始终@(posedge clk)开始
如果((in1==1)和&(y==0))
out1=1;
else如果((in1==0)和&(y==1))
out2=1;
其他的
out1=0;
out2=0;
如果结束
如果(in1==1)
#1 y=1'b1;
else如果(in1==0)
#1 y=1'b0;
如果结束
if((负边in2)和&(in1==1))
总线=3'b001;
else如果((负边in2)和&(in1==0))
总线=3'b000;
其他的

总线在Verilog中,使用
begin…end
进行范围界定

if ((in1==1)&&(y==0))
    out1=1;
else if ((in1==0)&&(y==1))
    out2 = 1;
else 
    out1 = 0;
    out2 = 0;
end if
应改写为

if ((in1==1)&&(y==0))
    out1=1;
else if ((in1==0) && (y==1))
    out2=1;
else 
  begin
    out1 = 0;
    out2 = 0;
  end

其他
if…else…end if
块应以类似方式重写。
end if
在Verilog中不起作用。

除了您得到的错误之外,您的代码中还有其他问题。
if((negedge in2)和&(in1==1))
是非法语法。
#1y=1'b1;不可合成。谢谢!我一直收到一个错误:“总是@(negedge in2)开始”说:“退出一个任务”-Nedge不是一个陈述吗?@user3307122如果你发布一个格式良好的新问题,回答起来会更容易。我发现在写出来的过程中,我经常发现错误。