From c62546c7618b51001cfd061109d31e70b6292787 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 29 Mar 2021 18:54:51 -0400 Subject: [PATCH] Add --coverage-max-width (#2853). --- Changes | 1 + bin/verilator | 7 +++++++ src/V3Coverage.cpp | 5 +++-- src/V3Options.cpp | 1 + src/V3Options.h | 2 ++ test_regress/t/t_cover_toggle.pl | 2 ++ test_regress/t/t_cover_toggle.v | 2 +- test_regress/t/t_cover_toggle_width.pl | 26 ++++++++++++++++++++++++++ 8 files changed, 43 insertions(+), 3 deletions(-) create mode 100755 test_regress/t/t_cover_toggle_width.pl diff --git a/Changes b/Changes index 84ca20cbd..f4d7990b4 100644 --- a/Changes +++ b/Changes @@ -17,6 +17,7 @@ Verilator 4.201 devel * Changed TIMESCALEMOD from error into a warning. * Verilated signals now use VlWide and VlPacked in place of C arrays. * Mark --no-relative-cfuncs as scheduled for deprecation. +* Add --coverage-max-width (#2853). [xuejiazidi] * Add VerilatedCovContext::forcePerInstance (#2793). [Kevin Laeufer] * Fix class unpacked-array compile error (#2774). [Iru Cai] * Fix exceeding command-line ar limit (#2834). [Yinan Xu] diff --git a/bin/verilator b/bin/verilator index ee0dbeab6..31879c192 100755 --- a/bin/verilator +++ b/bin/verilator @@ -313,6 +313,7 @@ arguments. --converge-limit Tune convergence settle time --coverage Enable all coverage --coverage-line Enable line coverage + --coverage-max-width Maximum array depth for coverage --coverage-toggle Enable toggle coverage --coverage-user Enable SVL user coverage --coverage-underscore Enable coverage of _signals @@ -697,6 +698,12 @@ 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. +=item --trace-max-width I + +Rarely needed. Specify the maximum bit width of a signal that is subject +to toggle coverage. Defaults to 256, as covering large vectors may greatly +slow coverage simulations. + =item --coverage-toggle Specifies signal toggle coverage analysis code should be inserted. diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index d7aee3ee0..b2fa737d3 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -96,8 +96,9 @@ private: if (prettyName[0] == '_') return "Leading underscore"; if (prettyName.find("._") != string::npos) return "Inlined leading underscore"; } - if ((nodep->width() * nodep->dtypep()->arrayUnpackedElements()) > 256) { - return "Wide bus/array > 256 bits"; + if ((nodep->width() * nodep->dtypep()->arrayUnpackedElements()) + > static_cast(v3Global.opt.coverageMaxWidth())) { + return "Wide bus/array > --coverage-max-width setting's bits"; } // We allow this, though tracing doesn't // if (nodep->arrayp(1)) return "Unsupported: Multi-dimensional array"; diff --git a/src/V3Options.cpp b/src/V3Options.cpp index cbbc25cc9..244d890d0 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -1237,6 +1237,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char DECL_OPTION("-coverage", CbOnOff, [this](bool flag) { coverage(flag); }); DECL_OPTION("-converge-limit", Set, &m_convergeLimit); DECL_OPTION("-coverage-line", OnOff, &m_coverageLine); + DECL_OPTION("-coverage-max-width", Set, &m_coverageMaxWidth); DECL_OPTION("-coverage-toggle", OnOff, &m_coverageToggle); DECL_OPTION("-coverage-underscore", OnOff, &m_coverageUnderscore); DECL_OPTION("-coverage-user", OnOff, &m_coverageUser); diff --git a/src/V3Options.h b/src/V3Options.h index ad522f373..7cb64f2ea 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -283,6 +283,7 @@ private: int m_buildJobs = 1; // main switch: -j int m_convergeLimit = 100; // main switch: --converge-limit + int m_coverageMaxWidth = 256; // main switch: --coverage-max-width int m_dumpTree = 0; // main switch: --dump-tree int m_gateStmts = 100; // main switch: --gate-stmts int m_ifDepth = 0; // main switch: --if-depth @@ -477,6 +478,7 @@ public: int buildJobs() const { return m_buildJobs; } int convergeLimit() const { return m_convergeLimit; } + int coverageMaxWidth() const { return m_coverageMaxWidth; } int dumpTree() const { return m_dumpTree; } bool dumpTreeAddrids() const { return m_dumpTreeAddrids; } int gateStmts() const { return m_gateStmts; } diff --git a/test_regress/t/t_cover_toggle.pl b/test_regress/t/t_cover_toggle.pl index e0feb7514..64324cf9d 100755 --- a/test_regress/t/t_cover_toggle.pl +++ b/test_regress/t/t_cover_toggle.pl @@ -21,6 +21,8 @@ execute( # Read the input .v file and do any CHECK_COVER requests inline_checks(); +file_grep_not("$Self->{obj_dir}/coverage.dat", "largeish"); + file_grep($Self->{stats}, qr/Coverage, Toggle points joined\s+(\d+)/i, 25) if $Self->{vlt_all}; diff --git a/test_regress/t/t_cover_toggle.v b/test_regress/t/t_cover_toggle.v index eb8e24ae2..a2920779f 100644 --- a/test_regress/t/t_cover_toggle.v +++ b/test_regress/t/t_cover_toggle.v @@ -62,7 +62,7 @@ module t (/*AUTOARG*/ reg [1:0] memory[121:110]; - reg [1023:0] largeish; + wire [1023:0] largeish = {992'h0, cyc}; // CHECK_COVER_MISSING(-1) always @ (posedge clk) begin diff --git a/test_regress/t/t_cover_toggle_width.pl b/test_regress/t/t_cover_toggle_width.pl new file mode 100755 index 000000000..f3823a558 --- /dev/null +++ b/test_regress/t/t_cover_toggle_width.pl @@ -0,0 +1,26 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003-2009 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(vlt => 1); + +top_filename("t/t_cover_toggle.v"); + +compile( + verilator_flags2 => ['--cc --coverage-toggle --coverage-max-width 1025'], + ); + +execute( + check_finished => 1, + ); + +file_grep("$Self->{obj_dir}/coverage.dat", "largeish"); + +ok(1); +1;