Rat dse policy

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

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

How to use this skill

Skill file

DSE Policy

What Makes DSE Different from Standard Phase 1→3

| Aspect | Standard (p1 + p2 + p3 sequential) | rat-dse |

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

| Algorithm study | Select best, justify | Explore N candidates, quantitative comparison |

| Architecture | Single architecture from requirements | Multiple candidates, trade-off matrix, user selects |

| μArch + BFM | Single-pass μArch design | Iterative μArch with self-critique and re-exploration |

| Ref C model | Build from scratch | Accept functional model as input, transform to architectural model |

| Fixed-point | Identify precision requirements | Simulate effects, precision vs area trade-off curves |

| Iteration | One-shot per phase | Self-critique → re-run → user review → trial comparison |

| Output | Ready for Phase 4 | Pre-implementation package with DSE rationale, ready for Phase 4 |

Design Priority Order

  1. Functional Correctness (highest) — Every required feature works exactly
  2. Interface Compliance — Ports, protocols, timing match Architecture
  3. Timing/Performance — Throughput, latency targets met
  4. Area/Power (lowest)

Document-as-Memory

All exploration results captured in design artifacts (docs/, reviews/) so downstream

phases can reference DSE rationale without repeating exploration.

DSE Methodology

Algorithm Comparison Matrix (per functional block)

For each major functional block, enumerate 2-4 algorithmic approaches:

| Metric | Candidate A | Candidate B | Candidate C |

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

| Computational complexity (ops/input) | | | |

| Memory access pattern (seq/random, R/W ratio) | | | |

| Memory bandwidth estimate | | | |

| HW gate count estimate (order of magnitude) | | | |

| Quality/accuracy impact (PSNR/SSIM if applicable) | | | |

| Parallelization potential (data/pipeline) | | | |

Fixed-Point Feasibility Analysis

HW-Friendly Algorithm Modifications

Architecture Candidate Format

For each candidate (2-3 required):

Output: docs/phase-2-architecture/architecture-candidates.md

User Decision Points

Two mandatory AskUserQuestion interactions:

  1. Algorithm selection: After algorithm exploration, present candidates with quantitative matrix
  2. Architecture selection: After architecture candidate exploration, present trade-off matrix

Decisions recorded as ADRs:

Functional → Architectural C Model Transformation

When input_mode == "transform" (user-provided functional C model):

  1. Analyze: Identify function boundaries, data flow, global state
  2. Map: Map functions to architecture.md block boundaries
  3. Restructure:
  1. Verify: Run same test vectors through original and transformed models

Output: refc/.c (restructured), refc/include/.h. C11, no clock/reset, DPI-C compatible.

Optional Evaluations

Quantitative RD evaluation: If ref C model encoder is buildable and test sequences

are available, invoke /rtl-agent-team:codec-rd-eval for BD-PSNR measurements.

Decoder conformance: If ref C model decoder exists and conformance bitstreams

are available, invoke /rtl-agent-team:codec-conformance-eval.

Execution Rules

Dual-Layer Phase Gates

Phase 1→2, Phase 2→3, and Phase 3 completion require BOTH Artifact Gate + Quality Gate.

Quality Gate verdicts: PASS or FAIL + findings[]. Max 2 retries per gate.

Scratchpad Convention

.rat/scratch/phase-{N}/round-{R}-{agent}.md

On gate PASS: consolidate to reviews/, clean scratch.

Termination

After Phase 3 Quality Gate PASS + self-critique re-run, present results to user.

Do NOT proceed to Phase 4. DSE produces a pre-implementation package for user review.

Phase Gate Definitions

Phase 1→2 (Research → Architecture DSE)

Artifact Gate: iron-requirements.json + open-requirements.json + io_definition.json + timing_constraints.json + domain-analysis.md exist

Quality Gate:

Summary Validation: docs/phase-1-research/phase-1-summary.md

Phase 2→3 (Architecture DSE → μArch + BFM)

Artifact Gate: architecture.md + architecture-candidates.md + refc/.c + iron-requirements.json (P2, REQ-A-) exist

Quality Gate:

Summary + ADR: phase-2-summary.md + ADRs (including algorithm + architecture selection)

Escalation & Stop Conditions

Coding Convention Summary

Phase 3 Gate Definition

Phase 3 Entry (requires Phase 2 completion)

Artifact Gate: architecture.md + refc/.c + iron-requirements.json (P2, REQ-A-) exist

Quality Gate: Phase 2→3 gate above must have passed (compliance PASS, all OPEN-1-* resolved)

Phase 3 Completion (μArch + BFM → Self-Critique)

Artifact Gate: docs/phase-3-uarch/.md + bfm/src/.cpp (or bfm/src/*.c) + iron-requirements.json (P3) exist

Quality Gate:

Note: Phase 3 produces C/SystemC BFM, NOT SystemVerilog RTL.

BFM is the executable μArch model. DPI bridge template is prepared for

future RTL comparison in Phase 4, but no RTL is written in DSE.

Self-Critique Protocol

After Phase 3 Quality Gate PASS, the orchestrator performs self-critique

BEFORE presenting results to the user:

  1. Critique agent reviews the complete P1→P3 output:
  1. Output: reviews/dse-self-critique.md with findings rated HIGH/MEDIUM/LOW
  1. Re-run: Run Phase 1→3 again incorporating all critique findings
  1. Result: Second pass produces refined pre-implementation package

Trial Comparison Protocol

When the user requests another iteration (not satisfied with results),

a new trial is created in a git worktree:

Trial Management

Comparison Method

After Trial N completes, compare against the current best trial:

  1. Independent compliance checks: invoke compliance-checker separately on EACH trial's P1→P3 chain
  1. Quantitative comparison table (presented to user):

| Metric | Current Best (Trial K) | New Trial (Trial N) |

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

| Iron requirements count | | |

| Open items remaining | | |

| Ambiguity score (P1) | | |

| Architecture candidates explored | | |

| μArch modules defined | | |

| BFM ↔ RefC match | | |

| Compliance verdict (P1+P2→P3) | | |

| Self-critique HIGH findings | | |

  1. Selection: user chooses which trial to keep

Iteration Loop

repeat:
  AskUserQuestion("결과가 만족스러운가? (yes/no)")
  if yes → done (pre-implementation package ready for Phase 4)
  if no  → collect user feedback
         → create new trial (worktree)
         → run P1→P3 with feedback
         → compare trials
         → user selects better trial

Final Checklist

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.