image/svg+xml
  • Contents
      • Back
      • Digital Basics
      • Verilog
      • Verification
      • SystemVerilog
      • UVM
Most Popular
Verification
  Testbench Evolution
  Constraint Random Verification
  Verification Techniques
  Verification Plan
  Code Coverage

Verilog
  Data Types
  Basic Constructs
  Behavioral Modeling
  Gate Modeling
  Simulation Basics
  Design Examples

SystemVerilog
  Data Types
  Class
  Interface
  Constraints and more!
  Testbench Examples

UVM
  Sequences
  Testbench Components
  TLM Tutorial
  Register Model Tutorial
  Testbench Examples

Digital Fundamentals
  Binary Arithmetic
  Boolean Logic
  Karnaugh Maps
  Combinational Logic
  Sequential Logic




UVM Virtual Sequencer

In simple terms it's a UVM sequencer that contain handles to other sequencers. Why do we need this ? Because we plan to use virtual sequences and want to have control over all sequencers from a central place. A request type is not required here because this sequencer is generic and not limited to handle only one particular data type.

Click to refresh the concept of a virtual sequence.

virtual sequencer

The environment shown above has an APB agent, Wishbone agent, PCIE environment and a register layer environment. Each of these components have their own sequences and the respective sequencers on which they are launched. A virtual sequencer called m_virt_seqr is instantiated to hold references to each individual sequencer. Hence a virtual sequence executing on this virtual sequencer will have access to all the sequencers in the testbench.

Example


	class my_virtual_sequencer extends uvm_sequencer;
		`uvm_component_utils (my_virtual_sequencer)
		
		function new (string name = "my_virtual_sequencer", uvm_component parent);
			super.new (name, parent);
		endfunction
		
		// Declare handles to other sequencers here
		apb_sequencer       m_apb_seqr;
		reg_sequencer       m_reg_seqr;
		wb_sequencer        m_wb_seqr;
		pcie_sequencer      m_pcie_seqr;
	endclass

Read more: UVM Virtual Sequencer

UVM Sequence [uvm_sequence]

What is a UVM sequence ?

UVM sequences are made up of several data items which can be put together in different ways to create interesting scenarios. They are executed by an assigned sequencer which then sends data items to the driver. Hence, sequences make up the core stimuli of any verification plan.

sequences on a sequencer

Class Hierarchy

uml_uvm_sequence_class_hier

Steps to create a UVM sequence

1. Create a user-defined class inherited from uvm_sequence, register with factory and call new

// my_sequence is user-given name for this class that has been derived from "uvm_sequence"
class my_sequence extends uvm_sequence;
	
	// [Recommended] Makes this sequence reusable. Note that we are calling 
	// `uvm_object_utils instead of `uvm_component_utils because sequence is a uvm_transaction object
	`uvm_object_utils (my_sequence)
	
	// This is standard code for all components
    function new (string name = "my_sequence");
    	super.new (name);
    endfunction	
endclass
2. Declare the default sequencer to execute this sequence

	// [Optional] my_sequencer is a pre-defined custom sequencer before this sequence definition
	`uvm_declare_p_sequencer (my_sequencer)
3. Define the body method

	// [Recommended] Make this task "virtual" so that child classes can override this task definition
	virtual task body ();
		// Stimulus for this sequence comes here
	endtask

Read more: UVM Sequence [uvm_sequence]

Subscriber [uvm_subscriber]

Subscribers are basically listeners of an analysis port. They subscribe to a broadcaster and receive objects whenever an item is broadcasted via the connected analysis port. A uvm_component class does not have an in-built analysis port, while a uvm_subscriber is an extended version with an analysis port named analysis_export.

Class definition


virtual class uvm_subscriber #(type T=int) extends uvm_component;
	typedef uvm_subscriber #(T) this_type;
	
	uvm_analysis_imp #(T, this_type) analysis_export;
	
	function new (string name, uvm_component parent);
		super.new (name, parent);
		analysis_export = new ("analysis_imp", this);
	endfunction
	
	pure virtual function void write (T, t);
endclass

Read more: Subscriber [uvm_subscriber]

JK Flip Flop

Design


module jk_ff ( input j,
               input k,
               input clk,
               output q);

   reg q;

   always @ (posedge clk)
      case ({j,k})
         2'b00 :  q <= q;
         2'b01 :  q <= 0;
         2'b10 :  q <= 1;
         2'b11 :  q <= ~q;
      endcase
endmodule

Hardware Schematic

Testbench


module tb_jk;
   reg j;
   reg k;
   reg clk;
   
   always #5 clk = ~clk;
   
   jk_ff    jk0 ( .j(j),
                  .k(k),
                  .clk(clk),
                  .q(q));

   initial begin
      j <= 0;
      k <= 0;
      
      #5 j <= 0;
         k <= 1;
      #20 j <= 1;
          k <= 0;
      #20 j <= 1;
          k <= 1;
      #20 $finish;
   end

   initial
      $monitor ("j=%0d k=%0d q=%0d", j, k, q);
endmodule	

D Flip-Flop Async Reset

A D flip-flop is a sequential element that follows the input pin d at the given edge of a clock.

Design #1: With async active-low reset


module dff 	( input d,
              input rstn,
              input clk,
              output reg q);
	
	always @ (posedge clk or negedge rstn) 
       if (!rstn)
          q <= 0;
       else
          q <= d;
endmodule

Hardware Schematic

Testbench


module tb_dff;
	reg clk;
	reg d;
	reg rstn;
	reg [2:0] delay;
	
    dff  dff0 ( .d(d),
                .rsnt (rstn),
                .clk (clk),
                .q (q));
    
    // Generate clock
    always #10 clk = ~clk;
                   
    // Testcase
    initial begin
    	clk <= 0;
    	d <= 0;
    	rstn <= 0;
    	
    	#15 d <= 1;
    	#10 rstn <= 1;
    	for (int i = 0; i < 5; i=i+1) begin
    		delay = $random;
    		#(delay) d <= i;
    	end
    end
endmodule

Design #1: With sync active-low reset


module dff 	( input d,
              input rstn,
              input clk,
              output reg q);
	
	always @ (posedge clk) 
       if (!rstn)
          q <= 0;
       else
          q <= d;
endmodule

Hardware Schematic

Testbench


module tb_dff;
	reg clk;
	reg d;
	reg rstn;
	reg [2:0] delay;
	
    dff  dff0 ( .d(d),
                .rsnt (rstn),
                .clk (clk),
                .q (q));
    
    // Generate clock
    always #10 clk = ~clk;
                   
    // Testcase
    initial begin
    	clk <= 0;
    	d <= 0;
    	rstn <= 0;
    	
    	#15 d <= 1;
    	#10 rstn <= 1;
    	for (int i = 0; i < 5; i=i+1) begin
    		delay = $random;
    		#(delay) d <= i;
    	end
    end
endmodule
  1. D Latch
  2. Verilog n-bit Bidirectional Shift Register
  3. UVM TLM Nonblocking Put Port
  4. 4-bit counter
  5. Verilog Hello World

Page 36 of 63

  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
Interview Questions
  Verilog Interview Set 1
  Verilog Interview Set 2
  Verilog Interview Set 3
  Verilog Interview Set 4
  Verilog Interview Set 5

  SystemVerilog Interview Set 1
  SystemVerilog Interview Set 2
  SystemVerilog Interview Set 3
  SystemVerilog Interview Set 4
  SystemVerilog Interview Set 5

  UVM Interview Set 1
  UVM Interview Set 2
  UVM Interview Set 3
  UVM Interview Set 4
Related Topics
  Digital Fundamentals
  Verilog Tutorial

  Verification
  SystemVerilog Tutorial
  UVM Tutorial
  • Verilog Testbench
  • Verilog Coding Style Effect
  • Verilog Conditional Statements
  • Verilog Interview Set 10
  • Synchronous FIFO
  • SystemVerilog Interview Set 10
  • SystemVerilog Interview Set 9
  • SystemVerilog Interview Set 8
  • SystemVerilog Interview Set 7
  • SystemVerilog Interview Set 6
  • UVM Singleton Object
  • UVM Component [uvm_component]
  • UVM Object [uvm_object]
  • UVM Root [uvm_root]
  • UVM Interview Set 4
© 2015 - 2023 ChipVerify
Terms and Conditions | DMCA.com Protection Status