hello sir i new to system verilog can you tell me why we are using streaming operator and i gone through some of example >> and << operator but this two example i am not able to understand what does 16 before concatenation in line 2 and in line 3 what is meaning of 4 and how it genrate the stream of 0101_11,beacuse answer must start from either left to right or right to left…
You should take a look at section 6.24.3 Bit stream casting first. A bit-stream cast is used to convert a data type of any shape made solely of bits to another data type of another shape. For example
typedef bit [7:0] array_of_bytes_t[16]];
typedef bit [31:0] array_of_words_t[4];
array_of_bytes_t a1;
array_of_words_t a2;
a1 = array_of_bytes'(a2);
The case will create a stream from a2 by taking the left most word bit (31) from the left most array element (0) and then proceed to take bits left-to-right in the word and left-to-right in the array. Then the stream will be assigned to a1 by taking the stream left to right and assigning bits to a1 in a similar left-to-right manner. The two data types must also have the exact same total number of bits.
But some times, you need something other than a simple left-to-right stream of bits, or don’t have the exact same number of bits in the two data types. That’s when you use the streaming operator. The >> or << is used to specify whether you want to stream left-to-right, or right-to-left respectively. The number after the << or >> specify that you want to stream some other chunk other than 1 bit (16 or 4 bits in your example.
So {<< 16 {j}} says you want to stream right-to-left in chunks of 16 bits. It will create a stream taking the right most chunk of j[15:0] first, followed by the chunk to the left j[31:16], which is effectively {j[15:0],j[31:16]}
{ << 4 { 6’b11_0101 }} says take the right most chunk of 4 bits first, which is effectively {4’b0101,2’b11}
thanks sir i understand the concept of operator streaming and casting but though i am not clear with example-2 << 4 { 6’b11_0101 }} means right to left with 4’bits aor my first 4-bit must be 1010 why its 0101(because this stream is starting from left to right)???
There is an example of this on page 240 of the 1800-2012 LRM(11.4.14.2 Re-ordering of the generic stream). You can use either 8 or byte to indicate you want chunks of 8 bits.