使用流运算符连接动态数组的所有元素

问题描述 投票:0回答:1

我想连接动态数组的所有元素,并将整个数组左移 8 位。我尝试了下面的代码,它有效。有没有更好的方法来移动整个数组而不用流操作符打包然后移动?

module tb();
    bit [31:0] payload[3];
    bit [32*payload.size()-1:0] stream;
    bit [(32*payload.size()+8)-1:0] shifted_stream;  

    initial begin
        payload[0]='habcdabcd;
        payload[1]='hefefefef;
        payload[2]='h12345678;
        stream={<<32{payload}};
        $display("stream=0x%h", stream);
        shifted_stream = {stream, 8'h0};
        $display("shifted stream=0x%h", shifted_stream);    
     end
endmodule
concatenation verilog system-verilog
1个回答
0
投票

你可以做

stream = {<<512{payload}};

foreach(payload[i])
  stream[i*512+:512] = payload[i];
© www.soinside.com 2019 - 2024. All rights reserved.