1)256 bit 数据 转8 bit 队列
实现方法如下:
module test_mem;
bit[255:0] rf_op_data[$], rdata;
bit [7:0] data_byte[$];
initial begin
rf_op_rdata.push_back('h671d3486671d348f671d348f671d3487c0589332c0589334c0589330671d3483);
rf_op_rdata.push_back('h671d3482671d3486671d348f671d3487c0589332c058932ec0589334c0589330);
rdata= rf_op_data[1];
$display("rdata = %h", rdata);
data_byte={>>8{rdata}};
foreach(data_byte[i]) $display("data_byte[%2h] is = %h, i, data_byte[i]");
#80;
$stop;
end
endmodule
执行cmd: vcs -R -full64 -sverilog +v2k -ntb test_mem.sv
打印显示:
rdata = 671d3482671d3486671d348f671d3487c0589332c058932ec0589334c0589330
data_byte[00]=67
data_byte[01]=1d
data_byte[02]=34
data_byte[03]=82
data_byte[04]=67
data_byte[05]=1d
data_byte[06]=34
data_byte[07]=86
data_byte[08]=67
data_byte[09]=1d
data_byte[0a]=34
data_byte[0b]=8f
data_byte[0c]=67
data_byte[0d]=1d
data_byte[0e]=34
data_byte[0f]=87
data_byte[10]=c0
data_byte[11]=58
data_byte[12]=93
data_byte[13]=32
data_byte[14]=c0
data_byte[15]=58
data_byte[16]=93
data_byte[17]=2e
data_byte[18]=c0
data_byte[19]=58
data_byte[1a]=93
data_byte[1b]=34
data_byte[1c]=c0
data_byte[1d]=58
data_byte[1e]=93
data_byte[1f]=30
2)256 bit 队列 转8 bit 队列
实现方法如下:
module test_mem;
bit[255:0] rf_op_data[$];
bit [7:0] data_byte[$];
initial begin
//rf_op_rdata.push_back('h671d3486671d348f671d348f671d3487c0589332c0589334c05893301d3483);
rf_op_rdata.push_back('h671d3482671d3486671d348f671d3487c0589332c058932ec0589334c0589330);
rf_op_rdata.push_back('hc524289cc52422d1808422008084252f80842a5dc5241eba808420a4c52425a0);
foreach(rf_op_data[i]) $display("rf_op_data[%h] is = %h, i, rf_op_data[i]");
data_byte={>>8{rf_op_data}};
foreach(data_byte[i]) $display("data_byte[%2h] is = %h, i, data_byte[i]");
#80;
$stop;
end
endmodule
执行cmd: vcs -R -full64 -sverilog +v2k -ntb test_mem.sv
打印显示:
rf_op_data[00000000]=671d3482671d3486671d348f671d3487c0589332c058932ec0589334c0589330
rf_op_data[00000001]=c524289cc52422d1808422008084252f80842a5dc5241eba808420a4c52425a0
data_byte[00]=67
data_byte[01]=1d
data_byte[02]=34
data_byte[03]=82
data_byte[04]=67
data_byte[05]=1d
data_byte[06]=34
data_byte[07]=86
data_byte[08]=67
data_byte[09]=1d
data_byte[0a]=34
data_byte[0b]=8f
data_byte[0c]=67
data_byte[0d]=1d
data_byte[0e]=34
data_byte[0f]=87
data_byte[10]=c0
data_byte[11]=58
data_byte[12]=93
data_byte[13]=32
data_byte[14]=c0
data_byte[15]=58
data_byte[16]=93
data_byte[17]=2e
data_byte[18]=c0
data_byte[19]=58
data_byte[1a]=93
data_byte[1b]=34
data_byte[1c]=c0
data_byte[1d]=58
data_byte[1e]=93
data_byte[1f]=30
data_byte[20]=c5
data_byte[21]=24
data_byte[22]=28
data_byte[23]=9c
data_byte[24]=c5
data_byte[25]=24
data_byte[26]=22
data_byte[27]=d1
data_byte[28]=80
data_byte[29]=84
data_byte[2a]=22
data_byte[2b]=00
data_byte[2c]=80
data_byte[2d]=84
data_byte[2e]=25
data_byte[2f]=2f
data_byte[30]=80
data_byte[31]=84
data_byte[32]=2a
data_byte[33]=5d
data_byte[34]=c5
data_byte[35]=24
data_byte[36]=1e
data_byte[37]=ba
data_byte[38]=80
data_byte[39]=84
data_byte[3a]=20
data_byte[3b]=a4
data_byte[3c]=c5
data_byte[3d]=24
data_byte[3e]=25
data_byte[3f]=a0