EmbDev.net

Forum: FPGA, VHDL & Verilog Having trouble understanding warnings and syntax errors in my Verilog.


von Kevin S. (kvnsmnsn)


Rate this post
useful
not useful
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.

von Andy (Guest)


Rate this post
useful
not useful
> input  operand [ nmBits:1];
 Die Bitweite muss vor dem Namen stehen (wie bei wire)

> genvar integer ix;
 Lass integer weg.

> xor x2( rships[ 2], operand[ 1], operand[ 2]);
 Der operator für XOR ist ^

>   for (ix = 3; ix <= nmBits; ix++)
 ix++ geht nicht in Verilog, schreibe ix=ix+1


Hier eine sehr vereinfachte Version:
1
module incPort ( result, operand);
2
 parameter nmBits = 2;
3
 output result;
4
 input  [nmBits-1:0] operand;
5
6
 assign result = ^operand;
7
8
endmodule

von Andy (Guest)


Rate this post
useful
not useful
Sorry just realized this is from the english forum

> input  operand [ nmBits:1];
 write the bitsize before the label, like you've done for wire

> genvar integer ix;
 No 'integer' needed

> xor x2( rships[ 2], operand[ 1], operand[ 2]);
 Use ^ for xor, like in C.

>   for (ix = 3; ix <= nmBits; ix++)
 ix++ is no valid Verilog, use: ix=ix+1


A simplified version of your module:
1
module incPort (result, operand);
2
 parameter nmBits = 2;
3
 output result;
4
 input  [nmBits-1:0] operand;
5
6
 assign result = ^operand;
7
8
endmodule

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.