Repository navigation
Description
PR #1883 received an equality review finding:
#1883 (comment)
The finding requests comparing only the active payload, ignoring unused bits.
The observed behavior is reproducible, but the requested language semantics
need confirmation before changing the implementation. This is an investigation,
not yet a confirmed conformance defect.
Reproducer (four-state simulation, tested against 7eae8d9):
module Top;
typedef union tagged packed { void Empty; logic [7:0] Full; } item_t;
item_t a, b;
initial begin
a = tagged Empty;
b = tagged Empty;
// Observed: logical equality is X; case equality is 1.
if ((a == b) !== 1'bx) $fatal(1, "logical equality was not X");
if ((a === b) !== 1'b1) $fatal(1, "case equality was not true");
end
endmoduleBoth observations were checked using Simulation::from_sv_sources(...).four_state(true).
Constructors fill unused payload bits with X and comparisons currently operate
on the packed representation. The review expects (a == b) to be true instead.
Specification evidence checked in the locally supplied IEEE 1800-2023:
- 7.3.1 describes treating a packed union primary as a vector.
- 7.3.2 defines tag/payload layout and says the space between the tag and the
active member is undefined; a void member has no significant payload. - 11.4.5 describes bitwise equality and an X result when unknown bits make
logical equality ambiguous. - No rule requiring active-payload-only equality was found in the passages
checked. This does not establish that no applicable exception exists.
Verilator 5.052 and Icarus 13.0 reject this tagged-union syntax in the available
external adapters, so they cannot settle this discrepancy.
Resolution criteria:
- Identify the applicable rule for packed tagged unions (including whether
it overrides ordinary packed-vector equality), with an exact clause. - Cover void, shorter and nested members, unknown/invalid tags, and all four
equality operators (==,!=,===,!==). - If active-payload equality is required, implement it without dropping or
duplicating operand side effects. Otherwise document the review finding as
not a defect and retain a specification-backed regression.
Equality behavior remains unchanged in #1883 while this is investigated. The
other two findings from the same review (output-port concatenations and typed
default arguments) are implemented in commit 4810a3e9cc of that PR.
Activity
feat(sv): support tagged packed unions
feat(sv): support tagged packed unions
feat(sv): support tagged packed unions
feat(sv): support tagged packed unions