Rtl model consistency

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

Rtl model consistency is an AI agent skill from the GitHub repository babyworm/rtl-agent-team. 3-way bitexact comparison of C ref model vs SystemC BFM vs RTL on shared vectors; isolates which model drifted. Triggers: 'model consistency', 'model drift'.

How to use this skill

Skill file

<Purpose>

Run a 3-way bitexact comparison between the C reference model (refc/), SystemC BFM (bfm/), and RTL simulation on a shared test vector set. Outputs: sim/consistency/consistency_report.md with a pairwise comparison matrix and diagnosis identifying which model diverges.

</Purpose>

<Use_When>

</Use_When>

<Do_Not_Use_When>

</Do_Not_Use_When>

<Why_This_Exists>

When ref model, BFM, and RTL are developed independently, silent divergence accumulates. 3-way comparison isolates which model is wrong: ref == BFM != RTL means RTL has a bug; ref != BFM == RTL means the ref model diverged; ref == RTL != BFM means BFM has an issue. Two-model comparisons cannot make this determination.

</Why_This_Exists>

Prerequisites

If any model binary is missing: WARNING — run that model's build skill first; proceed with 2-way comparison and note the absent model in the report.

<Assets>

| Path | Role |

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

| scripts/compare_3way.py | Pairwise comparison of ref/BFM/RTL output files (--refc/--bfm/--rtl, line-oriented text via --format hex\|bin\|csv, --tolerance N); emits pairwise match/mismatch matrix, first-divergence index + values per pair, exit 0 = consistent / 1 = inconsistent. |

| templates/consistency-report.md | Report scaffold with summary table, diagnosis section, and mismatch details table. |

| references/model-consistency-conventions.md | Comparison criteria, diagnosis logic table, vector-count guidance, anti-patterns. |

| examples/ | Worked 3-way vector set: shared inputs + consistent outputs (PASS) + RTL-drift outputs (vector 11 diverges → "RTL has a bug" diagnosis) + README with commands. |

</Assets>

<Responsibility_Boundary>

</Responsibility_Boundary>

<Execution>

  1. Select shared test vector set: use sim/consistency/test_vectors.bin if present; otherwise generate a minimum 10-vector set.
  2. Run all three models in parallel on identical input (see Tool_Usage). Each output must be captured as line-oriented text (one value per line — dump binary outputs to hex/bin/csv text first):
  1. Run python3 {plugin_root}/skills/rtl-model-consistency/scripts/compare_3way.py --refc sim/consistency/ref_output.hex --bfm sim/consistency/bfm_output.hex --rtl sim/consistency/rtl_output.hex --format hex ({plugin_root} = plugin root resolved from .rat/state/spawn-context.json) — prints the pairwise match/mismatch matrix, first-divergence index + values per pair, and OVERALL: CONSISTENT|INCONSISTENT (exit 0/1).
  2. Write sim/consistency/consistency_report.md using templates/consistency-report.md: summary table, diagnosis (see conventions for logic), mismatch details with divergence index + expected/actual values.
  3. Report overall consistency status to the user.

Apply steps 1-5 to every vector set requested — do not stop after the first run.

</Execution>

<Tool_Usage>

Task(subagent_type="rtl-agent-team:ref-model-dev",
     prompt="Run refc/build/ref_model on sim/consistency/test_vectors.bin via Bash CLI. "
            "Capture output as line-oriented hex text (one value per line) to "
            "sim/consistency/ref_output.hex. Build first if needed: make -C refc/.")

Task(subagent_type="rtl-agent-team:bfm-dev",
     prompt="Run bfm/build/bfm_smoke on sim/consistency/test_vectors.bin via Bash CLI. "
            "Capture output as line-oriented hex text (one value per line) to "
            "sim/consistency/bfm_output.hex. Build first if needed: make -C bfm/.")

Task(subagent_type="rtl-agent-team:func-verifier",
     prompt="Simulate RTL with sim/consistency/test_vectors.bin as input via Bash CLI (iverilog/cocotb). "
            "RTL ports use i_/o_ prefixes, clocks are {domain}_clk, resets are {domain}_rst_n. "
            "Capture output as line-oriented hex text (one value per line) to "
            "sim/consistency/rtl_output.hex.")

</Tool_Usage>

<Examples>

<example index="1">

<scenario>All three models built; 50 shared vectors; post-BFM-update consistency gate.</scenario>

<expected_output>ref == BFM on 50/50; RTL diverges on vector 23; consistency_report.md diagnoses RTL as outlier; first divergence at index 142 with val_a/val_b values; diagnosis: CABAC encoder rounding difference.</expected_output>

</example>

<example index="2">

<scenario>Ref model updated after spec change; BFM and RTL not yet updated.</scenario>

<expected_output>ref != BFM == RTL; consistency_report.md diagnoses ref model diverged; mismatch details list first-divergence index and values per pair; user informed to update BFM and RTL.</expected_output>

</example>

<example index="3">

<scenario>BFM binary missing; only ref and RTL available.</scenario>

<expected_output>WARNING in report noting BFM absent; 2-way ref vs RTL comparison run; consistency_report.md documents reduced scope; user advised to run bfm-develop before full 3-way check.</expected_output>

</example>

</Examples>

<Escalation_And_Stop_Conditions>

</Escalation_And_Stop_Conditions>

Output

<Final_Checklist>

</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.