1

I am using v10 of Icarus Verilog, Windows 8.1 and am having troubles compiling 1D arrays like:

localparam [15:0] A[0:5]  = {
    0,
    10920, 
    21840,
    32760,
    43680,
    54600
};

or 2D array like:

localparam [1:0] B[0:5][0:2] = {
    {2'b00, 2'b10, 2'b01},
    {2'b10, 2'b00, 2'b01},
    {2'b10, 2'b01, 2'b00},
    {2'b00, 2'b01, 2'b10},
    {2'b01, 2'b00, 2'b10},
    {2'b01, 2'b10, 2'b00}
};

When I try to compile this using iverilog inside command prompt like: iverilog -o tb.vvp ".v files here" I get the following errors:

tb.v:39: syntax error
tb.v:39: error: syntax error localparam list.
tb.v:54: syntax error
tb.v:54: error: syntax error localparam list.

Lines 39 and 54 are lines where upper two arrays are located.

What is wrong and how can I fix this ridicilous error?

user1806687
  • 934
  • 1
  • 10
  • 27

1 Answers1

1

Verilog does not support unpacked arrayed parameters/localparams; SystemVerilog does. See:

Icarus Verilog (iverilog) has limited SystemVerilog support. EDAplayground currently includes Icarus Verilog 0.10.0 11/23/14, which does not support unpacked arrayed parameters with SystemVerilog enabled. You can try with the latest version of Icarus. Enable SystemVerilog by changing your file extinctions from .v to .sv, you may need to add the -g2012 compile option.

If that doesn't work, you will need to convert the array into a large vector. You can slice the array with the +: operator (Added in Verilog 2001 and supported with Icarus Verilog. See Indexing vectors and arrays with +:). Or change to another simulator that supports SystemVerilog.

Greg
  • 18,111
  • 5
  • 46
  • 68