meenu Posted May 23, 2012 Report Posted May 23, 2012 pack function in UVM I have a class class A extends uvm_sequence_item; ... rand bit[3:0]a; rand bit[121:0]b; rand bit[162:122]c; rand bit[511:163]d; ... endclass I have another class class B extends uvm_sequence_item; .... rand bit[511:0]field; ... endclass I would like to assign to field the packed version of all the fields of class A. ie. B b1; A a1; b1 = pack(all fields of a1); How can i use the uvm pack function for this?? Need immediate help Quote
uwes Posted May 24, 2012 Report Posted May 24, 2012 hi, why not module test187; import uvm_pkg::*; `include "uvm_macros.svh" class ac extends uvm_object; rand bit[3:0]a; rand bit[121:0]b; rand bit[162:122]c; rand bit[511:163]d; `uvm_object_utils_begin(ac) `uvm_field_int(a,UVM_DEFAULT) `uvm_field_int(b,UVM_DEFAULT) `uvm_field_int(c,UVM_DEFAULT) `uvm_field_int(d,UVM_DEFAULT) `uvm_object_utils_end function new (string name=""); super.new(name); endfunction endclass class bc extends uvm_object; rand bit[511:0]field; `uvm_object_utils(bc) function new (string name=""); super.new(name); endfunction endclass initial begin ac ma = new; bc mb = new; bit d[]; ma.pack(d); $display({>>{d}}); end endmodule Quote
meenu Posted May 24, 2012 Author Report Posted May 24, 2012 hi, why not module test187; import uvm_pkg::*; `include "uvm_macros.svh" class ac extends uvm_object; rand bit[3:0]a; rand bit[121:0]b; rand bit[162:122]c; rand bit[511:163]d; `uvm_object_utils_begin(ac) `uvm_field_int(a,UVM_DEFAULT) `uvm_field_int(b,UVM_DEFAULT) `uvm_field_int(c,UVM_DEFAULT) `uvm_field_int(d,UVM_DEFAULT) `uvm_object_utils_end function new (string name=""); super.new(name); endfunction endclass class bc extends uvm_object; rand bit[511:0]field; `uvm_object_utils(bc) function new (string name=""); super.new(name); endfunction endclass initial begin ac ma = new; bc mb = new; bit d[]; ma.pack(d); $display({>>{d}}); end endmodule Hi uwes This packs into bits. If i would like to pack them into bytes, what should i use ? Quote
meenu Posted June 21, 2012 Author Report Posted June 21, 2012 (edited) use pack_bytes instead of pack it works pretty well, but now i face a different situation . what if module test187; import uvm_pkg::*; `include "uvm_macros.svh" class ac extends uvm_object; rand bit[31:0]a; rand bit[121:32]b; rand bit[162:122]c; rand bit[511:163]d; `uvm_object_utils_begin(ac) `uvm_field_int(a,UVM_DEFAULT) `uvm_field_int(b,UVM_DEFAULT) `uvm_field_int(c,UVM_DEFAULT) `uvm_field_int(d,UVM_DEFAULT) `uvm_object_utils_end function new (string name=""); super.new(name); endfunction endclass class bc extends uvm_object; rand bit[511:0]field; `uvm_object_utils(bc) function new (string name=""); super.new(name); endfunction endclass initial begin ac ma = new; bc mb = new; bit d[]; ma.pack(d); $display({>>{d}}); end endmodule Am assigning variable a of class ac with the value {16'h00,8'h5,8'h5} via a task. When i pack, the value am expecting is byte 0 = 0 byte 1 = 5 byte 2 = 0 byte 3 = 5 byte 4 = 0 byte 5 = 0 byte 6 =0 byte 7= 0 all bytes are packed properly, except for the first eight bytes which are packed in reverse order : byte 0 = 0 byte 1 = 0 byte 2 = 0 byte 3 = 0 byte 4 = 0 byte 5 = 5 byte 6 =0 byte 7=5 byte 8=.. . . . byte 63=.. why does this happen? Edited June 21, 2012 by meenu Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.