I just got done writing a module that takes as input (operand) whose
length varies depending on parameter (nmBits), and outputs a single bit
(result) that I want to be the exclusive or of all the bits in
(operand). Here's my code:
1 | // (c) Kevin Simonson 2020
|
2 |
|
3 | module incPort ( result, operand);
|
4 | parameter nmBits = 2;
|
5 | output result;
|
6 | input operand [ nmBits:1];
|
7 |
|
8 | wire [ nmBits:2] rships;
|
9 | genvar integer ix;
|
10 |
|
11 | xor x2( rships[ 2], operand[ 1], operand[ 2]);
|
12 | generate
|
13 | for (ix = 3; ix <= nmBits; ix++)
|
14 | begin
|
15 | xor xix( rships[ ix], operand[ ix], rships[ ix - 1]);
|
16 | end
|
17 | endgenerate
|
18 | assign result = rships[ nmBits];
|
19 |
|
20 | endmodule
|
Then when I tried to simulate it with Icarus I got error messages:
1 | D:\Hf\Verilog\Unpacked\Common>\Icarus\bin\iverilog -g2009 -o incPort.out incPort.sv
|
2 | incPort.sv:6: warning: Array dimensions in incomplete port declarations are currently ignored.
|
3 | incPort.sv:6: : The dimensions specified in the net or variable declaration will be used.
|
4 | incPort.sv:9: syntax error
|
5 | incPort.sv:9: error: invalid module item.
|
6 | incPort.sv:13: syntax error
|
7 | incPort.sv:15: error: invalid module item.
|
8 | incPort.sv:16: syntax error
|
9 | incPort.sv:18: error: invalid module item.
|
10 | incPort.sv:20: syntax error
|
11 | I give up.
|
12 |
|
13 | D:\Hf\Verilog\Unpacked\Common>
|
What exactly do the complaints about line 6 (line "input operand [
nmBits:1];") mean? And why is it calling my (genvar) declaration a
syntax error? Furthermore, why are the beginning of my for loop, the
(end) at the end of that for loop, and the (endmodule) declaration
designated as syntax errors? Any information on this would be greatly
appreciated.