Kinjal Posted August 8, 2011 Report Posted August 8, 2011 Is UVM clone/copy works for dynamic objects too? I am trying with below code and it looks something wrong. Can someone help? ---------------------------------------------------------------------------------------------------- class abc extends uvm_sequence_item; rand byte data[]; constraint size_data { data.size() <= 1000; }; `uvm_object_utils_begin(abc) `uvm_field_array_int(data, UVM_ALL_ON) `uvm_object_utils_end endclass class xbus_transfer extends uvm_sequence_item; abc abc_inst[]; function void pre_randomize(); ......... abc_inst = new[5]; endfunction `uvm_object_utils_begin(xbus_transfer) .................... `uvm_field_array_object(abc_inst, UVM_ALL_ON) `uvm_object_utils_end ...... ...... ----------------------------------------------------------------------------------------- Quote
jadec Posted August 9, 2011 Report Posted August 9, 2011 UVM_DEFAULT (as opposed to UVM_ALL_ON) sets UVM_DEEP which will cause the sub-object to the cloned as well. You can also explicitly set: UVM_ALL_ON | UVM_DEEP, UVM_ALL_ON | UVM_SHALLOW, or UVM_ALL_ON | UVM_REFERENCE when specifying object fields. UVM_SHALLOW may not be completely implemented. Quote
Kinjal Posted August 10, 2011 Author Report Posted August 10, 2011 I tried with UVM_DEEP / UVM_SHALLOW. It doesn't work. I can't use UVM_REFERENCE as I am modifying and thats why I am using copy(). Can you show some good example for UVM_DEEP targeting this case? It will be really good. Quote
jadec Posted August 11, 2011 Report Posted August 11, 2011 Here's what I did: class my_sub extends uvm_object; int val; `uvm_object_utils_begin(my_sub) `uvm_field_int(val,UVM_DEFAULT) `uvm_object_utils_end endclass class my_obj extends uvm_object; my_sub sub; `uvm_object_utils_begin(my_obj) `uvm_field_object(sub,UVM_DEFAULT) `uvm_object_utils_end endclass class my_vseq extends uvm_sequence#(); `uvm_object_utils(my_vseq) task body(); `uvm_info( get_type_name(), "sequence", UVM_MEDIUM ) begin my_obj obj = my_obj::type_id::create("obj",,get_full_name()); my_obj obj2; obj.sub = my_sub::type_id::create("sub",,obj.get_full_name()); obj.sub.val = 3; `uvm_info( get_type_name(), $sformatf("obj val=%0d\n%0s", obj.sub.val, obj.sprint() ), UVM_LOW ) $cast(obj2, obj.clone()); `uvm_info( get_type_name(), $sformatf("obj2 val=%0d\n%0s", obj2.sub.val, obj2.sprint() ), UVM_LOW ) end endtask endclass I get: UVM_INFO my_pkg.sv(28) @ 0: reporter [my_vseq] sequence UVM_INFO my_pkg.sv(34) @ 0: reporter [my_vseq] obj val=3 ---------------------------------------------------------------------- Name Type Size Value ---------------------------------------------------------------------- obj my_obj - @2018 sub my_sub - @2011 val integral 32 'h3 ---------------------------------------------------------------------- UVM_INFO my_pkg.sv(37) @ 0: reporter [my_vseq] obj2 val=3 ---------------------------------------------------------------------- Name Type Size Value ---------------------------------------------------------------------- obj my_obj - @2017 sub my_sub - @1990 val integral 32 'h3 ---------------------------------------------------------------------- You can see that clone() creates a new sub object. 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.