uvm_sequence_library

The uvm_sequence_library is a sequence that contains a list of registered sequence types.  It can be configured to create and execute these sequences any number of times using one of several modes of operation, including a user-defined mode.

When started (as any other sequence), the sequence library will randomly select and execute a sequence from its sequences queue.  If in UVM_SEQ_LIB_RAND mode, its select_rand property is randomized and used as an index into sequences.  When in UVM_SEQ_LIB_RANDC mode, the select_randc property is used.  When in UVM_SEQ_LIB_ITEM mode, only sequence items of the REQ type are generated and executed--no sequences are executed.  Finally, when in UVM_SEQ_LIB_USER mode, the select_sequence method is called to obtain the index for selecting the next sequence to start.  Users can override this method in subtypes to implement custom selection algorithms.

Creating a subtype of a sequence library requires invocation of the `uvm_sequence_library_utils macro in its declaration and calling the init_sequence_library method in its constructor.  The macro and function are needed to populate the sequence library with any sequences that were statically registered with it or any of its base classes.

class my_seq_lib extends uvm_sequence_library #(my_item);
  `uvm_object_utils(my_seq_lib)
  `uvm_sequence_library_utils(my_seq_lib)
   function new(string name="");
     super.new(name);
     init_sequence_library();
   endfunction
   ...
endclass
Contents
uvm_sequence_libraryThe uvm_sequence_library is a sequence that contains a list of registered sequence types.
uvm_sequence_library_cfgA convenient container class for configuring all the sequence library parameters using a single set command.

new

function new(
    string  name  =  ""
)

Create a new instance of this class

get_type_name

virtual function string get_type_name()

Get the type name of this class

selection_mode

uvm_sequence_lib_mode selection_mode

Specifies the mode used to select sequences for execution

If you do not have access to an instance of the library, use the configuration resource interface.

The following example sets the config_seq_lib as the default sequence for the ‘main’ phase on the sequencer to be located at “env.agent.sequencer” and set the selection mode to UVM_SEQ_LIB_RANDC.  If the settings are being done from within a component, the first argument must be this and the second argument a path relative to that component.

uvm_config_db #(uvm_object_wrapper)::set(null,
                                   "env.agent.sequencer.main_phase",
                                   "default_sequence",
                                   main_seq_lib::get_type());

uvm_config_db #(uvm_sequence_lib_mode)::set(null,
                                   "env.agent.sequencer.main_phase",
                                   "default_sequence.selection_mode",
                                   UVM_SEQ_LIB_RANDC);

Alternatively, you may create an instance of the sequence library a priori, initialize all its parameters, randomize it, then set it to run as-is on the sequencer.

main_seq_lib my_seq_lib;
my_seq_lib = new("my_seq_lib");

my_seq_lib.selection_mode = UVM_SEQ_LIB_RANDC;
my_seq_lib.min_random_count = 500;
my_seq_lib.max_random_count = 1000;
void'(my_seq_lib.randomize());

uvm_config_db #(uvm_sequence_base)::set(null,
                                   "env.agent.sequencer.main_phase",
                                   "default_sequence",
                                   my_seq_lib);

min_random_count

int unsigned min_random_count=10

Sets the minimum number of items to execute.  Use the configuration mechanism to set.  See selection_mode for an example.

max_random_count

int unsigned max_random_count=10

Sets the maximum number of items to execute.  Use the configuration mechanism to set.  See selection_mode for an example.

sequences_executed

protected int unsigned sequences_executed

Indicates the number of sequences executed, not including the currently executing sequence, if any.

sequence_count

rand int unsigned sequence_count = 10

Specifies the number of sequences to execute when this sequence library is started.  If in UVM_SEQ_LIB_ITEM mode, specifies the number of sequence items that will be generated.

select_rand

rand int unsigned select_rand

The index variable that is randomized to select the next sequence to execute when in UVM_SEQ_LIB_RAND mode

Extensions may place additional constraints on this variable.

select_randc

randc bit [15:0] select_randc

The index variable that is randomized to select the next sequence to execute when in UVM_SEQ_LIB_RANDC mode

Extensions may place additional constraints on this variable.

select_sequence

virtual function int unsigned select_sequence(
    int  unsigned  max
)

Generates an index used to select the next sequence to execute.  Overrides must return a value between 0 and max, inclusive.  Used only for UVM_SEQ_LIB_USER selection mode.  The default implementation returns 0, incrementing on successive calls, wrapping back to 0 when reaching max.

add_typewide_sequence

static function void add_typewide_sequence(
    uvm_object_wrapper  seq_type
)

Registers the provided sequence type with this sequence library type.  The sequence type will be available for selection by all instances of this class.  Sequence types already registered are silently ignored.

add_typewide_sequences

static function void add_typewide_sequences(
    uvm_object_wrapper  seq_types[$]
)

Registers the provided sequence types with this sequence library type.  The sequence types will be available for selection by all instances of this class.  Sequence types already registered are silently ignored.

add_sequence

function void add_sequence(
    uvm_object_wrapper  seq_type
)

Registers the provided sequence type with this sequence library instance.  Sequence types already registered are silently ignored.

add_sequences

virtual function void add_sequences(
    uvm_object_wrapper  seq_types[$]
)

Registers the provided sequence types with this sequence library instance.  Sequence types already registered are silently ignored.

remove_sequence

virtual function void remove_sequence(
    uvm_object_wrapper  seq_type
)

Removes the given sequence type from this sequence library instance.  If the type was registered statically, the sequence queues of all instances of this library will be updated accordingly.  A warning is issued if the sequence is not registered.

get_sequences

virtual function void get_sequences(
    ref  uvm_object_wrapper  seq_types[$]
)

Append to the provided seq_types array the list of registered sequences.

init_sequence_library

function void init_sequence_library()

All subtypes of this class must call init_sequence_library in its constructor.

uvm_sequence_library_utils

All subtypes of this class must invoke the `uvm_sequence_library_utils macro.

class my_seq_lib extends uvm_sequence_library #(my_item);
  `uvm_object_utils(my_seq_lib)
  `uvm_sequence_library_utils(my_seq_lib)
   function new(string name="");
     super.new(name);
     init_sequence_library();
   endfunction
   ...
endclass

uvm_sequence_library_cfg

A convenient container class for configuring all the sequence library parameters using a single set command.

uvm_sequence_library_cfg cfg;
cfg = new("seqlib_cfg", UVM_SEQ_LIB_RANDC, 1000, 2000);

uvm_config_db #(uvm_sequence_library_cfg)::set(null,
                                   "env.agent.sequencer.main_ph",
                                   "default_sequence.config",
                                   cfg);
Summary
uvm_sequence_library_cfg
A convenient container class for configuring all the sequence library parameters using a single set command.
Class Hierarchy
uvm_sequence_library_cfg
Class Declaration
class uvm_sequence_library_cfg extends uvm_object
virtual class uvm_void
The uvm_void class is the base class for all UVM classes.
virtual class uvm_object extends uvm_void
The uvm_object class is the base class for all UVM data and hierarchical classes.
virtual class uvm_transaction extends uvm_object
The uvm_transaction class is the root base class for UVM transactions.
class uvm_sequence_item extends uvm_transaction
The base class for user-defined sequence items and also the base class for the uvm_sequence class.
class uvm_sequence_base extends uvm_sequence_item
The uvm_sequence_base class provides the interfaces needed to create streams of sequence items and/or other sequences.
virtual class uvm_sequence #(
    type  REQ  =  uvm_sequence_item,
    type  RSP  =  REQ
) extends uvm_sequence_base
The uvm_sequence class provides the interfaces necessary in order to create streams of sequence items and/or other sequences.
class uvm_sequence_library #(
    type  REQ  =  uvm_sequence_item,
      RSP  =  REQ
) extends uvm_sequence #(REQ,RSP)
The uvm_sequence_library is a sequence that contains a list of registered sequence types.
class uvm_sequence_library_cfg extends uvm_object
A convenient container class for configuring all the sequence library parameters using a single set command.
Random sequence selection
rand int unsigned select_rand
The index variable that is randomized to select the next sequence to execute when in UVM_SEQ_LIB_RAND mode
Random cyclic sequence selection
randc bit [15:0] select_randc
The index variable that is randomized to select the next sequence to execute when in UVM_SEQ_LIB_RANDC mode
Emit only items, no sequence execution
Apply a user-defined random-selection algorithm
virtual function int unsigned select_sequence(
    int  unsigned  max
)
Generates an index used to select the next sequence to execute.
function void init_sequence_library()
All subtypes of this class must call init_sequence_library in its constructor.
uvm_sequence_lib_mode selection_mode
Specifies the mode used to select sequences for execution