3

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 Answers 2

4

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]];

Sign up to request clarification or add additional context in comments.

1 Comment

hi, i changed my code and wrote ` int temp[temp[15:0]]`. but it showed error.
0

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.

2 Comments

hi, i wrote like above one. but it showed error as: ref formal and actual do not have equivalent data types (expecting datatype compatible with 'int' but found 'integer' instead).
May I know the simulator you are using now? I use VCS and your original code can run correctly (but LRM denies such usage for wildcard index). If I use IUS, I have to modify your code to int temp, imem[int];. Or you may try to change all int to integer type (2-value V.S 4-value) and try again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.