Skip to main content

UVM Sequence Item and Data Modeling

· loading · loading · ·
Education UVM Verification UVM Verification SystemVerilog Data Modeling Uvm_sequence_item
Education UVM Verification
Axolot Logic
Author
Axolot Logic
Digital Design Engineer
Table of Contents
UVM Series - This article is part of a series.
Part 11: This Article

🧩 UVM Sequence Item and Data Modeling
#

🚀 Introduction
#

The uvm_sequence_item is the backbone of transaction-based verification environments in UVM. It is commonly used for data modeling, representing the information that flows between the testbench and the design under test (DUT).


🔍 Data Modeling
#

Data modeling in a UVM testbench is the process of organizing and defining data structures that represent the transactions exchanged with the DUT. This is typically done by defining data variables inside a uvm_sequence_item and using it as a container for stimulus generation.

For example, in an adder verification environment where two 8-bit numbers are added, the operands and the result can be modeled using a uvm_sequence_item.


📦 uvm_sequence_item Class
#

The uvm_sequence_item is a subclass of uvm_transaction and is used to model the data that flows through the testbench.
Its most common usage involves defining members with rand or randc qualifiers and using the randomize() method to generate stimulus.

Key Features
#

✅ Represents transactions between the testbench and the driver
✅ Supports randomization and constraints
✅ Includes built-in methods for print, compare, pack/unpack, etc., to aid debugging and analysis


📝 Adder Example
#

The following example shows how to model an adder_packet class that represents two 8-bit numbers to be added.

module adder (
  input logic clk,
  input logic rst,
  input logic [7:0] num1,
  input logic [7:0] num2,
  output logic [8:0] out
);
  always_ff @(posedge clk) begin
    if (rst) out <= 0;
    else out <= num1 + num2;
  end
endmodule
  // Sequence Item (Already Defined)
class adder_transaction extends uvm_sequence_item;
  rand bit [8:0] num1;
  rand bit [8:0] num2;
  bit [8:0] result;
  bit is_correct; // Flag to indicate correctness

  // Constraint for num1 and num2 to be in range 0-512
  constraint input_range {
    num1 >= 0 && num1 <= 300;
    num2 >= 0 && num2 <= 300;
  }

  `uvm_object_utils(adder_transaction)

  function new(string name = "adder_transaction");
    super.new(name);
  endfunction
endclass

Explanation
#

  • num1 and num2: The two 8-bit numbers to be added (randomizable)
  • out: The sum result (to be set by the driver, not randomized)
  • uvm_object_utils_begin and uvm_object_utils_end: These macros automatically generate print, compare, and pack methods, simplifying debugging and maintenance.

💡 Summary
#

🔹 uvm_sequence_item is the foundation of data modeling in UVM.
🔹 It is used to model transaction data and generate random stimulus.
🔹 Data modeling ensures that the testbench can produce stimulus aligned with protocol or functional requirements.
🔹 The adder example shows how to represent a simple addition operation, ready to integrate with sequencer and driver components.


UVM Series - This article is part of a series.
Part 11: This Article

Related

UVM Sequence Usage and Adder Example
· loading · loading
Education UVM Verification UVM Verification SystemVerilog Uvm_sequence Stimulus Generation
Education UVM Verification
UVM Agent Usage and Adder Example
· loading · loading
Education UVM Verification UVM Verification SystemVerilog Uvm_agent Testbench Structure
Education UVM Verification
UVM Base Classes
· loading · loading
Education UVM Verification UVM Verification SystemVerilog Class Hierarchy
Education UVM Verification
UVM Driver Usage and Adder Example
· loading · loading
Education UVM Verification UVM Verification SystemVerilog Uvm_driver Stimulus Driving
Education UVM Verification
UVM Environment Usage and adder_env Example
· loading · loading
Education UVM Verification UVM Verification SystemVerilog Uvm_env Testbench Structure
Education UVM Verification
UVM Monitor Usage and Adder Example
· loading · loading
Education UVM Verification UVM Verification SystemVerilog Uvm_monitor Coverage
Education UVM Verification