Professional Documents
Culture Documents
Adder Verification Using UVM
Adder Verification Using UVM
Verification
using
Normal Adder UVM verification
Let’s take adder of the following specification:
// Input signals
logic a_in;
logic b_in;
logic c_in;
// Output signals
logic sum_out;
logic carry_out;
// Control signals
logic clock;
logic reset;
So in the adder, there could be any random bit in input operand, hence input a_in, b_in,c_inare
randomized
// Macros for additional UVM features (commented out, but you can enable if
needed)
/* `uvm_object_utils_begin(normal_adder_txn)
`uvm_field_int(a_in, UVM_ALL_ON)
`uvm_field_int(b_in, UVM_ALL_ON)
`uvm_field_int(c_in, UVM_ALL_ON)
`uvm_field_int(sum_out, UVM_ALL_ON)
`uvm_field_int(carry_out, UVM_ALL_ON)
`uvm_object_utils_end */
endclass // End of class normal_adder_txn
So in current scenario let the loop of randomization run for 8 times to get all inputcombination ,
hence it will look like below
// Define a UVM sequence class named normal_add_sequence
class normal_add_sequence extends uvm_sequence#(normal_adder_txn);
endclass: normal_add_sequencer
endmodule : testbench
endclass : normal_add_driver
// Build phase: Set up the virtual interface connection and analysis port
function void build_phase(uvm_phase phase);
// Call the base class build_phase
super.build_phase(phase);
endclass : normal_add_monitor_before
///////////////////////////////////////////////////////////////////////////
// This Monitor Calculates the reference result
class normal_add_ref_monitor_after extends uvm_monitor;
// Build phase: Set up the virtual interface connection and analysis port
function void build_phase(uvm_phase phase);
// Call the base class build_phase
super.build_phase(phase);
// Attempt to get the virtual interface from the UVM configuration
database
if (!uvm_config_db#(virtual dut_if1)::get(this, "", "dut_vif", dut_vif))
begin
`uvm_error("", "uvm_config_db::get failed")
end
// Update the transaction item with the calculated sum and carry_out
add_mon_ref_txn.sum_out = sum_res[0];
add_mon_ref_txn.carry_out = sum_res[1];
endfunction : add_mon_ref_add_result
endclass : normal_add_ref_monitor_after
Now let’s Define Agent
// Include the sequencer file named "normal_adder_seqr.sv"
`include "normal_adder_seqr.sv"
endclass : normal_add_agent
endclass : normal_add_env
endclass : normal_adder_score
// Set a drain time to ensure that all activities complete before ending
the phase
phase.phase_done.set_drain_time(this, 50);
endtask
endclass