[How to] Assign integer value to unpacked array slice

In reply to dave_59:

In reply to Fipser@VA:
We cannot understand what your intent is. Are you looking for

tcode_tx[7] == tc_counter[5] &&
tcode_tx[6] == tc_counter[4] &&
tcode_tx[5] == tc_counter[3] &&
tcode_tx[4] == tc_counter[2] &&
tcode_tx[3] == tc_counter[1] &&
tcode_tx[2] == tc_counter[0]

Can you make code_tx a packed array? Then you could do

tcode_tx[7:2] == tc_counter;

Hi,

the code above works, thanks! Is there no other way to do it besides assigning the value bit by bit? (type casting, streaming, anything else?)

I chose tcode_tx to be an unpacked array, because the array is passed as a parameter to a task inside a driver, where the parameter can also be a queue (thus unpacked).

My intention was to increment an integer value (here: tc_counter) and with every new sequence item assign the incremented value to the slice tcode_tx[7:2], i.e. assign the int type value to a 6 bit wide slice of an unpacked array (somehow!). That’s why I reset tc_counter to 0 if it hits 63 = 6’b111111.

Even if I assigned a constant value, as I would do to initialize an unpacked array, e.g.

tcode_tx[7:2] == '{1,1,0,0,1,0}

within the randomization part, I get a compilation error.