I have been trying to run this Verilog code which simulates traffic decongestion, but I am getting this error. I have also tried to use an always block, but I am still not able to resolve it. Following are my design and testbench files in that order.
// main module
module test2(v1, v2, v3, v4, v5, h, l, lane_no);
input v1, v2, v3, v4, v5, h, l;
output[1 : 0] lane_no;
wire local;
wire x1, x2, p;
wire e3, e2, e1;
assign local = v1 & v2 & v3;
wire[2 : 0] count1 = 3'b000;
wire[2 : 0] count2 = 3'b000;
wire a1, a2, a3, b1, b2, b3;
assign a1 = count1[0];
assign a2 = count1[1];
assign a3 = count1[2];
assign b1 = count2[0];
assign b2 = count2[1];
assign b3 = count2[2];
if (local) begin // This is Line 26 (see error messages)
assign lane_no = 2'b11;
end
else
begin
assign e3 = ~(a3^b3);
assign e2 = ~(a2^~b2);
assign e1 = ~(a1^~b1);
assign x1 = (~a3 & b3) + (e3 & ~a2 & b2) + (e3 & e2 & ~a1 & b1);
assign x2 = ~x1;
assign p = e3 & e2 & e1;
if (p == 1)
begin
if (count1 == 3'b000)
begin
assign lane_no = 2'b01;
assign count1 = count1 + 3'b001;
assign count1 = count1 - 3'b001;
end
end
end
endmodule
I am getting this error when I execute the following command:
harshal@dl8-OptiPlex-9010:~/Desktop$ iverilog test.v testbench.v
test.v:26: error: Unable to bind parameter `local' in `main.dut'
test.v:26: error: Cannot evaluate genvar conditional expression:
local
test.v:26: error: Unable to bind parameter `local' in `main.dut'
test.v:26: error: Cannot evaluate genvar conditional expression:
local
4 error(s) during elaboration.
module main;
reg v1,v2,v3,v4,v5,h,l;
wire[2:0] lane_no;
test2 dut(v1,v2,v3,v4,v5,h,l,lane_no);
initial begin
v1=1;v2=1;v3=1;v4=0;v5=0;h=1;l=0;
#10 v1=1;v2=0;v3=1;v4=0;v5=0;h=1;l=0;
#10 v1=1;v2=1;v3=0;v4=0;v5=0;h=0;l=1;
end
initial begin
$monitor(" output= %b%b%b",lane_no);
end
endmodule
I am not able to figure out the exact error as I am beginner in Verilog programming.