cocotb icon indicating copy to clipboard operation
cocotb copied to clipboard

Document code coverage collection

Open Divya2030 opened this issue 5 years ago • 12 comments

how can we find code coverage?

Divya2030 avatar Jan 29 '20 06:01 Divya2030

for functional coverage we can use cocotb-coverage https://github.com/mciepluc/cocotb-coverage but for code-coverage?

Divya2030 avatar Jan 29 '20 06:01 Divya2030

You want to do code coverage of python testbench or RTL?

themperek avatar Jan 29 '20 08:01 themperek

See https://cocotb.readthedocs.io/en/latest/building.html#envvar-COVERAGE If you want but don't get HDL code coverage with your simulator with this, you need to specify the simulator-specific extra arguments via https://cocotb.readthedocs.io/en/latest/building.html#var-EXTRA_ARGS

cmarqu avatar Jan 29 '20 09:01 cmarqu

See https://cocotb.readthedocs.io/en/latest/building.html#envvar-COVERAGE If you want but don't get HDL code coverage with your simulator with this, you need to specify the simulator-specific extra arguments via https://cocotb.readthedocs.io/en/latest/building.html#var-EXTRA_ARGS

thanks

Divya2030 avatar Jan 29 '20 11:01 Divya2030

That question has come up multiple times in the past. We should document the different types of "code coverage" (as discussed in this issue) and write a section on that in our docs.

imphil avatar Jan 29 '20 11:01 imphil

but how to see the percentage of code coverage

Divya2030 avatar Jan 29 '20 11:01 Divya2030

I feel like closing was a mistake. AFAIK there is no documentation on how to collect or view code coverage in either the CONTRIBUTING.md or the ReadTheDocs documentation.

ktbarrett avatar Jan 08 '21 15:01 ktbarrett

@ktbarrett we can find coverage using following python libraries:

  1. cocotb-coverage and https://github.com/JoseIuri/cocoTBCoverageView
  2. pyvsc coverage libraries and pyucis-viewer

Divya2030 avatar Jan 08 '21 16:01 Divya2030

So you were talking about HDL code coverage, not Python code coverage? If so we don't have documentation on that yet. We should point to those extensions at a minimum.

ktbarrett avatar Jan 08 '21 17:01 ktbarrett

Well, for HDL coverage, you only need extensions (such as cocotb-coverage) if you'd like to have (SystemVerilog-like) functional coverage, or want to drive your verificaton based on that. If you're only interested in things like line or toggle coverage, just use whatever functionality your simulator provides, cocotb is completely out of he picture here.

imphil avatar Jan 08 '21 17:01 imphil

Well, I'm using cocotb-test and iverilog. And I found an old tool called "covered" to do code coverage (HDL), but I couldn't make it work within the cocotb-test flow. The interesting thing is that I couldn't find a good way to collect code coverage using cocotb-test and iverilog, and no information about it either. If I succeed I'll share it, just to have one example for the future.

TomyPrudente avatar Mar 04 '23 03:03 TomyPrudente

I've been in trouble with displaying HDL code coverage (My design is Verilog code and my simulator is Iverilog), and I find this Issue. Is there anybody can find the way that can help getting HDL code coverage? I tried to do with "cocotb-coverage and https://github.com/JoseIuri/cocoTBCoverageView" but they do not work.

ttDuong282 avatar Apr 17 '24 02:04 ttDuong282