3
votes

i wrote a simple code for testing different methods in array. here is the code:

module assoc_arr;
 int temp,imem[*];
 initial
 begin
  imem[ 2'd3 ] = 1;
  imem[ 16'hffff ] = 2;
  imem[ 4'b1000 ] = 3;
  if(imem.first(temp))
   $display(" First entry is at index %0db ",temp);
  if(imem.next(temp))
   $display(" Next entry is at index %0h after the index 3",temp);
// To print all the elements alone with its indexs
  if (imem.first(temp) )
   do
    $display( "%d : %d", temp, imem[temp] );
   while ( imem.next(temp) );
 end
endmodule

here there is a warning :: "Using indicated method on wildcard associative arrays is non standard." at imem.first(temp) and imem.next(temp).

why this warning is showing??

2

2 Answers

4
votes

Because it is not allowed by the language specification. From section 7.9.4 of the 1800-2012 SystemVerilog spec.

The syntax for the first() method is as follows:

function int first( ref index );

where index is an index of the appropriate type for the array in question. Associative arrays that specify a wildcard index type shall not be allowed.

You can download the language reference here:

http://standards.ieee.org/getieee/1800/download/1800-2012.pdf

I believe if you change your example to use a non-wildcard array it will work and you won't get the warning.

Example:

int temp[bit[15:0]];

0
votes

If your associative array's key is always and only integer type, you can declare it as follows

int temp,imem[int];

Then your code should be able to run with first() and next() methods.