You are on page 1of 7
Verification Guide UVM Sequence How to write uvm sequence Table of Contents = {How to wite wm sequence 1. .saquence base ca {Lt roquesteg 112 rosponsars: 4.2. Sequence Execution 4.21 ,body Mato 1.23. Staring The Sequence: 4.3, Whiing UVM Sequence 114. U Sequence macios {U1 Whtng re sequence using Macr's ‘5.5 do $A. um ert and “wm, end $A3 wry va son Ss wo ow $45 uae send win SA Calin eorcns nae he sequence 15. aiference betwoon m sequencer and p sequencer 1.5.1. soquonces, 1152.5 sequoneer, ‘A sequence generates a series of sequence_item’s and sends it to the driver via sequencer, Sequence is written by extending the luvm_soquence. + Auuvm_sequence Is derived from an uvm_sequenece, em + a sequence is parameterized with the type of sequence. tem, ths defines the type of the item sequence that wil sendireceve ttm river sequence base class ‘virtual class uym_sequence (type REQ = uve_sequence_iten, ‘type RSP = REQ ) extends uvm_sequence_base exampl class write sequence extends uve_secuence #(nen_seq_ites); endelass the sequence has handle req and rsp of mem_seq. em. ® requestireq: [A transaction that provides information to inate the processing ofa partcular operation. {A transaction that provides information about the completion or status ofa particular operation, Sequence Execution ‘Most important properties of a sequence are, + body method + m_sequencer handle body Method: body method defines, what the sequence does. m_sequencer Handle: “The m_sequoncer handle contains the reference to the sequencer an which the sequence is running ‘The sequence will get executed upon calling the start ofthe sequence from the test. sequence_nase.start(sequencer_naee); “sequencer_name species on which sequencer sequence has fo run. ‘+ There are Methods, macros anc pre-defined callbacks associated with uvm_sequence, + Users can define the methods(task or function) to pre-defined calloacks. these methods will get executed automatically upon caling tk star ofthe sequence. + These methods should not be called direc by the user. Below block diagram shaws the order in which the mathods will get called on calling the start of a sequence. * mid_do and post_do are functions, All other aro tasks starting The Sequence: ® Logic to generate and send the sequence_tem wil be written inside the body() method ofthe sequence, ‘The handshake between the sequence, sequencer and driver to sen the sequence_ emis given below. Sequence eee) oo oe | oe re) A iY iY Hy a emo 1 et next tem’) rman ‘ | ‘Communication between the Sequence and driver involves below slaps, + reat tom) / create re. 2wait_forgrant). S,randomize the req “4 send the roa ‘5. wait for tem done. 6.get response, * Step 5 and 6 are optional create_tem() pir ee) corer) send_request() — = Peer eeened eer) Pome ent Method Call create_item() req ="*_seq_lom:type_idereate(req"); wait for_grant() req.randomize() send_requestreq.e-randomize) Description Create and intalize sequence. tem or sequence “initialize inialized to communicate wih te specified sequence This method calls blocking, Execution willbe blocked untl the method returns. 4.This method issues a request tothe curent sequencer 2.The sequencer grants on geting get_next_tem() request from fiver Tismadotstorentnie he seaner ten (A) ‘Send the request item tothe sequencer, which wil forward itt th re-andomize revandomize wait for_tom_done() get_current item) get_response(esp) Writing UVM Sequence class nen_sequence extends uvn_sequencet(nem_seq_iten); vm_object_utils(mes, quence) LIConstructor Function new(string name Super new(nane); cenafunetion inen_sequence”); virtual task body(); req =men_se wait_for_grant(); assert(req.randomize()); send_request (req); wait_for_iter_done(); set Fespanse(sp); enctask endelass Note: assert (req.randomize());, will return the assertion error on randomiz. UVM Sequence macros iver he rerandomize the bits sat, the item wil be randomized befe being sent tothe driver. This call is optional This task wil lock unl the driver calls item_done or put Retums the request item currently bsing executed by the sequencer. I the sequencer isnot curently executing an item, this method w receives the response from driver teem: type_Ad::create("reg"); //ereate the req (seq iten) Tiwait for grant Jirandoaize the req Hisend req to driver Iivait for iten done fron driver Higet response Fron driver on failure. ‘These macros are used to stat sequences and sequence items on default sequencer, m_sequencer. “wm_dojitem/Seq) wm _sreate(ttem/Seq) ne{terSeq) “uwm_cand_sond{ttomSeq) “wm_do_withitem'Seq,Constaints) wm _rand_senc_with(tem/Seq,Constrants) wvm_do_pritenSeq,Prosty ) “wm _do_pr_wit(lten/Seq, Constraints Priory) wm _send_pritemSeq Prost) wm _rand_send_pri(tem’Seq,Prory) “wwm_rand_sond_prl_with(tem/Seq.Priotty, Constraints) Description This macro takes seq_tem or sequence as argument On cating “wm _do() the above-defined 6 steps will be executed. ‘This macro creates the item or sequence. create() and randomize are skipped, rest al other steps are executed Only create) is skipped, rest all other steps are executed This macro performs above 6 steps along with constraints define in second argument. create) is sk’pped, rest all other steps are executed along with constraints defined in second argument. Performs ‘uvm_do() with priority mentioned, Pecoems ‘uvm_da() along with constrains defined and priory mmentionea, creste() and randomize) are skipped, rest al other steps are executed with proty mentioned. Only create Is skipped, ost all other stops are executed with ® creata() Is skpped, as al other steps are exocuted aor with prlorty mentioned, “wm decare_f Writing the sequence using Macro’s “uvM_000) class nen_sequence extends uvm_sequence®(nen_seq_iten) ~uvm_object_utils(mea_sequence) {constructor Function new(string nane ~ “nen_sequence”); super.new(nane); lenafunction virtual task body(); ‘wvm_do(rea) enatask endclass “UVM_CREATE() AND “UVM_SEND() class non_sequence extends uvm_sequence®(nem_seq_iten); ~uvn_object_utils(mea_sequence) {constructor function new(string name = "nen_sequence’ super.new(nane); cenafunction virtual task body): ‘uvm_create(req) assert(req.randomize()); ‘uym_send(reg); enctask endelass “UVM_RAND_SEND() class men_sequence extends uvm_sequencet (en_seq_iten); tvm_object_uti1s(mes_sequence) {Constructor Function new(string name Super. new(nane); cenafunction “nen sequence”); virtual task body(); uvm_creste(req) tuvnrand_send(req) enctask endelass “UVM_DO_WITHO) class write sequence extends uve_sequencel(men_seq_item); vm_object_utils(wefte_sequence) constrains defined with priority mentioned, ‘This macro is used to declare a variable p_sequencer whose type Is spectied by SEQUENCER. by using p_sequencer handle, properties of sequencer can be accessed, {Constructor Function neu(string nane = “write_sequence"); super.new(nane); cenafunction virtual task body()s ‘wvn_do_with(reg, (req.wr_en == 13}) enatask endclass *UVM_RAND_SEND_WITH() class read_secuence extends uvm_sequencer(en_seq_sten); ~uvm_object_utsls(read_ sequence) fconstevctor function new(string nane = “reas_sequence"); super new(nate); endfunction virtual task body); wom_cneaterea) womrand_send-xith(re, (req.r@_en == 13)) endtask endclass CALLING SEQUENCE’S INSIDE THE SEQUENCE lass wr_rd_seq extends uva_sequences(nen_seq_iten); weite_sequence wr_seqs ead Sequence rd_seqi uvn_object_utils(we_ed_seq) JIConstructor unetion new(string name = “wr_rd_seq"); super.new(nane); cenafunction virtual task body(); ‘wun_é0(we_seq) > uvm_do(rd_seq) enatask endclass difference between m_sequencer and p_sequencer: m_sequencer, “The m_sequencer hanale contains the reference tothe sequencer(detault sequencer) on which the sequence is running This is determined by, + the sequencer handle provided in the start method + the sequencer used by the parent sequence + the sequencer that was set using the set_sequencer method p_sequencer, ‘The p_sequencer isa varlable, used as a handle to access the sequencer properties. sequencer is defined using the macro "uvm_declare_p_sequencer(SEQUENCER_NAME)

You might also like