Basics
- Put all covergroups in a class or module
- Use local variables in the class or module
- Make covergroups sensitive to a variable or explicitly sample a variable
- Have a coverage test plan
- Use automatic bins for simple covergroup
- Code coverage is not functional coverage
- line coverage
- block / statement coverage
- branch coverage
- path coverage
- toggle coverage
- expression coverage
- FSM coverage
- transition coverage
<coverpoint_name> : coverpoint <expression> { bins <bin_name> = { <list of values > } }
class coverage extends uvm_agent;
`uvm_component_utils (coverage)
tlm_analysis_fifo #(mem_req) req_fifo;
mem_req req;
mem_op op;
logic [15:0] addr;
covergroup mem_ops;
coverpoint memop {
bins action[] = {read, write};
}
coverpoint addr {
bins zeros = {0};
bins others = {[1 : 16'hFFFE]};
bins ones = {16'hFFFF};
}
edges : cross op, addr;
endgroup
covergroup alu_cv;
all_ops : coverpoint op;
a_op: coverpoint A {bins Ais0 = {'h00};}
b_op: coverpoint B {bins Bis0 = {'h00};}
endgroup
function new (string name, uvm_component parent);
super.new(name, parent);
mem_ops = new();
alu_cv = new();
endfunction : new
task run();
mem_data cln;
mem_req req_tx;
forever begin : run_loop
req_fifo.get (req_tx);
op = req_tx.op;
addr = req_tx.addr;
mem_ops.sample();
end
endtask : run
endclass
Example: automatic bins
typedef enum {add, and, xor, mul, rst, nop} op_t;
covergroup opcov;
coverpoint op;
endgroup : opcov
task sample_req;
A = req.A;
B = req.B;
op = req.op;
opcov.sample();
endtask
covergroup alu_cv2;
coverpoint op;
coverpoint A;
coverpoint B;
option.auto_bin_max = 4; // default to 64 bins
endgroup
Example: Basic Bins
covergroup opcov;
coverpoint op;
A00FF : coverpoint A {
bins zeros = { 0 };
bins ones = { 8'hFF };
}
B00FF : coverpoint B {
bins zeros_ones = { 0, 8'hFF };
}
endgroup
Bins with Ranges, Bins with sequences
typedef enum {add, and, xor, mul, rst, nop} op_t;
covergroup opcov;
coverpoint op {
bins single_cyc = {[add : xor] , rst, nop};
bins multi_cyc = {mul};
}
endgroup : opcov
// Automatic bins with ranges
bins onepervalue [] = {< list of="" values="" >};
bins n_bins [n] = { < list of="" values="" >};
bins threebins [3] = {[1:2],[2:6]};
// same as
// bins threebins [3] = {1,2,2,3,4,5,6};
// Bins with sequences
// run multi-cycle after reset
// bins bin_name = ( < value1 > => < value2 >);
covergroup opcov;
coverpoint op {
bins single_cycle = {[add : xor], rst, nop};
bins multi_cycle = {mul};
bins mult_rst = (mul => rst);
bins rst_mult = (rst => mul);
}
endgroup
Bins with multiple value transitions in sequences
// Bins with multiple value transitions // bins bin_name = (< value list > => < value list >); // 1, 2 => [3:5], 7 // 1=>3, 2=>3, 1=>4, 2=>4, 1=>5, 2=>5, 1=>7, 2=>7 bins op_rst[] = ( [add : nop ] => rst ); bins rst_mult[] = ( rst => [add : nop]); // multi-cycle after single-cycle bins singl_mul[] = ( [add : xor ], nop => mul ); // single-cycle after multi-cycle bins mul_sngl[] = ( mul => [add : xor ], nop ); // Run all operations twice in a row // bins <name> = (<value list> [* n]); bins <name> = (<value list> [* n:m]); // Ex: Run 3-5 Multiplies in a row bins twoops[] = ([add:nop] [*2]); bins manymult = (mul [* 3:5]); // Nonconsecutive Repetition // <value list> [= n:m]; // nonconsecutive operator // <value list> [-> n:m]; // goto operator // • Nonconsecutive Operator (=) matches if n:m values occur // in a list of value regardless of the terminating value. // • Goto Operator (->) matches if n:m values occur in a list // of values and then a terminating value appears. bins rstmulrst = (rst => mul [= 2] => rst); // rstmulrst (match): rst => mul => xor => mul => and => rst bins rstmulrstim = (rst => mul [-> 2] => rst); // rstmulrst and rstmulrstim (match): rst => mul => xor => and => mul => rst
Cross Coverage : Use Cross and Binsof to capture combinations of values
covergroup zeros_ones_ops;
all_ops : coverpoint op {
ignore_bins null_ops = {rst, nop};
}
a_op: coverpoint A {
bins zeros = {'h00};
bins others = {['h01:'hFE]};
bins ones = {'hFF};
}
b_op: coverpoint B {
bins zeros = {'h00};
bins others = {['h01:'hFE]};
bins ones = {'hFF};
}
basic : cross a_op, b_op, all_ops;
with_a0bin : cross a_op, b_op, all_ops {
bins a0bin = binsof (a_op.zeros);
}
// bins <bin> = binsof(<somebins>) && binsof(<otherbins>);
// bins <bin> = binsof(<somebins>) || binsof(<otherbins>);
zeros_ones : cross a_op, b_op, all_ops {
bins AorBzero = binsof (a_op.zeros) || binsof (b_op.zeros);
bins AorBones = binsof (a_op.ones) || binsof (b_op.ones);
ignore_bins the_others =
binsof (a_op.others) && binsof (b_op.others);
}
// intersect qualifier
// bins <bin> = binsof(<somebins> intersect (<value_list>))
zeros_ones_2 : cross a_op, b_op, all_ops {
bins add_bin = binsof (all_ops) intersect {add};
ignore_bins x = ! binsof (all_ops) intersect {add};
}
endgroup
No comments:
Post a Comment