[source]

Class uvm_pkg::uvm_sequence_library

CLASS

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 mode, its select_rand property is randomized and used as an index into sequences . When in mode, the select_randc property is used. When in mode, only sequence items of the REQ type are generated and executed--no sequences are executed. Finally, when in 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](../../../../index-macros.html#macros) 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
Parameters

Name

Default value

Description

REQ

uvm_sequence_item

RSP

REQ

Variables

Name

Type

Description

selection_mode

uvm_sequence_lib_mode

Variable

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 . 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

Variable

min_random_count

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

Variable

max_random_count

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

sequence_count

int unsigned

Variable

sequence_count

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

select_rand

int unsigned

Variable

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

bit[15:0]

Variable

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.

type_name

string

Constraints

Name

Description

valid_rand_selection

Constraint

valid_rand_selection

Constrains select_rand to be a valid index into the sequences array

valid_randc_selection

Constraint

valid_randc_selection

Constrains select_randc to be a valid index into the sequences array

valid_sequence_count

Constraint

valid_sequence_count

Constrains sequence_count to lie within the range defined by min_random_count and max_random_count.

Typedefs

Name

Actual Type

Description

this_type

uvm_sequence_library#(REQ, RSP)

Constructors

new(string name = "")

Function

new

Create a new instance of this class. New

Parameters:

name (string)

Functions

get_type_name()

Function

get_type_name

Get the type name of this class. Get_type_name

select_sequence(int unsigned max)

Function

select_sequence

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

Parameters:

max (int unsigned)

add_typewide_sequence(uvm_object_wrapper seq_type)

Function

add_typewide_sequence

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_sequence

Parameters:

seq_type (uvm_object_wrapper)

add_typewide_sequences(uvm_object_wrapper seq_types)

Function

add_typewide_sequences

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_typewide_sequences

Parameters:

seq_types (uvm_object_wrapper)

add_sequence(uvm_object_wrapper seq_type)

Function

add_sequence

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

Parameters:

seq_type (uvm_object_wrapper)

add_sequences(uvm_object_wrapper seq_types)

Function

add_sequences

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

Parameters:

seq_types (uvm_object_wrapper)

remove_sequence(uvm_object_wrapper seq_type)

Function

remove_sequence

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. Remove_sequence

Parameters:

seq_type (uvm_object_wrapper)

get_sequences(uvm_object_wrapper seq_types)

Function

get_sequences

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

Parameters:

seq_types (uvm_object_wrapper)

init_sequence_library()

Function

init_sequence_library

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

do_print(uvm_printer printer)

Do_print

Parameters:

printer (uvm_printer)

Tasks

execute(uvm_object_wrapper wrap)

Execute

Parameters:

wrap (uvm_object_wrapper)

body()

Body