How to select specific bits from integer and assign it to queue of byte

In reply to Sarit8r:

Use the streaming pack/unpack operator

module top;
  
  byte unsigned data[$];
  int burst_width, raw_data;
  
  initial begin
    raw_data = 'h01234567;
    $displayh("raw_data %h",raw_data);
    for(burst_width=1;burst_width<5;burst_width++) begin
      data = {>>{raw_data with [(burst_width*8)-1:0]}};
      $displayh("%0p",data);
    end
  end
endmodule
1 Like