I have a member tx_cnt in the virtual sequence which spawns of other child sequences. I want the child sequence have access this member which is updated dynamically through out the sim. Any ideas how to do this?
I tried to pass do the following
child_seq.start(seqr,this/parent sequence/)
in body of child seq i had child_seq_iem.cnt = m_parent_sequence.tx_cnt;
pass the parent_sequence through start and then access using m_parent_sequence.tx_cnt but i get error that tx_cnt variable is not found .
yes option one will work theoretically if i cast but will not work in my case because in order of compilation the child seq is compiled before the virtual seq(parent seq)
In reply to CRVAddict: #1) $cast is dynamic casting, it will check the compatible in run time, not compilation time. Then, I don’t think it will be an issue because of compilation order. Can you try again?
#2) The answer is “no”. Either you set again when the tx_cnt value is changed in parent, or you can create wrapper object configuration, set the handler of this object to database, then get it in children sequences:
class seq_cfg extends uvm_object;
int tx_cnt;
// ...
endclass
class parent_seq extends uvm_sequence;
seq_cfg cfg;
// ...
task pre_body();
uvm_config_db#(seq_cfg)::set(seqr, "*", "cfg", cfg);
endtask
endclass
class child_seq extends uvm_sequence;
seq_cfg cfg;
// ...
task pre_body();
uvm_config_db#(seq_cfg)::get(m_sequencer, "", "cfg", cfg);
endtask
With it, everytime the value tx_cnt is changed, the child seq is able to get the updated value.
In reply to cuonghle: hi
As for #1 option(dynamic casting) i have attached a sample which i tried.
You need a type of parent to $cast isnt it, so for it to work with the forward referencing using typedef this will not work because of order of compilation or am i missing something.
typedef class v_seq;
class seq extends uvm_sequence #(seq_item);
`uvm_object_utils(seq)
seq_item req;
v_seq p;
function new(string name = "seq");
super.new(name);
// do_not_randomize = 1'b1; // Required for ModelSim
endfunction
task body();
m_parent_sequence.print();
$cast(p,m_parent_sequence);
$display("tx_cnt %d",p.tx_cnt);
I mean to say , it cant work without forward referencing using typedef and typedef works only if the sequences are in same files. In a normal UVM TB we dont have the seq and virtual seq in same file isnt it