Hi,
I am learning sequences and tried to code an example where a top sequence(my_sequence) calls another sequence(child_sequence). This top sequence is started on a sequencer from test(my_test)This worked fine.
class my_test extends uvm_test;
`uvm_component_utils(my_test);
my_env my_env_h;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction : new
function void build_phase (uvm_phase phase);
my_env_h = my_env::type_id::create("my_env_h", this);
endfunction : build_phase
task run_phase(uvm_phase phase);
my_sequence seq;
seq = my_sequence::type_id::create("seq");
seq.start(my_env_h.my_agent_h.my_sequencer_h);
endtask
endclass : my_test
class my_sequence extends uvm_sequence #(my_transaction);
`uvm_object_utils(my_sequence)
// `uvm_declare_p_sequencer(my_sequencer)
function new(string name = "");
super.new(name);
endfunction
task body;
child_sequence cseq;
cseq = child_sequence::type_id::create("cseq");
if(! cseq.randomize())
`uvm_error("", "Randomization of child sequence failed")
cseq.start(m_sequencer, this);
endtask
endclass : my_sequence
class child_sequence extends uvm_sequence #(my_transaction);
`uvm_object_utils(child_sequence)
rand int start_addr;
constraint caddr { start_addr>=0 ; start_addr < 100;}
function new(string name = "");
super.new(name);
endfunction
task body;
if(starting_phase != null)
starting_phase.raise_objection(this);
for(int i=0; i<=4; i++)
begin
req = my_transaction::type_id::create("req");
start_item(req);
if(!req.randomize() with { addr == start_addr+i; } )
`uvm_error("", "randomization failed");
finish_item(req);
end
if(starting_phase != null)
starting_phase.drop_objection(this);
endtask
endclass : child_sequence
class my_transaction extends uvm_sequence_item;
`uvm_object_utils(my_transaction)
rand bit reset;
rand bit cmd;
rand bit [7:0] addr;
rand bit [7:0] data;
// constraint c_reset {reset = 0; reset=1;}
constraint c_addr {addr >= 0; addr < 256;}
constraint c_data {data >= 0; data < 256;}
function new(string name = "");
super.new(name);
endfunction : new
function string convert2string;
return $sformatf("In transaction class: cmd = %b; addr = %0d data = %0d", cmd, addr, data);
endfunction
endclass : my_transaction
At next level, in the same environment I created another test(my_test2) which extends from my_test and I tried to override the child sequence with another sequence(overriding_seq) using set_type_override, but I get the following fatal error:
UVM_FATAL @ 0: uvm_test_top.my_env_h.my_agent_h.my_sequencer_h@@seq.cseq [SEQNOTITM] attempting to start a sequence using start_item() from sequence ‘uvm_test_top.my_env_h.my_agent_h.my_sequencer_h.seq.cseq’. Use seq.start() instead.
class my_test2 extends my_test;
`uvm_component_utils(my_test2)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
//function void build_phase(uvm_phase phase);
// super.build_phase(phase);
//endfunction
function void start_of_simulation_phase(uvm_phase phase);
super.start_of_simulation_phase(phase);
child_sequence::type_id::set_type_override(overriding_sequence::get_type());
endfunction
endclass : my_test2
class overriding_sequence extends child_sequence #(my_transaction);
`uvm_object_utils(overriding_sequence)
function new(string name = "");
super.new(name);
endfunction
task body;
if(starting_phase != null)
starting_phase.raise_objection(this);
for(int i = 0; i<2 ; i++)
begin
req = my_transaction::type_id::create("req");
start_item(this);
if(!req.randomize())
`uvm_error("","Randomization of overriding seq failed")
finish_item(this);
end
if(starting_phase != null)
starting_phase.drop_objection(this);
endtask
endclass
My environment has one Agent, This Agent has a sequencer, driver and monitor
Can you please help!!