Commit Graph

9470 Commits

Author SHA1 Message Date
Matthew Ballance e5594e9c6c Fix constifyParamsEdit regression in visit(AstInsideRange*)
The original code called V3Const::constifyParamsEdit() in
V3Width::visit(AstInsideRange*) to fold negative bin bounds
(e.g., NEGATE(100) -> -100) for covergroup bins. Since
constifyParamsEdit uses m_required=true, it errored on any
non-constant expression -- breaking the upstream test
t_constraint_array_index_simple which uses a foreach loop
variable 'i' in an inside constraint expression.

Fix: Remove the unconditional constifyParamsEdit calls from
V3Width::visit(AstInsideRange*). Instead:
- In V3Width: when m_vup is null (covergroup bin context,
  not an expression context), use constifyEdit (m_required=false)
  to fold constant arithmetic before iterating children.
- In V3Covergroup: call constifyEdit at the two sites that
  cast InsideRange bounds to AstConst for bin expansion.

This moves the covergroup-specific concern to the right layer
(V3Covergroup) while keeping V3Width safe for all contexts.

Also update golden files for t_covergroup_trans_3value,
t_covergroup_trans_restart, and t_covergroup_with_sample_args_too_many_bad
whose line numbers shifted by 1 due to the SPDX copyright header
additions in the previous commit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:48 +00:00
Matthew Ballance 4c4d3e91bc Add missing SPDX-FileCopyrightText headers to covergroup test files
All new covergroup test files were missing the canonical
SPDX-FileCopyrightText line required by t_dist_copyright.
Add it above the existing SPDX-License-Identifier line in each file.
Also canonicalize t_covergroup_with_sample_args_too_many_bad.py to
use SPDX form instead of prose copyright comment.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:48 +00:00
Matthew Ballance ae10856ec0 Update golden files after rebase onto upstream/master
Upstream commit 07ed6aef5 'Tests: Verilog format' reformatted several
Verilog test files, shifting line/column numbers in compiler output.
Also pick up upstream's improved 'Too many arguments' error message
which now includes the declaration location.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:48 +00:00
Matthew Ballance b4ff2f7704 Fix non-ASCII characters in V3Covergroup.cpp comment
Replace Unicode em-dash and curly apostrophe with plain ASCII
equivalents to pass t_dist_whitespace CI check.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:48 +00:00
Matthew Ballance a18fdb1c4b Restore t_covergroup_with_sample_args_too_many_bad test
This test was added upstream in a364704e3 and should not have been
deleted. The driver normalizes version strings (?v=X.Y -> ?v=latest)
and 'Exiting due to...' messages, so the upstream .out file is
compatible with our branch's error output as-is.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:48 +00:00
Matthew Ballance 4eb676cb49 Convert 'if' tests to assertion macros
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
2026-04-05 21:10:48 +00:00
github action 7475dea9f3 Apply 'make format' 2026-04-05 21:10:48 +00:00
Matthew Ballance 06d34cc4cf Cleaned up coverpoint-bin warning around 'excessive size'
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
2026-04-05 21:10:48 +00:00
Matthew Ballance bcf6e6ac72 Update debug_emitv to include covergroup constructs ; update emit of covergroup debug content
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
2026-04-05 21:10:33 +00:00
Matthew Ballance 464be2c85b Test clean-ups, resolve an internal error masked by the checking strategy, and add 'automatic' to remove warnings
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
2026-04-05 21:10:33 +00:00
Matthew Ballance affe776463 t_covergroup_with_sample_args_too_many_bad: remove redundant test
'sample' argument count checking is generic function/task behavior
already covered by t_func_bad and similar tests. Removing this test
eliminates fragility from upstream error message/caret changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:33 +00:00
Matthew Ballance dda0405fce V3Covergroup: initialize bin counters to 0, not random
Coverage bin counters (__Vcov_* member variables) were being initialized
with VL_SCOPED_RAND_RESET_I because they are plain uint32 members with no
explicit initial value. This caused 0% coverage readings at runtime when
randReset != 0 (as used in CI).

Fix all 5 bin counter AstVar creation sites to set an explicit valuep of
AstConst(0), so V3EmitCFunc emits '= 0U' instead of VL_SCOPED_RAND_RESET_I.

Affects: regular bins, default bins, array bins, transition array bins,
and cross bins.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:33 +00:00
Matthew Ballance a3a456779d Fix V3Fork lifetime assertion by restoring V3LinkInc temp var lifetime
Commit b4244fc57 accidentally dropped the varp->lifetime(VLifetime::AUTOMATIC_EXPLICIT)
line when reverting V3LinkInc.cpp to a merge base. This caused __Vincrement* temp
variables to have VLifetime::NONE, triggering V3Fork's assertion that all variables
inside fork...join_none blocks have a known lifetime.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:33 +00:00
github action 83eb65a6c3 Apply 'make format' 2026-04-05 21:10:33 +00:00
Matthew Ballance 80502fd9ee Correct indent on coverage tests ; add required test drivers ; back out CMakeLists pch change and adjust test that required it to no longer need it
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
2026-04-05 21:10:33 +00:00
Matthew Ballance e347943e3b Whitespace fixes
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
2026-04-05 21:10:33 +00:00
Matthew Ballance ff9781fc73 Update golden file for covergroup fileline fix
The covergroup keyword fileline fix (using $<fl>1 instead of $<fl>2)
shifts error column from the name position to the 'covergroup' keyword.
Update the golden output for t_covergroup_in_class_duplicate_bad to match.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:33 +00:00
Matthew Ballance 80dd984780 Fix infinite recursion in visit(AstCovergroup*) and fileline
Two bugs in the covergroup -> AstClass transformation in V3LinkParse:

1. Infinite recursion: when a covergroup has a clocking event (e.g.
   `@(posedge clk)`), visit(AstCovergroup*) embeds a sentinel
   AstCovergroup node inside the new AstClass to carry the event for
   V3Covergroup.cpp. The subsequent iterate(cgClassp) call then visits
   the sentinel via visit(AstNodeModule*) -> iterateChildren -> which
   hits visit(AstCovergroup*) again, creating another class with another
   sentinel, infinitely.

   Fix: skip transformation in visit(AstCovergroup*) when already inside
   a covergroup class (m_modp->isCovergroup()), so sentinel nodes are
   left alone.

2. Wrong fileline column: AstCovergroup was created with the fileline of
   the identifier token ($<fl>2, the name position) rather than the
   'covergroup' keyword token ($<fl>1). This caused warnings about the
   covergroup to point to the name column instead of the keyword column.

   Fix: use $<fl>1 (the 'covergroup' keyword fileline) when constructing
   AstCovergroup in the parser.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:33 +00:00
Matthew Ballance 9a26843da8 Fix: move removeStd() to after V3LinkParse
V3LinkParse's visit(AstCovergroup) creates std:: references and calls
setUsesStdPackage(). The previous removeStd() call happened before
V3LinkParse ran, so it deleted the std package before those references
were created, causing:

  %Error: Package/class for ':: reference' not found: 'std'

Move removeStd() to immediately after V3LinkParse::linkParse() inside
process() so the std package is only pruned after all parse-time
transformations have had a chance to declare their std:: usage.

Fixes test failures:
  - t_covergroup_option
  - t_covergroup_with_sample_args_too_many_bad

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:33 +00:00
github action eba0dcdb37 Apply 'make format' 2026-04-05 21:10:33 +00:00
Matthew Ballance 15bcf7b2fb Parser clean-up
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
2026-04-05 21:10:33 +00:00
Matthew Ballance 10b590c6ac verilog.y: fix accidental DEL omissions for wait_order, expect, property case
Three node deletions were accidentally dropped from the initial covergroup
commit as collateral damage:
- wait_order (no-stmt variant): restore DEL($3) for vrdList
- expect (no-stmt variant): restore DEL($3) for property_spec
- property_exprCaseIf yIF/yELSE: restore DEL($3) for condition expr

In all three cases $3 is an AstNode* that is not assigned to $$ and would
be leaked without the deletion.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:32 +00:00
Matthew Ballance d9060bc9d3 Gate V3Covergroup pass on useCovergroup() flag
Add v3Global.useCovergroup() flag (following the useRandSequence()
pattern) that is set to true when a covergroup_declaration is parsed.
Gate the V3Covergroup::covergroup() pass in Verilator.cpp on this flag
so the pass is skipped entirely for designs with no covergroups.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:32 +00:00
Matthew Ballance 3aef029184 V3Covergroup: fix coverpoint cleanup for unsupported covergroups
Two bugs fixed:
1. AstCReset: mark as ineligible for coverage expressions via
   isExprCoverageEligible() override, preventing verilogForTree
   from being called on CReset nodes (which has no V3EmitV handler).

2. generateCrossCode: when a cross references an unknown coverpoint,
   don't delete the cross node early. The caller's cleanup loop
   (in visit(AstClass*)) is responsible for deleting all coverpoints
   and crosses. Early deletion left a dangling pointer in m_coverCrosses
   causing a use-after-free segfault.

3. hasUnsupportedEvent path: added coverpoint/cross cleanup before
   returning so AST nodes don't reach downstream passes (V3EmitCFunc,
   V3MergeCond) which no longer have stub visitors for them.

All 60 covergroup tests now pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:32 +00:00
Matthew Ballance 07f959d31d Refactoring node locations and enums ; Delete coverpoints after V3Covergroup so they don't accidentally hit the generators
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
2026-04-05 21:10:32 +00:00
github action 30ca516362 Apply 'make format' 2026-04-05 21:10:32 +00:00
Matthew Ballance 1ee88a0c79 Revert V3Coverage.cpp to funccov-minimal merge base
The VLifetime::AUTOMATIC_EXPLICIT addition is not required for
functional coverage — all 60 covergroup tests pass without it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:32 +00:00
Matthew Ballance 5ef2a2956d Revert V3EmitV.cpp and V3LinkInc.cpp to funccov-minimal merge base
These changes are not required for functional coverage support and
should not be included in the upstream patch.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:10:32 +00:00
Matthew Ballance 17eaa5514b Adopt use of MemberMap
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
2026-04-05 21:09:39 +00:00
Matthew Ballance 6c443b7662 Rename funccov tests to covergroup
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
2026-04-05 21:09:39 +00:00
Matthew Ballance c749ff09b4 Refactoring before renaming tests
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
2026-04-05 21:09:39 +00:00
github action 43bfd85dc0 Apply 'make format' 2026-04-05 21:08:58 +00:00
Matthew Ballance 7bc6d8a602 CMake: detect PCH include flag for GCC/Clang in verilated.mk
Without this, CFG_CXXFLAGS_PCH_I was left empty in CMake builds, causing
GCC to treat the PCH filename as a linker input instead of applying it as
a -include flag, breaking compilation of any model that uses PCH.

This is a general CMake build fix (not funccov-specific); the same bug
exists in upstream CMakeLists.txt. It is included here because funccov's
cross-coverage tests expose the issue.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:08:58 +00:00
Matthew Ballance 20970c7dde Add function coverage (funccov) and covergroup support
Implement functional coverage collection via covergroups, coverpoints,
and cross coverage bins. Introduces V3CoverageFunctional pass and
verilated_funccov.h runtime support.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 21:08:09 +00:00
Wilson Snyder 9f4546fcb9
Fix constraint 'with' in parameter classes (#7375) 2026-04-04 21:03:44 -04:00
Wilson Snyder 5b9cd12530 Internals: Remove mutex, part of last commit 2026-04-04 18:10:47 -04:00
Wilson Snyder 33493cf5b4 Add `+verilator+solver+file` (#7242).
Fixes #7242.
2026-04-04 17:26:43 -04:00
Wilson Snyder 2796294396 Fix string `inside` queue (#7373).
Fixes #7373.
2026-04-04 14:43:06 -04:00
Wilson Snyder 94f3e16a6c Commentary: Changes update 2026-04-04 14:42:11 -04:00
github action 4b6bc1ff83 Apply 'make format' 2026-04-04 18:32:27 +00:00
Yilou Wang 3b454a6f60 Internals: Add isNonPackedArray(). No functional change. (#7334 prep) 2026-04-04 14:31:09 -04:00
Yilou Wang adb48046c2
Fix parameter default comparison when value contains type cast (#6281) (#7369)
Fixes #6281.
2026-04-04 11:02:20 -04:00
Wilson Snyder de8d3c9356 Commentary: Changes update 2026-04-03 20:16:23 -04:00
Wilson Snyder 00bf59ac92 Internals: Cleanup some V3Simulate branches. No functional change intended. 2026-04-03 20:16:10 -04:00
Wilson Snyder ed0506ea8d Internals: Use Var flag instead of magic names. No functional change intended. 2026-04-03 19:05:56 -04:00
Yilou Wang efd60df2be
Fix virtual interface select from sub-interface instance (#7203) (#7370)
Fixes #7203.
2026-04-03 19:04:10 -04:00
em2machine e7a644a3fc
Fix functions in generate block resulting in "Broken link in node" (#7236) (#7367)
Fixes #7236
2026-04-03 11:19:17 -04:00
Yilou Wang 56ed47ee7c
Fix false ASSIGNIN on interface input port connections (#7365)
* add oneline fix

* Apply 'make format'

* merge test and update 2 space indents

---------

Co-authored-by: github action <action@example.com>
2026-04-02 20:44:48 +02:00
Yilou Wang 1e5c93cc51
Fix virtual interface function calls binding to wrong instance (#7363) 2026-04-02 10:53:01 -04:00
em2machine 32672deb6f
Fix resolving default/nondefault type parameters (#7171) (#7346)
Fixes #7171
2026-04-02 10:51:11 -04:00