In Verilog, why can't I compare my (genvar) with an integer value in my (for) loop?

OP #6382837
I've written a bit of Verilog code that takes two input operands 
(leftOp) and (rightOp) and outputs (result), with a parameter (nmBits) 
that is the common length of all three of those operands, set to one by 
default. My code is:
1
module bwEqu ( result, leftOp, rightOp);
2
parameter nmBits = 1;
3
integer highBit = nmBits - 1;
4
output [ highBit:0] result;
5
input  [ highBit:0] leftOp;
6
input  [ highBit:0] rightOp;
7

8
integer poolSize = 3 * nmBits;
9
integer highPool = poolSize - 1;
10
wire pool [ highPool:0];
11
genvar ix;
12

13
for (ix = 0; ix <= highPool; ix = ix + 3)
14
begin
15
  nand2 na0( pool[ ix], leftOp[ ix / 3], rightOp[ ix / 3]);
16
  nor2 no0( pool[ ix + 1], leftOp[ ix / 3], rightOp[ ix / 3]);
17
  nt1 nt0( pool[ ix + 2], pool[ ix + 1]);
18
  nor2 no1( result[ ix / 3], pool[ ix], pool[ ix + 2]);
19
end
20

21
endmodule
When I try to simulate this with Icarus I get the following error 
messages:
1
D:\Hf\Verilog\Unpacked\Common>\Icarus\bin\iverilog -g2009 -o bwEqu.out bwEqu.sv
2
bwEqu.sv:13: error: Unable to bind parameter `highPool' in `bwEqu'
3
bwEqu.sv:13: error: Cannot evaluate genvar conditional expression: (ix)<=(highPool)
4
2 error(s) during elaboration.
5

6
D:\Hf\Verilog\Unpacked\Common>
Now I realize that there are much more simple ways of accomplishing my 
bit-wise equal that won't suffer from these problems; this is sort of a 
simplification of a problem I'm having with a considerably more 
complicated piece of code. The problem is the same; I've got an integer 
value, in this case (highPool), that I'm using to control my (for) loop, 
and for some reason the simulator is balking when it comes to comparing 
(ix) with that value. Anybody have any idea why Icarus is having this 
problem, and what I can do to solve the problem (short of splitting 
(pool) into three separate arrays)?

Reply

A question of your own? This thread is over 6 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.