From 99cf981c2f048da1a15b6c17b7884c6c2ac818b0 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 4 Sep 2008 09:43:53 -0400 Subject: [PATCH] Support coverage under SystemPerl 1.285 and newer. --- Changes | 2 ++ bin/verilator | 28 +++++++++++++++++++--------- src/V3EmitMk.cpp | 1 + 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Changes b/Changes index cc45a422b..da48087e5 100644 --- a/Changes +++ b/Changes @@ -16,6 +16,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Add IMPERFECTSCH warning, disabled by default. +**** Support coverage under SystemPerl 1.285 and newer. + **** Fix stack overflow on large ? : trees. [John Sanguinetti] * Verilator 3.670 2008/07/23 diff --git a/bin/verilator b/bin/verilator index 559492c98..314cfd21e 100755 --- a/bin/verilator +++ b/bin/verilator @@ -296,7 +296,7 @@ functions to avoid error C1061. =item --coverage -Enables all forms of coverage, alias for --coverage-line, --coverage-user +Enables all forms of coverage, alias for --coverage-line, --coverage-user. =item --coverage-line @@ -308,10 +308,6 @@ Coverage. At each such branch a unique counter is incremented. At the end of a test, the counters along with the filename and line number corresponding to each counter are written into logs/coverage.pl. -After running multiple tests, the vcoverage utility (from the SystemPerl -package) is executed. Vcoverage reads the logs/coverage.pl file(s), and -creates an annotated source code listing showing code coverage details. - Verilator automatically disables coverage of branches that have a $stop in them, as it is assumed $stop branches contain an error check that should not occur. A /*verilator coverage_block_off*/ comment will perform a @@ -321,10 +317,6 @@ Note Verilator may over-count combinatorial (non-clocked) blocks when those blocks receive signals which have had the UNOPTFLAT warning disabled; for most accurate results do not disable this warning when using coverage. -For an example, after running 'make test' in the Verilator distribution, -see the test_sp/logs/coverage_source directory. Grep for lines starting -with '%' to see what lines Verilator believes need more coverage. - =item --coverage-user Enables user inserted functional coverage. Currently, all functional @@ -2103,6 +2095,24 @@ Verilator makes standard VCD (Value Change Dump) files. They are viewable with the public domain Dinotrace or GtkWave programs, or any of the many commercial offerings. +=item How do I do coverage analysis? + +Verilator supports both block (line) coverage and user inserted functional +coverage. First, run verilator with the --coverage option. If you're +using your own makefile, compile the model with the GCC flag +-DSP_COVERAGE_ENABLE (if using Verilator's, it will do this for you.) + +Run your tests in different directories. Each test will create a +logs/coverage.pl file. + +After running all of your tests, the vcoverage utility (from the SystemPerl +package) is executed. Vcoverage reads the logs/coverage.pl file(s), and +creates an annotated source code listing showing code coverage details. + +For an example, after running 'make test' in the Verilator distribution, +see the test_sp/logs/coverage_source directory. Grep for lines starting +with '%' to see what lines Verilator believes need more coverage. + =item Where is the translate_off command? (How do I ignore a construct?) Translate on/off pragmas are generally a bad idea, as it's easy to have diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index b7bf3df0d..995a3d426 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -46,6 +46,7 @@ public: of.putsHeader(); of.puts("\n"); + of.puts("VM_COVERAGE = "); of.puts(v3Global.opt.coverage()?"1":"0"); of.puts("\n"); of.puts("VM_TRACE = "); of.puts(v3Global.opt.trace()?"1":"0"); of.puts("\n"); of.puts("\n");