Rtl p4s unit test policy

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

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

How to use this skill

Skill file

Tier 2 Unit Test Policy

Coding Convention Requirements

Testbenches MUST follow project conventions:

Execution Policy

Reference Comparison Modes

| Mode | Condition | Method |

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

| A: DPI-C | refc/build/lib{module}_ref.so exists | SV TB calls ref functions via DPI-C, cycle-level comparison |

| B: File | DPI-C unavailable | RTL sim → output file, ref binary → output file, diff comparison |

DPI-C setup:

cd refc && mkdir -p build
gcc -std=c11 -shared -fPIC -o build/lib{module}_ref.so src/{module}_ref.c

Result JSON Schema

Each feature entry supports an optional ac_ids field for acceptance criteria traceability:

iron-requirements.json, ac_ids MUST be populated for each covered criterion.

{
  "module": "{module}",
  "tier": 2,
  "ref_mode": "A_DPI" | "B_FILE",
  "features": [
    {"name": "fsm_idle_to_active", "status": "PASS", "req_ids": ["REQ-U-003"], "ac_ids": ["REQ-U-003.AC-1"]},
    {"name": "pipeline_latency_3cyc", "status": "PASS", "req_ids": ["REQ-U-007"], "ac_ids": ["REQ-U-007.AC-1", "REQ-U-007.AC-2"]},
    {"name": "valid_ready_handshake", "status": "PASS", "req_ids": ["REQ-U-012"], "ac_ids": ["REQ-U-012.AC-1"]},
    {"name": "transform_accuracy", "status": "FAIL", "mismatch_cycle": 47, "req_ids": ["REQ-U-015"]}
  ],
  "ref_mismatches": 0,
  "pass_count": 5,
  "fail_count": 0,
  "total": 5,
  "gap_fill_round": {
    "executed": true,
    "before": {"line_pct": 52.1, "fsm_pct": 40.0},
    "after": {"line_pct": 67.3, "fsm_pct": 55.0}
  },
  // When gap-fill NOT triggered: {"executed": false, "before": null, "after": null}
  "coverage": {
    "line_pct": 67.3,
    "fsm_pct": 55.0,
    "toggle_pct": 42.1
  },
  "func_coverage": {
    "covergroups_defined": 2,
    "bins_hit": 14,
    "bins_total": 20
  },
  "codec_conformance": "PASS" | "FAIL" | "N/A"
}

Tier Transition Rules

Escalation & Stop Conditions

Advanced

Minimum Coverage Targets (Tier 2)

These are intentionally lower than P5 targets (90%/80%/70%) to keep Tier 2 fast while ensuring meaningful depth:

Structural coverage:

Functional coverage (Tier 2):

Gate-enforced (hard):

Recommended guidance (not gate-enforced — P5 coverage-analyst verifies these):

Traceability:

Mandatory Error Injection (Tier 2)

Every Tier 2 unit test MUST include at minimum these error injection scenarios

where the module interface supports them:

| Category | Condition | Mandatory Test |

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

| Reset recovery | All modules | Assert rst_n=0 during active operation → verify FSM returns to reset state, no residual data |

| Backpressure stress | Modules with valid/ready interface | Hold ready low ≥16 cycles during valid=1 → verify data integrity preserved |

| Boundary arithmetic | Modules with datapath operations | Input at min/max boundary values → verify no overflow/underflow corruption |

Applicability: If a module lacks the interface for a category (e.g., no valid/ready),

that category is N/A. At least ONE error injection test must be present per module.

Gate: unit_results.json features array must contain at least one entry with

name containing "error_" or "err_" or "reset_" or "backpressure_" or "overflow_" prefix.

Absence of any error injection test → WARNING (advisory at Tier 2, enforced at Tier 3).

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.