EDA Tools:
- ICCR ( Cadence)
- ModelSim (Mentor Graphics)
Coverage can be divided into two:
- Code Coverage
- Functional Coverage
Code coverage is further divided into
- Block Coverage
- Expression Coverage
- FSM Coverage
- Toggle Coverage
Example for Code coverage: DUT (4:1 Mux )
module four_mux ( a, b, c, d, Sel_a, Sel_b , Out );
input a, b, c, d, Sel_a, Sel_b ;
output Out ;
reg Out ;
always @ ( a, b, c, d, Sel_a, Sel_b)
begin
case (Sel_a, Sel_b)
2'b00 : Out <= a; 2'b01 : Out <=b; 2'b10 : Out <=c; 2'b11 : Out <= d; default : Out <= 1'b0; endcase end endmodule
module tb_four_mux ;
reg a, b, c, d, Sel_a, Sel_b ;
wire Out ;
initial begin
a = 1'b0 ;
b = 1'b1 ;
c = 1'b0 ;
d = 1'b1 ;
// Input Combination 0
Sel_a = 1'b0 ;
Sel_b = 1'b0;
//Input Combination 1
Sel_a = 1'b0 ;
Sel_b = 1'b1 ;
//Input Combination 2
Sel_a = 1'b1 ;
Sel_b = 1'b0 ;
//Input Combination 3
Sel_a = 1'b1;
Sel_b = 1'b1;
//Input Combination X
Sel_a = 1'bx ;
Sel_b = 1'bx ;
end
//Instantiate the DUT in test bench environment
four_mux four_mux_instantiate ( .a (a),
.b (b),
.c (c),
.d (d),
.Sel_a (Sel_a),
.Sel_b (Sel_b),
.Out (Out)
);
endmodule
reg a, b, c, d, Sel_a, Sel_b ;
wire Out ;
initial begin
a = 1'b0 ;
b = 1'b1 ;
c = 1'b0 ;
d = 1'b1 ;
// Input Combination 0
Sel_a = 1'b0 ;
Sel_b = 1'b0;
//Input Combination 1
Sel_a = 1'b0 ;
Sel_b = 1'b1 ;
//Input Combination 2
Sel_a = 1'b1 ;
Sel_b = 1'b0 ;
//Input Combination 3
Sel_a = 1'b1;
Sel_b = 1'b1;
//Input Combination X
Sel_a = 1'bx ;
Sel_b = 1'bx ;
end
//Instantiate the DUT in test bench environment
four_mux four_mux_instantiate ( .a (a),
.b (b),
.c (c),
.d (d),
.Sel_a (Sel_a),
.Sel_b (Sel_b),
.Out (Out)
);
endmodule
Let us assume that input combination x is not written in test case. So now the input combination 0, 1, 2, 3 hits the functionality of the DUT,
always @ ( a, b, c, d, Sel_a, Sel_b)
begin case ( Sel_a, Sel_b )
2'b00 : out <= a ;
2'b01: out <= b ;
2'b10: out <= c;
2'b11: out <= d;
default : out <= 1'b0 ;
endcase
end
begin case ( Sel_a, Sel_b )
2'b00 : out <= a ;
2'b01: out <= b ;
2'b10: out <= c;
2'b11: out <= d;
default : out <= 1'b0 ;
endcase
end
So, depending upon the Sel_a and Sel_b, the particular input would be driving the output which is the functionality of the Mux. So, if Sel_a and Sel_b equals to 0, input a Out, when Sel_a and Sel_b equals to 1, input b would be driving the Out, when Sel_a and Sel_b equals to 2, input c would be driving the Out and when Sel_a and Sel_b equals to 3, input d would be driving Out. This is the functionality of the Design MUX. With the test input combination 0, 1 , 2 and 3 we check the functionality of the mux and we get 100% Functional Coverage but we have not exercised the statement default so our code coverage would be 85.75% (6/7 * 100). So with the code coverage percentage, we understand that we have not exercised certain Condition or codes of the Design. We improve our test environment to check whether our test case hits the default statement. Through this we get 100% code coverage and a proof that we have verified the RTL thoroughly.
Coverage obtained through Assertion is always Functional Coverage as we check the property of the Design. Code Coverage is checking how good is your testcase and how much RTL is exercised.
So, we conclude that Verification is DONE when we hit 100% Functional and Code Coverage.
About Author:
Jeyanthi Arumugam
Senior Design Engineer in Freescale, Noida
URL: http://vlsi-core.blogspot.com/2008/12/code-and-functional-coverage-why-both.html
2 comments:
Jeyanthi,Bravo...
But tell me if my IP is well defined in terms of functionality..ie I have complete list of functionality the IP under verification has to support.
Wont a good functional coverage ie 99 -100 % be more appropriate than code coverage.Cant i do trade off between code coverage and functional coverage. In a way I am consciously allowing untested rtl in final `product` knowing that it wont be used ever in real time scenario.
Thanks Shakthi, as I mentioned that functionality can be easily achieved than exercing all the codes of the RTL. Here in 4:1 mux, through the testcase we have exercised all the functionality but we have not exercised the condiftion when sel_a and sel_b is X, through this we are verifiying the Default condition and making sure that there are no deadcodes in the design. Functionality can be easily achieved through few testcase but code coverage informs the percentage of lines exercised by the verification environment and proves that there are no deadcodes and hence its early detection of bug.
Post a Comment