here is a part of my code ,da is the integer variable in the class sequence_item which not shown
class packer_sequence extends uvm_sequence #(packet);
packet packet_item;
task body
packet_item = packet::type_id::create("packet");
start_item(packet_item);
packet_item.randomize();
finish_item(packet_item);
endtask
endclass
class test_da_is_10 extends test_base
virtual function void build_phase(uvm_phase phase )
super.build_phase(phase);
set_inst_override_by_type("env.sgt.sqr.packer_sequence.packet_item",packet::get_type(),packet_da_10::get_type());
endclass
the problem is that the value of da is not 10 even if i useset_inst_override_by_type(“env.sgt.sqr.packer_sequence.req”,packet::get_type(),packet_da_10::get_type());
if i change the code to this
class packer_sequence extends uvm_sequence #(packet);
task body
`uvm_do(req);
endtask
endclass
class test_da_is_10 extends test_base
virtual function void build_phase(uvm_phase phase )
super.build_phase(phase);
set_inst_override_by_type("env.sgt.sqr.packer_sequence.req",packet::get_type(),packet_da_10::get_type());
endclass
the problem was fixed, the value of da is 10 now. why the problem fixed? how can the value of da be changed to 10 without using uvm_do?
Two issues with your code. There is no need to create a separate packet_item variable; there is already a req variable. You named your sequence_item “packet”, but you overrode “packet_item”.
Change your code to
class packer_sequence extends uvm_sequence #(packet);
task body
req = packet::type_id::create("req");
start_item(req);
req.randomize();
finish_item(req);
endtask
endclass
class test_da_is_10 extends test_base
virtual function void build_phase(uvm_phase phase )
super.build_phase(phase);
set_inst_override_by_type("env.sgt.sqr.packer_sequence.req",packet::get_type(),packet_da_10::get_type());
endclass
thanks for reply, i changed the code as you posted , but the value of da is still not 10.
i know there is no need to create new var, but i am confused about that
req holds the transaction object, if i declare a new var called packet_item, and i wrote this code
packet_item = packet::type_id::create("packet").
packet_item should hold the object too.
what is the issues with below code? Please correct me if my concept is wrong.
set_inst_override_by_type is defined for uvm_components and factory. You are handling your object liek a component. But you can perform the command also on the factory like this:
It’s more than just a “guideline”. The UVM only knows about the string names you give objects. It knows nothing of the variable identifier names. As I stated in my first reply, you named your sequence_item “packet”, but you overrode “packet_item”.
, the value of da is not 10
.I am still finding the reason.
could you tell me how to print warning message if set_inst_override_by_type not work sucessfully?
i think there is a problem about the path (env.sgt.sqr.packer_sequence.packet_item), so set_inst_override_by_type not work