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)?