Verilog: wildcards in case items depend on the case kind - #2123
Merged
Conversation
The case items of a plain case statement are compared using 4-state equality, per 1800-2017 section 12.5.1, i.e., x and z in a case item are not wildcards. Only casex and casez have wildcards: casez treats z (and ?) bits as wildcards, whereas casex treats x, z (and ?) bits as wildcards. The case items were previously masked irrespective of the kind of case statement, i.e., every case was treated like casex. This is now fixed: case_comparison receives the case kind and selects the wildcard bits accordingly, comparing the non-wildcard positions using 4-state equality (both aval and bval must match).
kroening
force-pushed
the
kroening/case-wildcard-fix
branch
from
August 29, 2026 19:22
9e1e8eb to
5a00bc8
Compare
tautschnig
approved these changes
Aug 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the KNOWNBUG introduced in #2122. Per IEEE 1800-2017 §12.5.1, the case items of a plain
casestatement are compared using 4-state equality (===):xandzin a case item are not wildcards. Onlycasexandcasezhave wildcards:caseztreatsz(and?) bits in a case item as wildcards.casextreatsx,z(and?) bits in a case item as wildcards.Previously the case items were masked irrespective of the kind of case statement, i.e., every
casewas effectively treated likecasex.Changes
src/verilog/verilog_synthesis.cpp:case_comparisonnow receives the case-statement kind and selects the wildcard bits accordingly (none forcase, z-only forcasez, x/z forcasex). Non-wildcard positions are compared using 4-state equality (bothavalandbvalmust match), which also correctly handles operands containingx/z. Added aPRECONDITIONon the case kind.src/verilog/verilog_synthesis_class.h: threaded the case kind throughcase_comparisonandsynth_case_values.regression/verilog/case/case_wildcard1.desc:KNOWNBUG→CORE.regression/verilog/case/case_wildcard2.{sv,desc}: new test locking in thecasexvscasezdistinction.Testing
make -C srcbuilds clean.make -C regression/verilog test: allcase/*.descpass, including both wildcard tests; no failures across the suite.make -C regression/ebmc testandmake -C regression/smv test: no failures.