Why an associative array can not be assigned to either dynamic array or queue/Fixed array

Hi,

can i assign a associative array to either dynamic array or queue/Fixed array?

Is vice versa is applicable?

For Example:

module top;

  class A;
   bit[3:0] q[$];
   bit[3:0] aa[int];
  endclass

 initial begin
    A A1;
    A1 = new();
    A1.q[0] = 5;
    A1.q[1] = 10;
    A1.q.push_back(15);

   aa = q; /*-->Getting compilation error like "Incompatible complex type assignment Type of source expression is incompatible with type of target expression. Mismatching types cannot be used in assignments, initializations and instantiations. The type of the target is 'bit[3:0]$[int]', while the type of the source is 'bit[3:0]$[$]'.*/



   A A1;
   A1 = new();
   A1.aa[0] = 5;
   A1.aa[1] = 10;
   A1.aa[5] = 15;

   q = aa;/* --> [b]Getting compilation error like "Incompatible complex type assignment Type of source expression is incompatible with type of target expression. Mismatching types cannot be used in assignments, initializations and instantiations. The type of the target is 'bit[3:0]$[$]', while the type of the source is 'bit[3:0]$[int]'.*/

end
endmodule

May i know how to assign an assoc array to dynamic array or queue/Fixed array in above context.

Thanks and Regards,
koti

In reply to pkoti0583:

associative array is a sparse memory - i.e it could be aa[0],aa[2],aa[5] without having aa[1],[3],[4]…etc
whereas queue and regular arrays are sequentially indexed… now how would they be compatible… ???

In reply to ssureshg_:

if you use continuous/sequential index for assoc array then also you will get compilation error.
Example
A A1;
A1 = new();
A1.aa[0] = 5;
A1.aa[1] = 10;
A1.aa[2] = 15;
A1.aa[3] = 4;

q = aa;

In reply to pkoti0583:

well, associative array implementation(in tool) is not just assigning memories unlike arrays, it uses hash tables.
You may have to understand hash tables …

In reply to pkoti0583:

It doesn’t matter if the current contents of associative array have indexes in consecutive order. That may not always be the case, and the compiler needs make sure the statement always executes legally.

It’s like rules for driving on one side of the road. It doesn’t matter if there happens to be no cars on the other side of the road, you are always required to keep to the legal side of the road.

In reply to dave_59:

I like the road analogy Dave_59… :)

In reply to dave_59:

May i know whether it is legal or illegal in above of my examples?

In reply to pkoti0583:
The syntax errors you are getting are correct. Your code is illegal.