HI,
I have a question embedded in the comment section below in the code. Any help in on how to split a packed array into 2 packed arrays would be appreciated.
class my_descriptor extends uvm_object;
rand bit [511:0] my_descr;
`uvm_object_utils_begin(my_descriptor)
`uvm_field_int(my_descr, UVM_DEFAULT | UVM_PHYSICAL)
`uvm_object_utils_end
endclass
class my_new_sequence extends proj_base_sequence;
byte unsigned desc_bytes[];
my_descriptor cmd_desc;
function new (string name = "my_new_sequence");
super.new(name);
endfunction : new
virtual task body();
packer = new;
packer.big_endian = 0;
void'(cmd_desc.pack_bytes(desc_bytes, packer));
//desc_bytes is now a packed array of 512 bits
//How do I split 'desc_bytes' so that I will have
//2 packed arrays of 256bits each(desc_bytes_lo and desc_bytes_hi)?
endtask
endclass
In reply to Val.engg:
Use a bit-stream cast:
bit [255:0] desc_bytes_lo, desc_bytes_hi;
{desc_bytes_hi, desc_bytes_lo} = 512'(desc_bytes);
In reply to dave_59:
Thanks Dave.
One small issue in using the aboove mentioned solution (I should have mentioned earlier in my problem statement,my bad). I need to desc_bytes_lo, desc_bytes_hi to be of integral datatype.
Your inputs are highly appreciated. Thank you!
In reply to Val.engg:
Rather than letting me guess, can you show the declarations of desc_bytes_lo, desc_bytes_hi and how you want the bytes ordered.
In reply to dave_59:
I need to pass desc_bytes_lo, desc_bytes_hi to the following task
mem_wr(addr1, desc_bytes_lo);
mem_wr(addr2, desc_bytes_hi);
task mem_wr(input bit [39:0] ADDR,ref bit [7:0] WR_DATA[])
endtask
I need the bytes ordered so that I can use mem_wr task and write desc_bytes_lo and desc_bytes_hi into memory.
Pls let me know if I am not clear.
Again, thanks much for the help!
In reply to Val.engg:
OK, you really want me to guess. I’m going to assume the declarations are
bit [7:0] desc_bytes_lo[], desc_bytes_hi[];
desc_bytes_lo = desc_bytes[0:255];
desc_bytes_hi = desc_bytes[256:511];
These are all dynamic unpacked arrays
In reply to dave_59:
Dave,
Sorry, did not quite understand your question the first time.
Here is what I want:
byte unsigned desc_bytes_lo;
byte unsigned desc_bytes_hi;
I am not sure if your earlier suggestion will work…I can try.
bit [7:0] desc_bytes_lo, desc_bytes_hi;
Would appreciate your inputs (now that I have answered your question).