In sequence:
start_item(tr);
Randomization
finish_item(tr);
get_response(tr);
In Driver:
seq_item_port.get(tr);
@(vif.cb) vif.in <= tr.in;
tr.set_id_info(tr);
seq_item_port.put(tr);
class base_tr extends uvm_sequence_item;
`uvm_object_utils(base_tr)
rand int in;
function new(string name = "base_tr");
super.new(name);
endfunction
constraint c1 {
in dist {1:=90, 5:=30};
}
virtual function string convert2string();
return $sformatf("in = %0d", in);
endfunction
endclass
class base_seq extends uvm_sequence;
`uvm_object_utils(base_seq)
base_tr tr,tr_r;
function new(string name = "base_seq");
super.new(name);
endfunction
virtual task body();
tr = base_tr::type_id::create("tr");
for (int i=0; i<100; i++) begin
start_item(tr);
if(!tr.randomize()) begin
`uvm_error(get_type_name(), $sformatf("could not randomize"))
end
finish_item(tr);
get_response(tr);
`uvm_info(get_type_name(), $sformatf(" after finish_item in = %d",tr.in), UVM_LOW);
end
endtask
endclass
class base_drv extends uvm_driver#(base_tr);
`uvm_component_utils(base_drv)
virtual if_name vif;
base_tr tr,tr_r;
function new(string name = "base_drv", uvm_component parent = null);
super.new(name,parent);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
uvm_config_db#(virtual if_name)::get(this,"", "if", vif);
endfunction
virtual task run_phase (uvm_phase phase);
super.run_phase(phase);
tr = base_tr::type_id::create("tr");
forever begin
seq_item_port.get(tr);
@(vif.cb) vif.in <= tr.in;
tr.set_id_info(tr);
seq_item_port.put(tr);
end
endtask
endclass
Link to entire code : debug response: don't edit. VerificationAcademy - EDA Playground
Error-[ICTTFC] Incompatible complex type usage
testbench.sv, 46
Incompatible complex type usage in task or function call.
The following expression is incompatible with the formal parameter of the
task. The type of the actual is ‘class $unit::base_tr’, while the type of
the formal is ‘class uvm_pkg::uvm_sequence_item’. Expression: this.tr
Source info:
uvm_pkg::\uvm_sequence#(uvm_pkg::uvm_sequence_item,uvm_pkg::uvm_sequence_item)::get_response
(this, this.tr, /* transaction_id = (-1) */);