From a23cf1ceea79055de4c6f0de1e7d5860adb6adcb Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 8 Feb 2024 19:21:44 -0500 Subject: [PATCH] Fix toggle coverage dataDeclp error on multi-edge driven signals. --- Changes | 1 + src/V3AstNodeOther.h | 2 +- src/V3CoverageJoin.cpp | 5 +++- src/V3DupFinder.cpp | 1 + test_regress/t/t_cover_toggle.pl | 2 +- test_regress/t/t_interface_array2_coverage.pl | 24 +++++++++++++++++++ .../t/t_interface_modport_coverage.pl | 24 +++++++++++++++++++ 7 files changed, 56 insertions(+), 3 deletions(-) create mode 100755 test_regress/t/t_interface_array2_coverage.pl create mode 100755 test_regress/t/t_interface_modport_coverage.pl diff --git a/Changes b/Changes index 701761dbe..2db67edda 100644 --- a/Changes +++ b/Changes @@ -46,6 +46,7 @@ Verilator 5.021 devel * Fix $fwrite of null (#4862). [Jose Tejada] * Fix GCC tautological-compare warnings. * Fix compile error on structs with queues (and ignore toggle coverage on queues). +* Fix toggle coverage dataDeclp error on multi-edge driven signals. Verilator 5.020 2024-01-01 diff --git a/src/V3AstNodeOther.h b/src/V3AstNodeOther.h index 97455091a..d0f12bda8 100644 --- a/src/V3AstNodeOther.h +++ b/src/V3AstNodeOther.h @@ -2653,7 +2653,7 @@ public: const char* broken() const override { if (m_dataDeclp && (m_dataDeclp == this || m_dataDeclp->m_dataDeclp)) { // Avoid O(n^2) accessing - v3fatalSrc("dataDeclp should point to real data, not be a list"); + v3fatalSrc("dataDeclp should point to real data, not be a list: " << cvtToHex(this)); } return nullptr; } diff --git a/src/V3CoverageJoin.cpp b/src/V3CoverageJoin.cpp index a0e609083..a270d2f92 100644 --- a/src/V3CoverageJoin.cpp +++ b/src/V3CoverageJoin.cpp @@ -48,6 +48,8 @@ class CoverageJoinVisitor final : public VNVisitor { V3DupFinder dupFinder; // Duplicate code detection // Hash all of the original signals we toggle cover for (AstCoverToggle* nodep : m_toggleps) dupFinder.insert(nodep->origp()); + if (dumpLevel() || debug() >= 9) + dupFinder.dumpFile(v3Global.debugFilename("coveragejoin") + ".hash", false); // Find if there are any duplicates for (AstCoverToggle* nodep : m_toggleps) { // nodep->backp() is null if we already detected it's a duplicate and unlinked earlier @@ -85,7 +87,8 @@ class CoverageJoinVisitor final : public VNVisitor { } // VISITORS - void visit(AstNetlist* nodep) override { + void visit(AstActive* nodep) override { + m_toggleps.clear(); // Find all Coverage's iterateChildren(nodep); // Simplify diff --git a/src/V3DupFinder.cpp b/src/V3DupFinder.cpp index 9d3eec9a0..af3aec54a 100644 --- a/src/V3DupFinder.cpp +++ b/src/V3DupFinder.cpp @@ -53,6 +53,7 @@ V3DupFinder::iterator V3DupFinder::findDuplicate(AstNode* nodep, V3DupFinderUser } void V3DupFinder::dumpFile(const string& filename, bool tree) { + UINFO(2, "Dumping " << filename << endl); const std::unique_ptr logp{V3File::new_ofstream(filename)}; if (logp->fail()) v3fatal("Can't write " << filename); diff --git a/test_regress/t/t_cover_toggle.pl b/test_regress/t/t_cover_toggle.pl index 45cfb4989..44f3b0c15 100755 --- a/test_regress/t/t_cover_toggle.pl +++ b/test_regress/t/t_cover_toggle.pl @@ -23,7 +23,7 @@ inline_checks(); file_grep_not("$Self->{obj_dir}/coverage.dat", "largeish"); -file_grep($Self->{stats}, qr/Coverage, Toggle points joined\s+(\d+)/i, 25) +file_grep($Self->{stats}, qr/Coverage, Toggle points joined\s+(\d+)/i, 23) if $Self->{vlt_all}; run(cmd => ["../bin/verilator_coverage", diff --git a/test_regress/t/t_interface_array2_coverage.pl b/test_regress/t/t_interface_array2_coverage.pl new file mode 100755 index 000000000..184f7f8bb --- /dev/null +++ b/test_regress/t/t_interface_array2_coverage.pl @@ -0,0 +1,24 @@ +#!/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 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(simulator => 1); + +top_filename("t/t_interface_array2.v"); + +compile( + v_flags2 => ["--coverage"], + ); + +execute( + check_finished => 1, + ); + +ok(1); +1; diff --git a/test_regress/t/t_interface_modport_coverage.pl b/test_regress/t/t_interface_modport_coverage.pl new file mode 100755 index 000000000..2b42c5830 --- /dev/null +++ b/test_regress/t/t_interface_modport_coverage.pl @@ -0,0 +1,24 @@ +#!/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(simulator => 1); + +top_filename("t/t_interface_modport.v"); + +compile( + verilator_flags2 => ["-fno-inline --coverage"], + ); + +execute( + check_finished => 1, + ); + +ok(1); +1;