question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cocotb verilator code coverage support

See original GitHub issue

Could you add verilator coverage support in the following file:

cocotb/share/lib/verilator/verilator.cpp

diff --git a/cocotb/share/lib/verilator/verilator.cpp b/cocotb/share/lib/verilator/verilator.cpp
index aff06d9..fc43374 100644
--- a/cocotb/share/lib/verilator/verilator.cpp
+++ b/cocotb/share/lib/verilator/verilator.cpp
@@ -84,5 +84,9 @@ int main(int argc, char** argv) {
     tfp->close();
 #endif
 
+#if VM_COVERAGE
+    VerilatedCov::write("coverage.dat");
+#endif
+
     return 0;
 }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sammy17commented, Aug 22, 2021

I noticed that even when I enable verilator code coverage with EXTRA_ARGS= --coverage, coverage.dat file is not getting generated even with the above fix (as mentioned in https://github.com/cocotb/cocotb/issues/2573#issuecomment-865454544).

After a quick debug I noticed that anything after vl_finish(__FILE__, __LINE__, ""); in cocotb/share/lib/verilator/verilator.cpp is not getting executed. So VerilatedCov::write("coverage.dat"); that was added for this issue never got executed and coverage.dat file was not dumped.

I was able to get the coverage file to be dumped by moving the VerilatedCov::write call right before vl_finish as below.

        // If there are no more cbAfterDelay callbacks,
        // the next deadline is max value, so end the simulation now
        if (next_time == static_cast<vluint64_t>(~0ULL)) {
#if VM_COVERAGE
            VerilatedCov::write("coverage.dat");
#endif
            vl_finish(__FILE__, __LINE__, "");
            break;
        } else {
            main_time = next_time;
        }
0reactions
lavanyajagancommented, Mar 4, 2020

https://github.com/cocotb/cocotb/pull/1479

Hope this is sufficient. Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simulator Support — cocotb 1.7.2 documentation
In general, cocotb can be used with any simulator supporting the ... To enable HDL code coverage, add Verilator's coverage option(s) to the...
Read more >
cocotb/Lobby - Gitter
Hi all, what's the current status of Verilator support now that v5 is out? Are any of the blockers for using Cocotb with...
Read more >
Tutorials — cocotb_coverage 1.0 documentation
coverage_section is a concept introduced in cocotb-coverage, that allows for separating the coverage code from the testbench code. It allows for packing the ......
Read more >
Frameworks and Methodologies — Open Source Verification ...
The most notable difference is that cocotb supports iverilog and verilator, while the only open source simulator supported by VUnit is GHDL.
Read more >
Recently Active 'cocotb' Questions - Stack Overflow
Code : @cocotb.test() async def test(dut) for i in . ... I am trying to modify the default python and run with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found