0

I have an array 32 bit wide of n elements and I am trying to assign these elements to a vector, I have the following code:

 function automatic logic [SIZE-1:0] my_function (my_array x_map);

    logic SIZE-1:0] y_map               = '0;
    int fctr                            = (SIZE)/32;
    int top_bnd                         = 31;
    int lwr_bnd                         = 0;

for(int k0 = 0; k0 < fctr; k0++)
    begin

    y_map[top_bnd:lwr_bnd]              = x_map[k0];
    top_bnd                             = (top_bnd + 32'hFFFF);
    lwr_bnd                             = (lwr_bnd + 32'hFFFF);

    end

return y_map;

endfunction

However this is not working and I get two errors:

1) "the range of the part select is illegal" 2) "Cannot evaluate the expression in left slicing expression, the expression must be compile time constant"

Thanks

George
  • 137
  • 1
  • 17

1 Answers1

0

You might want to use the streaming operators for this

y_map = {<<32{x_map}};

BTW, you should show the declarations of all identifiers in your example, i.e. my_array.

dave_59
  • 39,096
  • 3
  • 24
  • 63
  • Hey Dave, Thank you for this answer and sorry about not identifying my declarations. I have a question though, is the streaming operator synthezisable? – George May 02 '18 at 14:07
  • 1
    It is a synthesizable construct. Whether _your_ synthesis tool has implemented it is another question. – dave_59 May 02 '18 at 14:10
  • For some reason using << reversed the order of bits but by using >> I had the same order of bits – George May 02 '18 at 15:36
  • 1
    That is correct. Read section **11.4.14 Streaming operators (pack/unpack)** in 1800-2017 LRM – dave_59 May 02 '18 at 17:03