Skip to content

Support Real literal patterns in BSV - #13

Open
nanavati wants to merge 1 commit into
pattern-match-neglitfrom
pattern-match-checking
Open

nanavati wants to merge 1 commit into
pattern-match-neglitfrom
pattern-match-checking

Conversation

@nanavati

@nanavati nanavati commented Aug 16, 2026

Copy link
Copy Markdown
Owner

Summary

PR 3 of 3, stacked on #15 (negative literals), which stacks on #14
(core pattern-match checking). One commit; the diff shown is exactly
the Real-literal change. (This PR originally carried the whole series;
it was re-based as the top of the stack when the series split into
three PRs.)

The BSV parser rejected a real literal in a pattern
(EUnsupportedNumReal), while the Classic parser accepted one; the
elaboration path they share already implements literal patterns as
equality filters, and the closed Prelude instance defines Real equality
exactly. Accept the literal and let the usual desugaring apply. As
everywhere else in the language, matching a Real compares by numeric
equality, so 0.0 matches -0.0 (and a negated real literal pattern
matches the negated value); a design that wants approximate comparison
still writes a guard.

The pattern checker already treats Real as an unbounded literal domain,
so Real matches participate in exhaustiveness and redundancy checking;
a custom RealLiteral target remains locally opaque.

Testing

  • Builds independently; bsc.real/evaluator passes (PatternReal
    elaboration test including -1.5 and signed-zero cases) and the
    patterncheck suite passes all 92 checks at this tip, including
    RealPatterns (numeric equality, signed zero, closed Integer-to-Real
    conversion, opaque custom RealLiteral targets).
  • This commit is the tip of the verified stack: the tree is
    byte-identical to the state that passed the full testsuite
    (20,338 PASS / 134 XFAIL, zero regressions).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rtt7rnnXC8DShYHhMXmpCG

The BSV parser rejected a real literal in a pattern (EUnsupportedNumReal),
while the Classic parser accepted one; the elaboration path they share
already implements literal patterns as equality filters, and the closed
Prelude instance defines Real equality exactly.  Accept the literal and
let the usual desugaring apply.  As everywhere else in the language,
matching a Real compares by numeric equality, so 0.0 matches -0.0 (and
a negated real literal pattern matches the negated value); a design
that wants approximate comparison still writes a guard.

The pattern checker already treats Real as an unbounded literal domain,
so Real matches participate in exhaustiveness and redundancy checking;
a custom RealLiteral target remains locally opaque.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rtt7rnnXC8DShYHhMXmpCG
@nanavati nanavati changed the title Pattern-match exhaustiveness and redundancy checking (T0165/T0166) Support Real literal patterns in BSV Aug 16, 2026
@nanavati
nanavati changed the base branch from main to pattern-match-neglit August 16, 2026 08:45
nanavati pushed a commit that referenced this pull request Aug 22, 2026
…y flip)

The v1 delay refusal becomes a build-mode selection: a model whose
--timing inspection dump shows delay constructs verilates with --timing
(verilated_timing.o joins the model objects; the shim compiles with the
same coroutine flag Verilator's own objects use), everything else stays
--no-timing.  SHIMGEN_REV 3 -> 4 with one new ABI entry, vlt_advance:
for timing models it drains internal delayed events strictly before the
target instant -- one eval at each drained slot's own time -- and
reports the drained count; for delay-free models it is a plain time
set.  BviPrim advances time through it at every observation frontier
and commit point (including slices that stage nothing for the
instance), so delayed NBAs land between the kernel's timeslices exactly
where the reference simulators put them.  A drain legitimately changes
outputs with no input change, so it resets the observe-mode snapshots;
TRS_BVI_CHECK=observe stays sound and quiet on timing models.

New differential PosDelay (DelayIP.v: #3/#12/#13 NBAs straddling the
clock period) is byte-exact against the iverilog oracle interpreted,
as a compiled artifact, and under observe mode.  The r3 delay-refusal
check flips to a timing-build positive on both metadata adapters.

Gates: bvi r2 15/15, r3 13/13 (incl. JSON leg on 5.050), r4 4/4,
r5 16/16, regress 22/22, cargo tests clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants