Skip to content

ternip: restore all three memories; add post-synthesis FakeRAM memory checks - #255

Merged
mguthaus merged 3 commits into
mainfrom
fakeram-memory-checks
Nov 24, 2026
Merged

mguthaus merged 3 commits into
mainfrom
fakeram-memory-checks

Conversation

@mguthaus

Copy link
Copy Markdown
Contributor

Problem

A memory can vanish during synthesis with no error, and synthesis then prunes the logic behind it. SYNTH_MEMORY_MAX_BITS doesn't catch it, because a memory with no storage is never inferred.

  • ternip: since ae7666b1 (2026-05-13, D 1024→2560), none of its three ternip_pipelined_mem instances matched a generate branch in ternip_pipelined_mem_fakeram.v, and the wrapper had no default branch. Every platform synthesized 0 macros and 2,399 flops (the memories alone hold 606,208 bits), so all ternip QoR since then is void.
  • floonoc (floonoc gets simplified away #254): an empty stub without (* blackbox *) had the same effect.

Changes

ternip

  • vector_registers 128×4096 → 8 × fakeram_512x128, one bank per register
  • tmatmul export 128×320 → 1 × fakeram_512x128
  • tmatmul import 4096×10 → flip-flops (SYNTH_MEMORY_MAX_BITS 16384 → 40960)
  • the wrapper now ends in $error
  • synth-verified on asap7, nangate45, sky130hd and gt2n: 9 macros each, asap7 flops 2,399 → 71,708
  • DECISIONS.md corrected; place-and-route results pending

tools/check_sram_usage.py (new): after synthesis, fails if a macro in ADDITIONAL_LEFS is never instantiated, if a count differs from sram/expected_macros.txt, or if flops fall below its floor. k8s builds run it and log the result (advisory only).

tools/check_sram_cfg.py (new, added to the lint-sram-lef CI workflow): checks for camelCase snap keys, since snake_case is silently ignored. The 9 existing asap7 cfgs with the bug are allowlisted, and the list can only shrink. It also checks that each cfg's macros match its committed LEFs.

tools/regenerate_sram.sh: refuses snake_case snap keys and fails on the wd_in direction bug.

generate-sram skill: new section "Memories that silently vanish", a mandatory post-synthesis check, and the stale template fixed (snap keys, fakeram_ names, per-platform cfg).

Follow-up

An audit of the other designs' memories is in progress. Its findings will set expected_macros.txt for each design.

…er flops)

Since ae7666b (2026-05-13, D 1024->2560) none of the three
ternip_pipelined_mem instances matched a branch in the fakeram wrapper,
and the wrapper had no default: no storage was instantiated and read data
was undriven, so every platform synthesized 0 macros, 0 memory flops and
a pruned datapath (2,399 flops total). All ternip QoR since then measured
that memoryless design.

Map the current shapes:
  vector_registers 128x4096 -> 8 x fakeram_512x128, one bank per register
  tmatmul export   128x320  -> 1 x fakeram_512x128
  tmatmul import   4096x10  -> flops (depth 10 below fakeram's minimum;
                               SYNTH_MEMORY_MAX_BITS 16384 -> 40960)
and end the generate block in $error so a config change can no longer
silently delete memory. fakeram_512x16 replaced by fakeram_512x128 in all
four cfgs and regenerated.

Synth-verified on asap7/nangate45/sky130hd/gt2n: 9 macros each; asap7
flops 2,399 -> 71,708. DECISIONS.md corrected (the old notes said the
array became flops; it had no storage at all).
Add a 'Memories that silently vanish' section from ternip (wrapper
generate branches with no default: 0 macros, 2,399 flops for six months)
and floonoc #254 (empty stub without (* blackbox *) dissolved by slang):
wrappers must end in an $error branch, stubs carry logic or a blackbox
attribute, shapes come from the actual config, and synth_stat.txt must
show the expected macro count, every LEF used, and plausible flops.
SYNTH_MEMORY_MAX_BITS does not catch a memory with no storage.

Also fix the template: camelCase snap keys (snake_case is silently
ignored), platform-neutral fakeram_ names, per-platform cfg +
tools/regenerate_sram.sh, wd_in direction check, gt2n.
tools/check_sram_usage.py <platform> <design>: reads synth_stat.txt
(top-module totals incl. submodules) and fails if any macro in the
design's ADDITIONAL_LEFS is never instantiated, a count differs from
sram/expected_macros.txt, or flops fall below its 'flops >=' floor. On
a synth_stat with ternip's macros removed it fails pointing at the
unused LEF, the symptom that went unnoticed May-Nov. Every k8s build now
runs it and prints the result (advisory, never fails the job).

tools/check_sram_cfg.py (added to the lint-sram-lef CI workflow): every
bsg_fakeram cfg uses camelCase snap keys (snake_case is silently ignored;
the 9 known asap7 cfgs are allowlisted until regenerated, and the list
can only shrink) and its macro set equals the committed LEFs.

tools/regenerate_sram.sh: refuses snake_case snap keys, fails if a
generated LEF has the wd_in direction bug, and points at the usage check.

ternip gets sram/expected_macros.txt (9 x fakeram_512x128, flops >=
40960); the generate-sram skill now walks through all three tools.
@mguthaus
mguthaus merged commit 6a2b3b4 into main Nov 24, 2026
1 check passed
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.

1 participant