arraysparametersverilogicarus

Can't create a 'real' type array in Verilog


I've tried creating a 'real' type value array in the following way in Icarus Verilog:

parameter width = 10;
shortreal b [width-1:0] = {0.0181,0.0487,0.1227,0.1967,0.2273,0.1967,0.1227,0.0487,0.0181};

Gives the following error:

error: Cannot assign to array b. Did you forget a word index?

I went through the icarus verilog src code error messages and the explanation to this one is "Special case: The l-value is an entire memory, or array slice". This is, in fact, an error in l-values. Detect the situation by noting if the index count is less than the array dimensions (unpacked)", which I assume means that the array index size differs from the declared one [width-1:0], which isn't true if I understand.

I've also tried:

parameter width = 10;
parameter [32:0] b [width-1:0] = {0.0181,0.0487,0.1227,0.1967,0.2273,0.1967,0.1227,0.0487,0.0181};

but without any success.

Using Icarus Verilog with -g2012 flag (for SV support)


Solution

  • It is only legal to use so-called array concatenation if you fill the entire array. You array have 10 elements, but there are only 9 on the right hand side:

    parameter width = 10;
    shortreal b [width-1:0] = {0.0181,0.0487,0.1227,0.1967,0.2273,0.1967,0.1227,0.0487,0.0181,0.0181};