top of page
Search

UVM Sequences

  • Dec 3, 2023
  • 2 min read


let's break down the UVM sequence code in that format:


### UVM Sequence Tutorial for Beginners:


```systemverilog

class my_sequence extends uvm_sequence #(my_sequence_item);

`uvm_object_utils(my_sequence)


task body();

my_sequence_item seq_item;

seq_item = my_sequence_item::type_id::create("seq_item");

if (!seq_item.randomize())

`uvm_fatal("RANDOMIZE_FAILED", "Randomization failed for sequence item")

seq_item.randomize();

`uvm_info("SEQ_EXECUTION", $sformatf("Executing sequence: %s", get_full_name()), UVM_LOW)

start_item(seq_item);

finish_item(seq_item);

endtask

endclass

```


Let's explain each line:


1. ``` class my_sequence extends uvm_sequence #(my_sequence_item); ```

- **What do these lines do?**: Declares a new sequence class named `my_sequence` that handles transactions of type `my_sequence_item`.

- **What if I don't add this?**: Without this line, there won't be a structured sequence to manage the generation and handling of sequence items.


2. ``` `uvm_object_utils(my_sequence)```

- **What do these lines do?**: Uses a macro to automate certain housekeeping tasks within UVM, like factory registration for the `my_sequence` class.

- **What if I don't add this?**: Omitting this macro might lead to issues related to factory registration or other essential functionalities needed for the `my_sequence` class.


3. `task body(); ... endtask`

- **What do these lines do?**: Defines the core execution logic of the sequence within the `body()` task.

- **What if I don't add this?**: Without this task, there won't be essential logic to generate and manage sequence items effectively.


4. `my_sequence_item seq_item;`

- **What do these lines do?**: Declares an instance `seq_item` of the `my_sequence_item` class to handle transactional data.

- **What if I don't add this?**: Omitting this declaration will result in an undefined object to handle transactional data, causing errors during operations.


5. `seq_item = my_sequence_item::type_id::create("seq_item");`

- **What do these lines do?**: Creates an instance of `my_sequence_item` and assigns it to `seq_item`.

- **What if I don't add this?**: Omitting this line will result in an uninitialized `seq_item`, causing errors during sequence execution.


6. `if (!seq_item.randomize()) ...`

- **What do these lines do?**: Attempts to randomize the properties of `seq_item` to generate valid test scenarios.

- **What if I don't add this?**: Omitting randomization may lead to `seq_item` containing default or uninitialized values, impacting the validity of the test scenario.


7. `start_item(seq_item);` and `finish_item(seq_item);`

- **What do these lines do?**: They initiate and complete the execution of `seq_item` by sending it to the sequencer for processing and signaling the completion of the item's execution, respectively.

- **What if I don't add this?**: Without these lines, the sequencer won't receive `seq_item` for execution. Consequently, the sequence won't trigger any action or stimulus on the design under verification (DUV), impacting the verification process by halting the flow of stimulus to the DUV.

 
 
 

Recent Posts

See All
APB Protocol Using UVM: A Beginner's Guide

Learn how to implement the AMBA APB (Advanced Peripheral Bus) protocol using UVM (Universal Verification Methodology). This beginner-friendly guide includes complete, copy-paste ready UVM code example

 
 
 

Comments


bottom of page