RouteRTL FPGA-Friendly RTL Rules
RouteRTL enforces "write HDL that maps well to silicon" as a layered system, not a single linter. Each layer has a distinct job; together they take a rule from human rationale down to measured silicon.
The enforcement stack
| Layer | What it is | Where |
|---|---|---|
| 1. Knowledge / judgment | The fpga-rtl-design skill — human-readable rationale for every rule (the why: the silent failure or wasted resource), with a pointer to its enforcement and its evidence (Haz.N / H.N). Read before writing. | skill |
| 3. Structural (CDC/RDC) | SV-Gap / Yosys — a manifest.toml generated from ip.yml, run in the background; reports coverage (source counts, clocks/crossings) so a green run is not mistaken for full CDC sign-off. | profile rr-cdc-structural-provisional |
| 3b. Pre-route CDC gate | rr cdc check — elaborates the design and reconciles discovered crossings against the cdc.yml ledger + checked-in constraint coverage; enforces by exit code, no vendor tool, any backend. Complements (never replaces) the post-route vendor report. | rr cdc check, CDC Signoff |
| 4. Formal | rr formal — PSL (VHDL) / SVA property proofs via GHDL→yosys→SymbiYosys (k-induction). | rr formal run --contract |
| 5. Empirical ground truth | OOC synth / impl utilization + timing reports — the ultimate check. The rules predict ("this should be a BRAM"); synth confirms (RAMB count). | rr synth/impl run --ooc |
Design principle — severity is calibrated to false-positive risk. A mechanical rule
that would nag correct code ships as info / review (suppressible, Spyglass-style),
not a hard error. Only rules that detect an unambiguous silicon bug are promoted to
error (build-gating). This is why the same family spans info → error.
Opt-out: a line pragma -- rr-lint-disable-line RR-XXX-NNN suppresses a specific
finding where the author has reviewed and accepts it.
The RR-* catalog
VHDL interface conformance — RR-VHDL-*
RR-VHDL-001 · error (build-gating) · Component declaration differs from its entity.
For every component whose same-named entity is present in the linted source set, compares
the ordered generic and port names, modes, and subtypes across files. This catches stale
component copies that remain syntactically valid but fail during elaboration or bind the
wrong interface. Fix the duplicated declaration or use direct entity instantiation
(entity work.<name>) so the compiler owns the contract. Components for external entities
and ambiguous same-named entities are left alone.
Memory inference — RR-MEM-*
RR-MEM-001 · info (advisory) · FF-matrix anti-pattern. A large registered array that should infer as Block RAM but is coded so it maps to a flip-flop matrix + LUT mux instead. Stays quiet when you follow the inferrable-RAM template: one write port, a synchronous registered read, no asynchronous read, no array-wide reset. Fix: register the read (present the address one cycle early), drop the array-wide reset (use an epoch/generation tag if you need a fast clear). Why info: the FF form is legal and sometimes intended (small arrays); this is a nudge, not a defect.
RR-MEM-002 · warning · >2 runtime read ports on a large array. Structural complement to RR-MEM-001: a Block RAM has at most 2 ports, so a large array read under more than 2 distinct runtime index expressions cannot map to a single BRAM — it replicates into extra BRAMs or LUT-heavy distributed RAM, even when every read is registered. Fix: time-multiplex the reads onto ≤2 ports, or accept the replication deliberately. (Constant-indexed taps do not count — only runtime indices.)
Arithmetic cost — RR-ARITH-*
RR-ARITH-001 · warning · Runtime or non-power-of-2 division.
A / or mod by a runtime value, or by a constant that is not a power of two, infers a
multi-cycle divider or a wide combinational network. Fix: a lookup ROM for a small bounded
operand, a reciprocal-multiply, or constant-fold; power-of-2 divides are free shifts.
RR-ARITH-002 · warning · runtime × runtime multiply. A multiply where both operands are runtime signals consumes a DSP (or a large LUT network) — flagged so it is a deliberate choice, not an accident. Fix: confirm a DSP is intended and sized to pack; if one operand is constant, it folds much cheaper.
Clocking — RR-CLK-*
RR-CLK-001 · error (build-gating) · Combinational clock gating.
A clock net driven by combinational logic (gated <= clk and en; ... rising_edge(gated))
is a hard silicon bug: glitches on the enable become spurious clock edges, and the path
clock-enable on the FF, or a proper BUFGCE/clock-gating cell. Opt out only with an
explicit -- rr-lint-disable-line RR-CLK-001.
aliased gate or a procedural if/else clock mux.
Clock-domain crossing — RR-CDC-*
CDC-001 (Xilinx *.xdc) / CDC-002 (Altera *.sdc) · warning by
default; error under rr rules check --strict · Blanket clock groups hide
every crossing. Any set_clock_groups carrying -asynchronous,
-exclusive, -physically_exclusive, or -logically_exclusive removes STA
from every path between the named groups—not merely the crossing the author
had in mind. Use
set_false_path -from [get_pins <launch>] -to [get_pins <capture>] for one
specific crossing, or set_max_delay -datapath_only <period> on the first
stage of a proper ASYNC_REG two-flop synchronizer. The constraint never makes
the crossing metastability-safe; the synchronizer/handshake/async FIFO does.
A truly intentional group may carry an immediately adjacent, auditable waiver:
# rr: allow-clock-groups reason="why every path is individually synchronized".
A non-empty reason downgrades the source finding to INFO; a missing reason does
nothing. Whenever any group exists, rr implementation run also emits the
vendor CDC/unconstrained-path summary. Any Critical/Warning/unsafe crossing is
fatal even when the source rule was waived.
RR-CDC-001 · warning · ASYNC_REG must be the string "TRUE", not VHDL boolean.
Vivado exposes only the string form of ASYNC_REG as a queryable cell property. A
boolean-typed async_reg keeps the placement/MTBF effect but is invisible to
get_cells -hier -filter {ASYNC_REG == "TRUE"} — so the design-wide
set_max_delay -datapath_only CDC idiom silently never reaches those synchroniser FFs,
leaving the crossing unconstrained (a false-negative WNS that only surfaces at P&R). Fix:
attribute async_reg of sync : signal is "TRUE";.
RR-CDC-002 · info (review) · Multi-bit bus through a 2-FF synchroniser. A per-bit 2-FF synchroniser does not keep the bits of a coherent bus together: each bit resolves metastability independently and can settle on a different cycle, so the receiver can sample a transiently wrong multi-bit value. 2-FF sync is safe only for a single bit, a gray-coded pointer (one bit changes per step), or genuinely independent bits. A review item (not pass/fail) — confirm coherency; use a proper handshake / async FIFO / gray code for a real multi-bit crossing.
RR-CDC-003 · warning · Async reset deassertion without a deassert synchronizer.
A clocked process consuming an asynchronous reset (if rst = '1' then ... elsif rising_edge(clk))
risks metastability upon deassertion if reset release edges race the clock. Feed async resets
through a two-flop deassert synchroniser in the destination domain (async assert, sync deassert).
Tripwire; follow the investigation protocol to confirm the driver or waive.
RR-CDC-004 · warning · olo_base_fifo_async ReadyRstState_g default '1' accept-and-drop corruption.
olo_base_fifo_async defaults generic ReadyRstState_g to '1'. This causes In_Ready
to assert during the coupled cross-domain reset window. If an upstream producer is free-running
(not held in reset by the exact same reset), it hands beats into the resetting FIFO that are
accepted and dropped, causing downstream consumer FSMs expecting start-of-data/packet markers to
receive mid-packet words and wedge permanently. Always specify ReadyRstState_g => '0' so
In_Ready is held low throughout the cross-domain reset window.
*(Structural CDC/RDC beyond regex is handled by the SV-Gap backend — profile
These
RR-CDC-*rules and therr-cdc-structural-provisional/rr-cdc-vhdl-provisionalprofiles are the authoring-time heuristic layer — per file, per regex/AST, blind to which domain a signal actually lives in. They are layer 1. Two project-level layers sit above them and neither replaces a lint rule:
rr cdc check— the pre-route structural gate: elaborates the whole design (GHDL→Yosys), reconciles discovered crossings against the declarativecdc.ymlledger, and verifies each declared crossing has a reaching timing exception in the checked-in XDC/SDC — the boolean-ASYNC_REGreachability trap that RR-CDC-001 warns about, now enforced by process exit code, on any backend, with no vendor tool. See CDC Signoff.rr timing cdc— the post-route vendor authority (Vivado routed DCP.rr cdc checkcomplements it pre-route; it never replaces it.
RR-AXIS-001: AXI-Stream / AXI4 backpressure needs a skid buffer
live · rr sim lint-axis-skid · severity warning
Rule. When a module exposes an AXI4-Stream (or AXI4 full) interface and needs to
be pipelined / registered across a timing or module boundary, the backpressure
(tready / ready) must be handled with a skid buffer (a 2-deep register slice), not
a combinational ready passthrough and not a naive single register.
Why. AXI tready backpressure is combinational by spec. Two failure modes:
- Combinational
readychain across a pipeline → a longreadypath that kills fmax (thereadyof the last stage ripples back to the first). - Naively registering
ready→ you either drop the beat in flight when the consumer deassertsreadyone cycle late, or you inject a bubble every other cycle (≤50% throughput).
A skid buffer registers both the forward (tvalid/tdata) and backward (tready)
paths while sustaining 1 transfer/cycle (100% throughput) — it "skids" to absorb the
single in-flight beat when the consumer stalls. It is exactly Xilinx axis_register_slice
in behaviour; the minimal correct AXI pipeline register.
Default action for an agent. When emitting or registering an AXI-Stream/AXI4
interface at a boundary, instantiate the canonical skid-buffer / register-slice primitive
(don't hand-roll a bare register on ready). A thin combinational leaf adapter that does
not register the interface is exempt — this rule is about pipelined boundaries.
Mechanically flaggable anti-patterns (the lint check target): a combinational
tready → tvalid/tdata path across a module boundary, plus direct tready chains
with no visible buffer state. Semantic correctness ("backpressure handled right") is
review-level; the clear anti-patterns are pass/fail.
The canonical primitive ships in both languages:
src/units/axis_skid_buffer.vhd and src/units/axis_skid_buffer.sv.
Run the staged-file lint directly with:
rr sim lint-axis-skid src
RR-RDY-001 / RR-RDY-002: ready tied off or ignored between instances
live · rr sim lint-ready-chain (exit 1 on a finding) and warnings in rr linting · severity warning
Rules.
- RR-RDY-001: a ready/backpressure INPUT of an instance is tied to a
constant (
'1','0',1'b1,1'b0, a constant, generic or parameter). Ready-like means*tready, the AXI channel readies (awready…rready) andwaitrequestby name alone;*_ready,*_rdy,*_stall,*_full,*_afulland a mid-namereadyonly when the same instance also has a paired valid/write port (i_idelay_rdywith no valid partner is a status flag). The finding names the instance, the port and the paired valid. - RR-RDY-002: a ready-like OUTPUT of an instance is
open, empty, omitted from a fully named map, or its net reaches only debug/probe logic (ILA, VIO, SignalTap, ISSP, REA instances,dbg_*/*_probenets, followed through plain assignments), while that instance's paired valid/data INPUT is driven.
Why. A producer whose ready is tied cannot hold its data. A sink whose
ready goes nowhere stalls without anyone listening. Both pass any simulation
whose sink never deasserts ready, and both pass timing. A field video chain
(scaler → encoder) shipped with the scaler's ready tied to '1' and the
encoder's ready routed only to a probe. It ran for weeks, then lost samples (a
horizontal picture shift) when a mode change made the encoder apply
backpressure.
Not reported. A tie-off of an unused interface (its paired valid is
itself unconnected), a ready whose net reaches any real consumer, and an
ignored full whose sibling prog_full/almost_full is read.
Scope. Named associations of instances only (VHDL formal => actual,
Verilog .port(net)). Directions come from the entity, module or component
declarations among the scanned files, else from AXI-Stream (s_axis_*,
m_axis_*) and i_/o_ naming. RR-RDY-002 never fires on a port whose
direction is unknown. The whole-chain review the lint cannot do is the
rr-ready-valid-chain-audit skill.
Waiver. Per line, with a reason, for a sink documented as always-ready:
m_axis_tready => '1', -- lint-ok: ready-chain encoder datasheet §4.2: s_axis_tready is constant 1
The comment goes on the association's line or on a comment-only line directly above it. A waiver with no reason does not count, and the finding still prints, saying so.
rr sim lint-ready-chain # project paths.sources
rr sim lint-ready-chain --json rtl/top # explicit files/directories
Running the lint
rr lint --profile esa-vhdl-strict-provisional --src src # ESA style + RR-* FPGA rules
rr lint --profile rr-arith-vhdl-provisional --src src # RR-ARITH timing-cost rules only
rr lint --profile rr-cdc-vhdl-provisional --src src # the RR-CDC/MEM/ARITH/CLK set
rr lint --profile rr-cdc-structural-provisional --src src # SV-Gap structural CDC/RDC
rr lint --profile rr-tcl-helpers --src tcl # rr-shipped Tcl helper docs
Tcl helper documentation — RR-TCL-*
RR-TCL-001 · error (build-gating) · Undocumented Tcl helper
procedure. Every rr-shipped proc declaration requires a concise explanatory
# comment immediately above it. Existing debt is grandfathered only by exact
file and proc name; the baseline does not cover a new helper added to the same
file.
rr-arith-vhdl-provisional is the single source for RR-ARITH-*. It is inherited by
the ESA-VHDL and BSG-aligned-VHDL baseline profiles, so every tier in those ladders
checks timing-risk arithmetic; rr-cdc-vhdl-provisional inherits it as well for
backward compatibility. The remaining FPGA rules live in the CDC profile. Coding-style
families remain distinct: ESA-V-* (ESA-VHDL audit — naming, magic numbers,
_q/_r convention) and bsg-aligned-* (Basejump STL alignment).
The through-line
Rationale (skill) → mechanical lint (RR-*, profile-bundled, FP-calibrated) → structural
(SV-Gap) → formal (PSL/SVA) → measured (OOC synth/impl). The layers are complementary:
the structural audit predicts the mapping; synthesis confirms it. On the h264-dec CABAC
decoder this exact chain caught an async-read grid that would have exploded into a
flip-flop matrix (RR-MEM territory), the fix landed as BRAM line-buffers, and the KV260
OOC synth then measured 109 RAMB36E2 and 0 FF-matrix — prediction confirmed.