`uvm_create 'd name of an object

`uvm_create 'd name of an object

UVM sequence macros are a great way of reducing code and hiding away some details. `uvm_do macros enable a sequence item to be created, randomized and executed on a sequencer all from a single line of code. `uvm_create is another macro which simply creates an object of a sequence item so that it can be handled later on. Let's see what the name of an object created by `uvm_create would look like. Unlike a typical type_id::create() method where you get to specify a required name, `uvm_create does not have any, not that it matters, but just for trivia.

A quick look at the definition of this macro within the UVM library will give you something like shown below.

`define uvm_create(SEQ_OR_ITEM) \
  `uvm_create_on(SEQ_OR_ITEM, m_sequencer)
`define uvm_create_on(SEQ_OR_ITEM, SEQR) \
  begin \
  uvm_object_wrapper w_; \
  w_ = SEQ_OR_ITEM.get_type(); \
  $cast(SEQ_OR_ITEM , create_item(w_, SEQR, `"SEQ_OR_ITEM`"));\

Under the hood, `uvm_create simply creates an object with the name that is passed as an argument to the macro, which will be the name of the variable itself. In an example shown below, a variable of type packet is created with the name jungle_book, and then upon calling `uvm_create on the object it will create and return an object with the name "jungle_book".

class packet extends uvm_sequence_item;
class my_seq extends uvm_sequence;
  virtual task body ();
    packet jungle_book;
    `uvm_create (jungle_book);
    jungle_book.print ();
Simulation Log
Name                           Type      Size  Value
jungle_book                    packet    -     @3492
  addr                         integral  32    'h990d450d
  begin_time                   time      64    0
  depth                        int       32    'd2
  parent sequence (name)       string    2     bs
  parent sequence (full name)  string    22    uvm_test_top.m_seqr.bs
  sequencer                    string    19    uvm_test_top.m_seqr
Practical example of polymorphism in UVM
Uniquely constrain variables

Related Posts



No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Saturday, 24 March 2018