Jump to content

How do you create sequences in UVM like that in VMM?

Recommended Posts

In vmm scenario class, i can write constraints on individual item as well as an items queue, equivalent to which i don't find in VMM

for eg, my 8th item could be predicted looking at the second one or vice versa, how can such a thing be achieved in uvm.

I am looking for a equivalent of the following in uvm :-

Edited by worma
Link to comment
Share on other sites

In UVM it should be slightly easier than that - provided you are familiar with the Sequences part of UVM. I say easier b'cos it is more of "procedural" than declarative as in VMM style - both have their pros-and-cons. Syntax will be quite close as you have conditional constraints in VMM style, that can be mapped easily to uvm_sequence::body() task. Make sure you have enough functional coverage to see the distributions in either case.

If you send/show a full code for a VMM-scenario style, I can perhaps show an equiv. in UVM (than me having to create everything from scratch for you).




Link to comment
Share on other sites

hi worma,

in UVM can have two styles to describe scenarios. the first style (a declarative style) would be similar to what you have shown in your code section. actually it is a set of constraints on an array of transactions. this set of transaction is usually randomized once and then send item-by-item. the second style in uvm is a sequence style which allows you step-wise generation. to illustrate that have a look at the pseudo-code examples below

declarative style:

class uvm1_seq extends uvm_sequence;
// rest of uvm required decls

rand transactions t[5];

constraint legal {
  // your constraints on transaction here

virtual task body();
      // now send the transaction or generate sequence items using the transactions
      // for instance `uvm_do_with(op,{type==transaction[idx].type}

or with the second style:

class uvmm2_seq extends uvm_sequence;
// rest of required decls
  rand int unsigned scenario_length;
  rand int addr;
  rand int length
virtual task body();
 repeat (scenario_length) 
`uvm_do_with(op,{type inside {my_transaction::MEM_WR_32,my_transaction::MEM_WR_64}; length==uvmm2_seq::length;...})

 // now you can look at op to see what has been sent ( or you can peek into the "transaction store" of the last send transactions

`uvm_do_with(op,{last_type==M32 -> type==R32; length==uvmm2_seq::length;...})

Edited by uwes
Link to comment
Share on other sites

Here is my version of a sequence from the Practical Guide to UVM, that shows a write followed by a read.

class apb_read_write_word_seq extends uvm_sequence #(apb_transfer);

   `uvm_sequence_utils(apb_read_write_word_seq, apb_master_sequencer);

   rand bit [31:0] start_addr;
   constraint c_addr {start_addr[2:0] == '0; start_addr <= 16'hFFFF;}

   function new(string name="apb_read_write_word_seq");
      `uvm_info("INFO", $psprintf("%m"), UVM_HIGH);

   virtual task body();
      `uvm_info("SEQ_NAME", $psprintf("%m"), UVM_HIGH);
      `uvm_do_with(req, {req.addr == start_addr; req.direction == APB_WRITE; });
      `uvm_do_with(req, {req.addr == start_addr; req.direction == APB_READ;  });

endclass : apb_read_write_word_seq
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...