Quantcast
Channel: UVM SystemVerilog Discussions Forum RSS Feed
Viewing all articles
Browse latest Browse all 410

ISSUE with 11.4.14 Streaming operators (pack/unpack) if the size of source not even

$
0
0

Hello All,

module top;


initial begin
bit data_source [];
byte unsigned pack_data[];

data_source = new[3];
pack_data = new[2];

for(int i = 0 ; i < (data_source.size()) ; i++)begin
    if ((i %2) == 0)data_source[i] = 1'b1;
    $display("INITIALIZED VALUE OF DATA SOURCE [%d] = 0x%x",i,data_source[i]);
end

foreach(pack_data[i])$display("\nUNINITIALIZED VALUE OF PACKED ARRAY[%d] = 0x%x",i,pack_data[i]);

// Casting Little endianess
pack_data = {<<{data_source}};
foreach(pack_data[i])$display("\nVALUE OF {LITTLE ENDIAN} PACKED ARRAY[%d] = 0x%x",i,pack_data[i]);

// Casting BIG endianess
pack_data = {>>{data_source}};
foreach(pack_data[i])$display("\nVALUE OF {BIG ENDIAN} PACKED ARRAY[%d] = 0x%x",i,pack_data[i]);

end

endmodule:top

generates the following results:

 

Both the little endian and big endian results same ???

INITIALIZED VALUE OF DATA SOURCE [          0] = 0x1
INITIALIZED VALUE OF DATA SOURCE [          1] = 0x0
INITIALIZED VALUE OF DATA SOURCE [          2] = 0x1

UNINITIALIZED VALUE OF PACKED ARRAY[          0] = 0x00
UNINITIALIZED VALUE OF PACKED ARRAY[          1] = 0x00

VALUE OF {LITTLE ENDIAN} PACKED ARRAY[          0] = 0xa0

VALUE OF {BIG ENDIAN} PACKED ARRAY[          0] = 0xa0

but if keeping data_source = new[any even number]; // lets say keeping it 4

 

the following results looks fine 

VALUE OF {LITTLE ENDIAN} PACKED ARRAY[          0] = 0x50

VALUE OF {BIG ENDIAN} PACKED ARRAY[          0] = 0xa0

Can anybody help me with this ??

 

Thanks ,

KS


Viewing all articles
Browse latest Browse all 410

Trending Articles