1

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)

toolic
  • 57,801
  • 17
  • 75
  • 117
Ginjas
  • 13
  • 2

1 Answers1

1

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};
Matthew Taylor
  • 13,365
  • 3
  • 17
  • 44
  • That's the case with commercial simulators, anyway. Icarus doesn't seem to like it either way. https://www.edaplayground.com/x/9AQG – Matthew Taylor Oct 28 '20 at 07:34
  • Also,should I then use the I/O file operation to accomplish this? Let's say,put the numbers on a .txt and then put those on a memory of the same dimensions as above? – Ginjas Oct 28 '20 at 08:57
  • @Ginjas That's up to you. If these numbers are being written to a file from some other program then I would imagine it would be better to write some Verilog/SV to read that file rather than having to paste those values into your code. (Unless the code were synthesisable, in which I doubt your synthesiser would make sense of it.) – Matthew Taylor Oct 28 '20 at 10:19