Streaming operator

With regards to streaming operator, I have tried various options like 16 bits to bytes, int to bit array, queue to bit array, bit array to queue etc. I would like to know if there are any restrictions while using this operator.

Thanks,

In reply to verif_learner:

If you want to know, read section 11.4.14 Streaming operators (pack/unpack) of the 1800-2017 LRM and then ask a more specific question that you need help with.

In reply to dave_59:

In reply to verif_learner:
If you want to know, read section 11.4.14 Streaming operators (pack/unpack) of the 1800-2017 LRM and then ask a more specific question that you need help with.

Thanks. I have started going through LRM. I am not done yet with the section fully but I do have two questions.

I assume that streaming operator can also be used to convert array of one dimension to another array of a different dimension. In this context, I have a question whether to use the steaming operator on the RHS or on the LHS. A simple example does now show any difference though. I am probably missing some basic concept of streaming operator and hence this question.

The example is shown below:

module x;
  bit [1:0] arr_1[0:1] = {2'b01, 2'b01};
  bit [3:0] arr_2;
  bit [3:0] arr_3;
  bit arr_4[0:3];
  bit arr_5[0:3];
  
  initial begin
    {>>{arr_2}} = arr_1;
    {<<{arr_3}} = arr_1;
    {>>{arr_4}} = arr_1;
    arr_5 = {<<{arr_1}};
    
    $display ("%p ", arr_2);
    $display ("%p ", arr_3);
    $display ("%p ", arr_4);
    $display ("%p ", arr_5);
  end
endmodule

Output:

5
10
'{'h0, 'h1, 'h0, 'h1}
'{'h1, 'h0, 'h1, 'h0}

Please see the display for arr_4 and arr_5.

Question 2:
Are streaming operators fundamentally related to packed or unpacked arrays.
The literature seem to use these two together while describing.
I am not sure if the document mean, unpacking/packing an array or packed/unpacked array.
This is a bit confusing.

In reply to verif_learner:

Let me answer your second question first. The streaming operator uses the terminology pack when you take multiple variables and stream them into a single variable. And conversely, unpack is when you stream a single variable into multiple variables. Those terms are loose descriptions for usage. Your examples are neither; they are more like bit stream casting. When applied to arrays and structs, the terms packed and unpacked have a specific meaning about their data type. All packed types may be used in a bit-stream, but not all unpacked types can be used.

Back to your first question, in your case it does not matter which side the streaming operator appears because both sides are a single variables of the same size. There is one slight difference when the variables are not the same size as mentioned in section 11.4.14.3.