uvm_not_gate_env
uvm_not_gate_env
Specification
VLSIJOBSEEKERS.COM
2023-07-18
Table of Contents
1. Abstract. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3. Design Specification. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3.1. Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3.2. Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3.3. Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3.4. Implementation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
4. PART 1: SystemVerilog Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4.1. Verification Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4.2. Test Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4.2.1. Random Stimulus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4.2.2. Corner Cases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4.3. Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4.4. Verification Components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4.4.1. Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4.4.2. Transaction Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4.4.3. Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4.4.4. Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.4.5. Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.4.6. Scoreboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.4.7. Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.4.8. Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.4.9. Testbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.4.10. Top-level Testbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5. PART 2: UVM Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.1. Verification Environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.2. Test Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.2.1. Random Stimulus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.2.2. Corner Cases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.3. Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.4. Verification Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.4.1. Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.4.2. Transaction Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.4.3. Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.4.4. Sequencer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.4.5. Driver. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.4.6. Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.4.7. Scoreboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.4.8. Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.4.9. Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.4.10. Testbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.4.11. Top-level Testbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Chapter 1. Abstract
This document specifies the design and verification plan for a simple NOT gate implemented in
SystemVerilog, including a comprehensive testbench structure with coverage and a top-level
module. The document is divided into two parts: SystemVerilog verification and UVM-based
verification.
1
Chapter 2. Introduction
The NOT gate is a fundamental digital logic component that inverts its input. This specification
outlines the design and verification methodology for implementing and testing a NOT gate using
SystemVerilog and UVM.
2
Chapter 3. Design Specification
3.1. Overview
The NOT gate is designed to invert a single-bit input signal.
3.2. Interface
Signal Direction Description
3.3. Functionality
The NOT gate will invert the input signal according to the following truth table:
Input Output
0 1
1 0
3.4. Implementation
module not_gate (
input logic in,
output logic out
);
endmodule
3
Chapter 4. PART 1: SystemVerilog
Verification
4.1. Verification Environment
The verification environment consists of the following components:
• Interface
• Transaction class
• Generator
• Driver
• Monitor
• Scoreboard
• Coverage
• Environment class
• Testbench module
Generate 100 random input vectors and verify the correct output for each.
• Stable input at 0
• Stable input at 1
4.3. Coverage
Functional coverage will be collected on both input and output signals, including cross coverage
between them.
4
4.4. Verification Components
4.4.1. Interface
interface not_gate_if;
logic in;
logic out;
class not_gate_transaction;
rand bit in;
bit out;
4.4.3. Generator
class not_gate_generator;
mailbox #(not_gate_transaction) gen2drv;
task run();
not_gate_transaction tr;
repeat(100) begin
tr = new();
assert(tr.randomize());
gen2drv.put(tr);
#2; // Wait for 2 time units
end
endtask
endclass
5
4.4.4. Driver
class not_gate_driver;
virtual not_gate_if.tb vif;
mailbox #(not_gate_transaction) drv_mbx;
task run();
not_gate_transaction tr;
forever begin
drv_mbx.get(tr);
vif.in <= tr.in;
#1; // Wait for 1 time unit
end
endtask
endclass
4.4.5. Monitor
class not_gate_monitor;
virtual not_gate_if.tb vif;
mailbox #(not_gate_transaction) mon_mbx;
task run();
not_gate_transaction tr;
forever begin
tr = new();
@(vif.in or vif.out);
tr.in = vif.in;
tr.out = vif.out;
mon_mbx.put(tr);
end
endtask
endclass
4.4.6. Scoreboard
class not_gate_scoreboard;
6
mailbox #(not_gate_transaction) mon_mbx;
int passes, fails;
task run();
not_gate_transaction tr;
forever begin
mon_mbx.get(tr);
if (tr.out == ~tr.in) begin
$display("PASS: Input = %b, Output = %b", tr.in, tr.out);
passes++;
end else begin
$display("FAIL: Input = %b, Output = %b (Expected %b)", tr.in, tr.out,
~tr.in);
fails++;
end
end
endtask
4.4.7. Coverage
class not_gate_coverage;
covergroup not_gate_cg @(posedge in);
input_cp: coverpoint in {
bins zero = {0};
bins one = {1};
}
output_cp: coverpoint out {
bins zero = {0};
bins one = {1};
}
in_out_cross: cross input_cp, output_cp;
endgroup
function new();
not_gate_cg = new();
endfunction
7
endclass
4.4.8. Environment
class not_gate_env;
not_gate_generator gen;
not_gate_driver drv;
not_gate_monitor mon;
not_gate_scoreboard scb;
not_gate_coverage cov;
mailbox #(not_gate_transaction) gen2drv, drv_mbx, mon_mbx;
virtual not_gate_if.tb vif;
task run();
fork
gen.run();
drv.run();
mon.run();
scb.run();
join_none
endtask
endclass
4.4.9. Testbench
module not_gate_tb (
not_gate_if dut_if
);
import not_gate_pkg::*;
not_gate_env env;
initial begin
env = new(dut_if.tb);
env.run();
8
// Run simulation for a specific time or until $finish is called
#1000;
if ($time > 999) $display("Simulation timeout");
env.scb.report();
$finish;
end
endmodule
`include "not_gate.sv"
`include "not_gate_if.sv"
`include "not_gate_pkg.sv"
`include "not_gate_tb.sv"
module not_gate_tb_top;
endmodule
9
Chapter 5. PART 2: UVM Verification
5.1. Verification Environment
The verification environment consists of the following UVM components:
• Interface
• Transaction class
• Sequence
• Sequencer
• Driver
• Monitor
• Scoreboard
• Coverage
• Environment class
• Testbench module
Generate 100 random input vectors and verify the correct output for each.
• Stable input at 0
• Stable input at 1
5.3. Coverage
Functional coverage will be collected on both input and output signals, including cross coverage
between them.
10
5.4.1. Interface
interface not_gate_if;
logic in;
logic out;
`uvm_object_utils_begin(not_gate_transaction)
`uvm_field_int(in, UVM_DEFAULT)
`uvm_field_int(out, UVM_DEFAULT)
`uvm_object_utils_end
5.4.3. Sequence
`uvm_object_utils_begin(not_gate_sequence)
`uvm_object_utils_end
11
finish_item(tr);
end
endtask
endclass
5.4.4. Sequencer
5.4.5. Driver
`uvm_component_utils(not_gate_driver)
5.4.6. Monitor
12
class not_gate_monitor extends uvm_component;
virtual not_gate_if.tb vif;
uvm_analysis_port #(not_gate_transaction) ap;
`uvm_component_utils(not_gate_monitor)
5.4.7. Scoreboard
`uvm_component_utils(not_gate_scoreboard)
13
end else begin
`uvm_error("FAIL", $sformatf("Input = %b, Output = %b (Expected %b)", tr.in,
tr.out, ~tr.in))
fails++;
end
endfunction
5.4.8. Coverage
`uvm_component_utils(not_gate_coverage)
5.4.9. Environment
14
virtual not_gate_if.tb vif;
`uvm_component_utils(not_gate_env)
5.4.10. Testbench
`uvm_component_utils(not_gate_test)
15
phase.raise_objection(this);
seq.start(env.sqr);
#1000;
if ($time > 999) `uvm_error("TIMEOUT", "Simulation timeout");
phase.drop_objection(this);
endtask
endclass
`include "not_gate.sv"
`include "not_gate_if.sv"
`include "not_gate_pkg.sv"
module not_gate_tb_top;
endmodule
16
Chapter 6. Conclusion
This specification outlines the complete design and verification plan for a NOT gate using
SystemVerilog and UVM. The verification strategy includes a combination of directed and random
test cases, functional coverage, and a comprehensive testbench environment.
17