1

I have some queues declared like so:

static bit [127:0]   same_addr_mem_model [int][$]; 
static bit [127:0]   temp_addr_mem_model [int][$];

Then later on the line of code:

same_addr_mem_model[write_addr].insert(0,temp_addr_mem_model[write_addr]); // write_addr is some int

And that line gives me the compiler error with Cadence IES:

assignment operator type check failed (expecting datatype compatible with 'packed array' but found 'queue of packed array [127:0] of bit' instead).

But as I've found documentation online it looks like a queue is a perfectly valid argument for insert(). Any idea what is wrong here? This code compiles and runs with Synopsys VCS, by the way.

Greg
  • 18,111
  • 5
  • 46
  • 68
Rich
  • 1,165
  • 1
  • 15
  • 29

1 Answers1

3

The function prototype for insert is:

function void insert(input int index, input element_t item);

So if you are creating a queue of ints then you cannot add a queue of ints using insert.

It's not uncommon for vendors to not implement all of the language spec, or implement vendor-specific features that are not in the spec. This is a case though where is seems VCS is just wrong for allowing this. I would double-check that it's actually doing what you expect.

Functions in SystemVerilog cannot be overloaded by argument type, so there would be no way to implement two insert functions, one taking the element type and the other taking a queue of elements.

You should be able to get the equivalent behavior using assignment syntax.

same_addr_mem_model[write_addr] = {temp_addr_mem_model[write_addr], same_addr_mem_model[write_addr]});

See section 7.10.4 of the 2012 SystemVerilog spec.

dwikle
  • 6,820
  • 1
  • 28
  • 38
  • Ok that is interesting to know. In regards to the problem at hand, I assume logically the code is trying to insert the contents of temp_addr_mem_model[write_addr] into same_addr_mem_model[write_addr] at the front of the queue. Is there a method that can do this or do I need to do it one at a time? – Rich May 20 '13 at 16:09
  • I made the same assumption about your example code. My answer shows how to do the same with an assignment, e.g. q1 = {q1, q2}. – dwikle May 20 '13 at 17:08