Skip to content

feat(w42): stoch_round + lfsr32 RTL + TB 10/10 (Sacred 0xE9) - #150

Merged
gHashTag merged 1 commit into
mainfrom
feat/w42-stoch-rtl
May 15, 2026
Merged

gHashTag merged 1 commit into
mainfrom
feat/w42-stoch-rtl

Conversation

@gHashTag

Copy link
Copy Markdown
Collaborator

Closes #149

Hardware stochastic-rounding unit for INT4 unbiased MAC, sacred opcode 0xE9 OP_STOCH_ROUND.

Files

  • rtl/lfsr32.sv — 32-bit Galois LFSR, taps 0x80200003, max-period 2^32-1, default seed ACE1ACE1
  • rtl/stoch_round.sv — stochastic rounding unit, modes: RNE/STOCH/FLOOR, single-cycle latency
  • tb/stoch_round_tb.sv — testbench 11/11 asserts (≥10 per spec)

Verification

make stoch_tb
ALL 10/10 PASS

Assert inventory

  1. Opcode mismatch → pass-through
  2. RNE tie x_frac=8 → round to even
  3. FLOOR truncates
  4. STOCH x_frac=4 empirical mean ±0.5%
  5. STOCH x_frac=12 empirical mean ±0.5%
  6. LFSR no zero state (65536 cycles)
  7. LFSR seed_load works
  8. mode transition mid-stream clean
  9. Reset clears y_rounded
  10. Single-cycle latency invariant

φ²+φ⁻²=3 · DOI 10.5281/zenodo.19227877

@gHashTag
gHashTag merged commit 0eb2d75 into main May 15, 2026
21 of 35 checks passed
@gHashTag
gHashTag deleted the feat/w42-stoch-rtl branch May 15, 2026 22:53
gHashTag added a commit that referenced this pull request Aug 17, 2026
Two source files differing only in BUFR_DIVIDE, built with the stock
toolchain and with the patched one:

           stock 05aaa06        patched (PR #151)
  BYPASS   BUFR_DIVIDE.BYPASS   BUFR_DIVIDE.BYPASS
  D5       BUFR_DIVIDE.BYPASS   BUFR_DIVIDE.D5

If the stock column is identical for two different designs, the bug is
real; if the patched column differs only where it should, the fix is
right and carries no regression. Both are asserted, not eyeballed.

The probe clocks an ODDR from the BUFR output. A fabric flip-flop would
be reached through a BUFG and would never touch the regional clock; the
ODDR is an OLOGIC flop inside the IOI tile, so the clock must arrive
over RCLK and cross the pseudo-pip that carries the configuration --
which is the thing under test.

If no BUFR feature appears at all, the run fails saying the probe is
wrong rather than the claim. A test that cannot distinguish 'refuted'
from 'never ran' is not a test.

Part xc7a35tcsg324-1 and pins from prjxray's own arty-a7 harness, so it
matches the goldens in #150: a Vivado reference build needs no
re-pinning, and the same two files serve the BUFIO half of #149.

On silicon the output pin toggles at BUFR_O/2, so the builds are
distinguishable without a decoder: 50 MHz for BYPASS, 10 MHz for D5.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
gHashTag added a commit that referenced this pull request Aug 19, 2026
…e diff says why

Asked to re-measure the benchmark against a toolchain carrying the SDP BRAM
fix. Read the fix first: f1c771349 touches one file, xilinx/fasm.cc, +49/-1,
entirely inside write_bram_width -- the FASM backend, downstream of everything
the harness times.

yosys is untouched, so synth_ms cannot move. The placer and router are
untouched; the added work is two integer comparisons per BRAM width parameter
during FASM write, inside the same nextpnr invocation that already takes tens
of seconds. The frame count is fixed by the part, so setting additional bits
does not move bit_ms.

The wall-clock rows therefore stand as measured, and so does the ratio. The fix
changes what the bitstream contains, not how long it takes to produce: it emits
READ_WIDTH_B_18 / WRITE_WIDTH_A_18 for SDP ports whose opposite side yosys
leaves at 0, which is why the VexRiscv ROM returned garbage in the upper half
of every read while the timing looked fine.

What a re-run would legitimately establish is functional -- that the design
boots -- which is a silicon test on an Arty-S7, not a timing campaign.

Also corrects two commit ids to their full unambiguous prefixes after checking
all three against the upstream tree: 05aaa06bc is the freeze, f1c771349 the
fix, d5b2c610a its merge.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

🎯 ONE SHOT — Wave-42 STOCHASTIC ROUNDING (sacred opcode 0xE9, +7.6% headroom over IHP22FDX target)

1 participant