Xiaobai practice run coverage from 0 to 100%

Table of contents

1. Preliminary preparation

2. Run the case and analyze the coverage

3. Replace the random seed to improve coverage

4. Analyze coverage again 

5. Write targeted incentives to increase coverage

6. Coverage to 100%


1. Preliminary preparation

Preparatory work includes verifying the construction of the environment, defining functional coverage, and preparing makefile scripts. Familiarize yourself with commonly used commands.

According to the custom makefile script, three commands are mainly used:

Task Order
run a case make comp elab run COV=1 TESTNAME=...
Merge Coverage make mergecov
Open DVE to analyze coverage make dvecov
Run case with sh script source ...

Note: Whether random seed + ntb_random_seed is given in the makefile, the random seed must be added, so that different random seeds will be generated when the same case is run multiple times.

To run a case with a sh script, you need to prepare a sh script in advance (convenient to run multiple cases at a time). Touch my_test1 in the terminal to create a document named my_test1. Generally, I am used to naming it my_test1 and my_test2. Put multiple cases and commands for merging coverage and opening DVE analysis in the document, and then source my_test1 in the terminal to automatically execute the following instructions.

A document controlled by an sh script

2. Run the case and analyze the coverage

Run a smoke test

 

Run a test with a different address

 Run a data test with different bit widths

 

 

 word misalignment test

 

 reset test

 

After running different cases, the coverage increases as shown in the table below

test

code coverage

Functional coverage

smoke test

71.34

20.07

different address

76.34

39.80

different width

79.68

52.30

word misalignment test

96.68

71.05

reset test

96.78

71.05

After the word misalignment test, the code coverage rate increased relatively quickly, mainly because the upper 16 bits of data were assigned for the first time in this case, and the assignments in the previous three cases were mainly in the lower 16 bits, so the code toggle of the higher bits of data was covered. But the coverage rate did not reach 100%, so we tried to change the random seed and run again.

3. Replace the random seed to improve coverage

In order to improve the coverage, you can change the random seed and run the middle three cases four more times (sh script can be used here), but the coverage improvement is not large, the code coverage remains unchanged, and the functional coverage increases from 71.05% to 72.37%.

4. Analyze coverage again 

So we analyze to see which places are not covered, first analyze the toggle of code coverage ;

  1. At this time, the toggles of HWDATA and HRDATA in certain positions have not been covered, and directional incentives can be written to cover them, and the values ​​​​of HWDATA are sent in sequence: 32'h0000_0000, 32'hFFFF_FFFF, 32'h0000_0000, to achieve 0->1,1->0 jump of each bit;
  2. HREADY, HREADYOUT can be excluded because the behavior of DUT is always 1;
  3. HRESP can be excluded because the designed DUT is always 0;
  4. HSELBRAM can give the initial value 1, set it to 0 in the non-blocking assignment in the reset task, and then set it to 1 when it is released;
  5. HTRANS does not have BUSY and SEQ states because DUT does not support burst transmission, so it can be excluded;

Then analyze the functional coverage:

 It can be seen that the random address has not reached addr_end many times, and the boundary address is difficult to cover, so a directional incentive should be written to cover the boundary address. At the same time, it is found that the illegal address is not covered, because we have no incentive to write illegal addresses, so we write another seq, which covers these three points.

Note: The main exclusion should be the inevitable and impossible situation caused by the designed behavior.

5. Write targeted incentives to increase coverage

Write directional stimuli to satisfy the toggle for HWDATA and HRDATA.

 Write directional stimuli to satisfy functional coverage

Note: newly write seq, test, and the two sv files must be put into the header file svh, and mount the corresponding seq in test.

6. Coverage to 100%

Put the two newly written tests into another document my_test2.

 After re-running the targeted incentives, import the previously excluded files, and finally found that the functional coverage and code coverage both reached 100%

Guess you like

Origin blog.csdn.net/weixin_55225128/article/details/127880312