Rtl p4 implement policy

From babyworm/rtl-agent-team · View interactive version

Rtl p4 implement policy is an AI agent skill from the GitHub repository babyworm/rtl-agent-team. Internal reference: rtl p4 implement policy (agent-loaded; do not invoke).

How to use this skill

Skill file

Phase 4 Implementation Policy

10-Wave Pipeline Definition

Wave 0:  Prepare      — **Wave 0: Preparation + Test Plan**
         - Step 0a: Module enumeration, directory creation, TODO list (existing)
         - Step 0b: Test plan generation per module via test-plan-writer agent
           - Gate: sim/{module}/{module}_test_plan.md exists for every module
           - Failure: retry once, then proceed with WARNING (Wave 6a must generate missing plans)
Wave 1:  Write All    — One rtl-coder per module, all parallel
Wave 2:  Lint All     — One lint-checker per module, all parallel, collect results
Wave 3:  Fix Lint     — ONLY FAIL modules, max 3 rounds, re-lint only fixes
Wave 3.5: Synth Gate  — synthesizability-gate per lint-clean module, parallel (HARD GATE:
         zero inferred latches / incomplete assignments / non-synth constructs, AND
         DC-script-emittable; max 2 fix rounds, then rtl-architect escalation)
Wave 4:  Code Review  — rtl-critic per lint-clean module, parallel
Wave 5:  Bugfix       — ONLY REVIEW_FAIL modules, max 3 review→fix iterations
Wave 6a: Tier 1 Smoke — testbench-dev + eda-runner per module, parallel
Wave 6b: Tier 2 Unit  — Ref model comparison, REQ-U-* tracing, FSM >= 50%, line >= 60%, covergroups >= 1, codec conformance PASS/N/A
Wave 7:  Module CDC   — cdc-checker per multi-domain module, parallel
Wave 8:  Module Proto — protocol-checker per bus-interface module, parallel
Wave 9:  Refactoring  — rtl-p4s-refactor for flagged modules, selective
Wave 10: Integration  — smoke test + spec compliance + Stream B + Phase 4 gate

Key principles:

Wave Overlap Rules

Owned by the wave sequencer: see "Wave Overlap Rules" in the p4-implement-orchestrator agent prompt (modules progress through waves independently per that schedule).

Per-Module State Tracker Schema

{
  "module": "{module}",
  "wave_1_write": "DONE",
  "wave_2_lint": "PASS|FAIL",
  "wave_3_fix": "PASS|SKIP",
  "wave_4_review": "REVIEW_PASS|REVIEW_FAIL",
  "wave_5_bugfix": "PASS|SKIP",
  "wave_6a_tier1_smoke": "PASS|FAIL",
  "wave_6b_tier2_unit": "PASS|FAIL",
  "wave_7_cdc": "CDC_PASS|CDC_FAIL|SKIP",
  "wave_8_protocol": "PROTOCOL_PASS|PROTOCOL_FAIL|SKIP",
  "wave_9_refactor": "DONE|SKIP",
  "wave_10_gate": "PASS|FAIL"
}

Coding Convention Summary (Core Overrides)

All RTL produced in Phase 4 MUST follow:

Memory Wrapper Rules

Storage elements specified as "SRAM wrapper" in Phase 3 μArch docs MUST use the standardized

wrappers in rtl/common/ (parameterized behavioral models for simulation, foundry macros for synthesis):

| Wrapper | File | Use |

|---------|------|-----|

| sram_sp | rtl/common/sram_sp.sv | Single-port: 1 R/W port, single clock |

| sram_tp | rtl/common/sram_tp.sv | Two-port: 1W + 1R, single clock (clk) |

| sram_dp | rtl/common/sram_dp.sv | Dual-port: 1W + 1R, dual clock (wclk/rclk) |

blackbox/macro-replacement strategy) is OWNED by .claude/rules/rtl-coding-conventions.md

("Storage Selection" section, deployed by rat-init-project) — follow it verbatim

Combinational Chain Depth Heuristic

Sequential dependency loops in always_comb (e.g., error diffusion, SAD accumulation,

carry chains) create deep combinational paths that risk timing closure.

may tolerate deeper chains — document the justification

Pattern: for (s = 0; s < N; s++) where iteration s depends on iteration s-1

→ split at N/2 with registered intermediate results (when latency budget allows)

Examples where split was beneficial (ASIC):

Code Review Focus Areas (Wave 4)

Per-module review by rtl-critic:

  1. uarch compliance: does RTL match docs/phase-3-uarch/{module}.md?
  2. Interface compliance: do ports match io_definition.json?
  3. FSM completeness: all states from uarch spec present?
  4. Pipeline correctness: stage count, latency, throughput match uarch?
  5. Coding style: naming conventions, parameterization, comments
  6. Logical correctness: off-by-one, sign extension, width mismatches
  7. Power: unnecessary toggling, missing clock gating opportunities

Classification: REVIEW_PASS (0 critical/major findings) or REVIEW_FAIL.

Structural Verification in Code Review (Wave 4)

Wave 4 code review MUST include automated structural checks (performed by rtl-critic):

  1. FSM state completeness: all uarch spec states present in RTL
  2. Pipeline depth: RTL stages match uarch spec ±1
  3. Port mapping: all uarch spec ports present with correct direction/width
  4. Timing contract: pipeline supports specified latency (if documented)

Structural findings are classified:

REVIEW_PASS requires zero CRITICAL structural findings.

Code Review Iteration Protocol (Wave 5)

CDC Check Scope (Phase 4 vs Phase 5)

Protocol Check Scope (Phase 4 vs Phase 5)

Refactoring Decision Criteria (Wave 9)

invoke equivalence-checker (RTL-vs-RTL) before Wave 10 gate

Wave 6a/6b Unit Test Scope

self-checking assertions. Quick pass/fail per module.

Produces: sim/{module}/tb_{module}.sv

(DPI-C or file-based), uarch feature-level coverage with REQ-U-* tracing,

per-feature result JSON. Deeper per-module verification.

Extends: sim/{module}/tb_{module}.sv (adds reference comparison logic to

existing Wave 6a TBs, does NOT replace them).

Gate: Tier 2 gate per "Phase 4 Gate Criteria" below (single normative statement

of thresholds and required {module}_unit_results.json fields).

for ad-hoc Tier 2 testing outside the pipeline

AC Coverage at Wave 6b (Advisory)

When iron-requirements has structured acceptance_criteria (with ac_id) for a REQ-U-*:

ac_ids should be populated for each unit test feature covering that requirement.

This is advisory at P4 (not hard-block). Incomplete AC coverage is flagged as WARNING

and deferred to P5 for closure.

When no structured AC: existing req_ids gate applies unchanged.

Rapid-Impl to Full-Impl Transition

smoke functional pass, block sanity pass. State in p4-state.json.

Tier 2 unit tests (Wave 6b), protocol checks (Wave 8), refactoring (Wave 9),

integration gate (Wave 10), Stream B artifacts.

from rapid-impl and skip Waves 1-3 for those modules. Detection via:

rtl/*/*.sv exists + lint passes.

Phase 4 Sub-Skills Integration

Escalation & Stop Conditions

escalate to clock-architect (in addition to cdc-reviewer)

Phase 4 Gate Criteria

ALL of the following must be true before Phase 5:

RTL Files:

Lint:

Synthesizability (HARD — Wave 3.5):

(inferred latches / unmappable constructs) — gate-blocking, not advisory

Code Review:

Test Plan:

Unit Test (Tier 1 + Tier 2):

AC Coverage (advisory):

CDC:

Protocol:

Refactoring:

Integration + Gate:

Stream B (content quality verified):

Naming Conventions:

Summary:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.