Functional Coverage in UVM
In previous blogs, we learned how a standard uvm test bench looks like and how an Environment instantiates Agent, Scoreboard and Coverage collector and Agent consists of Sequencer, Driver and a Monitor along with sample code for those components. This tutorial focuses on functional coverage in UVM.
Functional Coverage: Functional coverage in UVM is a user-defined metric that measures how much of the design specification that are captured in the test plan has been exercised.
•Used to measure whether interesting scenarios, corner cases, specification invariant have been observed, validated, and tested
•It is used to access that the random and focused tests adequately exercise the design
•SystemVerilog has a rich set of coverage construct to enable functional coverage collection
Focus of functional coverage in UVM is on the inputs to the DUT. To check if all the valid combinations of inputs/stimulus were exercised.
Below block diagram shows where functional coverage class would typically fit in the big picture followed by functional coverage code.
class add_coverage extends uvm_subscriber # (packet_c)
`uvm_component_utils(add_coverage)
packet_c txn;
covergroup inputs_to_dut;
cvp_1: coverpoint txn.a {
bins lo = {[0:7]}
bins hi = {[8:31]}
}
cvp_1: coverpoint txn.b {
bins lo = {[0:7]}
bins hi = {[8:31]}
}
endgroup
function new(string name, uvm_component parent);
inputs_to_dut = new();
endfunction: new
endclass
In above code, add_coverage class is defined and extended from uvm_subscriber class. It is a parameterized class that handles transactions of type packet_c. It is then registered in factory by calling standard UVM macro `uvm_component_utils. Then we declare a handle with name txn and this handler of type packet_c. Then covergroup inputs_to_dut is created. This covergroup has two coverpoints – One each for two inputs a and b of the DUT. Again, like other uvm_components, new function is defined in which inputs_to_dut is instantiated. After his inputs_tp_dut.sample() needs to be called at appropriate place in testbench so that the tool can collect the coverage.
POP-QUIZ: How do you get txn in above code?? Hint: Same way as the scoreboard gets it. There is a reason why we have placed Scoreboard and Coverage collector together in the block diagram above.
To get notifications for our upcoming blogs and tutorials, please LIKE our facebook fan page