我正在这里做这项工作
http://web.cs.hacettepe.edu.tr/~onderefe/bbm231/2013-2014%20Guz%20Proje.pdf
并得到这些错误:
microislemci.v:10: error: Cannot evaluate genvar conditional expression:
(opcode)==(4'd0)
microislemci.v:10: error: Cannot evaluate genvar conditional expression:
(opcode)==(4'd0)
2 error(s) during elaboration.
任何想法?
module mikroislemci(data1,data2,opcode,data_out,flag);
input [7:0] data1;
input [7:0] data2;
input [3:0] opcode;
output [7:0] data_out;
output [4:0] flag;
wire [8:0] tmp;
wire [7:0] tmp1;
if(opcode == 4'b0000)
begin
if (data1==data2)
begin
assign flag[0]=1;
end
else
begin
assign tmp = data1+data2;
assign data_out=tmp [7:0];
assign flag[2]=tmp [8];
end
end
else if (opcode==4'b0001)
begin
if (data1==data2)
begin
assign flag[0]=1;
end
if(data1>data2)
begin
assign data_out=data1-data2;
end
else
begin
assign data_out=data2-data1;
assign flag[1]=1;
end
end
else if (opcode==4'b0010)
begin
assign data_out[0]=data1[0] & data2[0];
assign data_out[1]=data1[1] & data2[1];
assign data_out[2]=data1[2] & data2[2];
assign data_out[3]=data1[3] & data2[3];
assign data_out[4]=data1[4] & data2[4];
assign data_out[5]=data1[5] & data2[5];
assign data_out[6]=data1[6] & data2[6];
assign data_out[7]=data1[7] & data2[7];
end
else if (opcode==4'b0011)
begin
assign data_out[0]=data1[0] || data2[0];
assign data_out[1]=data1[1] || data2[1];
assign data_out[2]=data1[2] || data2[2];
assign data_out[3]=data1[3] || data2[3];
assign data_out[4]=data1[4] || data2[4];
assign data_out[5]=data1[5] || data2[5];
assign data_out[6]=data1[6] || data2[6];
assign data_out[7]=data1[7] || data2[7];
end
else if (opcode==4'b0100)
begin
assign data_out[0]=data1[0] ^ data2[0];
assign data_out[1]=data1[1] ^ data2[1];
assign data_out[2]=data1[2] ^ data2[2];
assign data_out[3]=data1[3] ^ data2[3];
assign data_out[4]=data1[4] ^ data2[4];
assign data_out[5]=data1[5] ^ data2[5];
assign data_out[6]=data1[6] ^ data2[6];
assign data_out[7]=data1[7] ^ data2[7];
end
else if (opcode==4'b0101)
begin
assign data_out[0]= !(data1[0]);
assign data_out[1]= !(data1[1]);
assign data_out[2]= !(data1[2]);
assign data_out[3]= !(data1[3]);
assign data_out[4]= !(data1[4]);
assign data_out[5]= !(data1[5]);
assign data_out[6]= !(data1[6]);
assign data_out[7]= !(data1[7]);
end
else if (opcode==4'b0110)
begin
if(data1==data2)
begin
assign flag[0]=1;
end
else if(data1<data2)
begin
assign flag[4]=0;
end
else if(data1>data2)
begin
assign flag[4]=1;
end
end
else if (opcode==4'b0111)
begin
assign data_out=data1<<data2;
end
else if (opcode==4'b1000)
begin
assign data_out=data1>>data2;
end
else
begin
display("you entered wrong opcode try again");
end
endmodule
答案 0 :(得分:3)
你没有写出正确的verilog。 if
语句需要进入程序块(如always
),它们不能单独存在于模块中。
围绕整个if语句,放置这个组合程序块:
always @* begin //<--- new line
if(opcode == 4'b0000)
...
else if
...
end
end //<--- new line
同样在程序块中,您不需要关键字assign
(这意味着其他内容),因此从块内的所有行中删除所有assign
。而不是assign a=b;
,只需撰写a=b;
。
您还需要将wire
类型更改为reg
类型,以便在程序块中进行分配。