please understand 1 issue facing when trying customize “select_sequence” of sequence_library. need customize “select_sequence” , make sequences run in exact order, written in external file. reason stepping on container of registered sequence types: sequences[$]. , doing dynamic casting. if casting matches needed sequence return number select_sequence function i.e. making library run sequence.
this part code:
class cfgseqnclib extends uvm_sequence_library #(seqitem_cfg); `uvm_object_utils(cfgseqnclib) `uvm_sequence_library_utils(cfgseqnclib) rstseqnc resetsequence; function int unsigned select_sequence(int unsigned max); static int unsigned counter; select_sequence = counter; counter++; if (counter > max) counter = 0; foreach (sequences[i]) begin if ($cast(resetsequence, sequences[i]) ) $display("%t: <><><>><>< resetseq: casting successfull", $time); else $display("%t: >>>>>>>>resetseq: casting not successfull", $time); end // foreach endfunction endclass
and have added reset sequence in library using : `uvm_add_to_seq_lib(rstseqnc, cfgseqnclib) command.
the thing $case never return 1 i.e. during simulation print \ >>>>>>>>resetseq: casting not successfull
even though can see reset sequence being run sequence_lib, never casting returns true. can please explain why?
if using uvm code, change select_sequence
function following, casting works:
function int unsigned select_sequence(int unsigned max); static int unsigned counter; uvm_object_wrapper wrap; uvm_object obj; select_sequence = counter; counter++; if (counter > max) counter = 0; foreach (sequences[i]) begin wrap = sequences[i]; obj = factory.create_object_by_type(wrap,get_full_name(), $sformatf("%s:%0d",wrap.get_type_name(),sequences_executed+1)); if ($cast(resetsequence, obj) ) $display("%t: !!!!!!! resetseq: casting successfull", $time); else $display("%t: >>>>>>>>resetseq: casting not successfull", $time); end // foreach endfunction
during simulaiton getting:
!!!!!!! resetseq: casting successfull
i cannot understand why casting in the first version of select_sequence not work in second case works. can explain me please.
using macro uvm_add_to_seq_lib
add sequence library [`uvm_add_to_seq_lib(rstseqnc, cfgseqnclib) ] gives feeling adding instance of sequence array present in sequence library , instance can used later in sequence library.
but not case , commonly used style within uvm, macro adding object of type uvm_object_registry
. object created (statically) once per class within uvm_object_utils
macros [ uvm_object_registry#(t,"s
") type_id; ].
this mechanism used within factory classes/mechanism create , use lightweight wrapper(uvm_object_registry) of object. ensures uvm framework not creating complete class till needed. instance of class created @ time of calling type_id::create function ( or other factory create functions).
so $cast(resetsequence, sequences[i])
in case 1 trying cast object_wrapper type resetsequence [uvm_object_registry#(resetsequence,"resetsequence") ] resetsequence fails .
resetsequence != uvm_object_registry#(resetsequence,"resetsequence")
examining macro can see not adding instance of type ( sequence) instead calling get_type function returns object wrapper.
`define uvm_add_to_seq_lib(type,libtype) \ static bit add_``type``_to_seq_lib_``libtype =\ libtype::m_add_typewide_sequence(type::get_type());
also examining code ( case 2 ) below can see using factory mechanism create instance of class. ensures type override in environment work , sequence library use new sequence on registered 1 in sequence library. in example 1 such case not possible attempting directly use instance of class [ if code fixed ] . case 2 has advantages.
wrap = sequences[i]; obj = factory.create_object_by_type(wrap,get_full_name(), $sformatf("%s:%0d",wrap.get_type_name(),sequences_executed+1)); if ($cast(resetsequence, obj) )
Comments
Post a Comment