Systemverilog assertion

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

Systemverilog assertion is an AI agent skill from the GitHub repository babyworm/rtl-agent-team. systemverilog-assertion project conventions (loaded by writer agents; do not invoke).

How to use this skill

Skill file

<Purpose>

SVA project conventions and formal-flow rules for .sva files and SVA blocks in .sv files.

Standard SVA semantics (property/sequence operators, assert/assume/cover/restrict usage) are

assumed known. Target standard: IEEE 1800-2012 for SVA and verification code

(2012 adds checker, restrict property, sequence methods; 2017 was errata-only).

</Purpose>

<Use_When>

</Use_When>

<Do_Not_Use_When>

</Do_Not_Use_When>

<Execution_Policy>

FIFO safety/liveness/coverage patterns: examples/fifo-sva-example.sv

</Execution_Policy>

<Steps>

1. Naming Conventions

| Target | Pattern | Example |

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

| Assert label | a_{signal}_{condition} | a_valid_hold, a_data_stable |

| Assume label | m_{signal}_{constraint} | m_valid_no_x, m_addr_aligned |

| Cover label | c_{scenario} | c_back_to_back, c_max_burst |

| Sequence | seq_{name} | seq_handshake, seq_burst_complete |

| Property | prop_{name} | prop_valid_hold, prop_fifo_no_overflow |

| SVA file | sva_{module}.sv | sva_axi_slave.sv |

| SVA bind module | sva_{module}_checker | sva_axi_slave_checker |

2. Clock/Reset Patterns

2.1 Basic Structure

// All concurrent assertions use default clocking + disable iff
default clocking cb @(posedge sys_clk); endclocking
default disable iff (!sys_rst_n);

2.2 Past-Valid Guard

The $past() value is invalid on the first cycle after reset, so use a guard:

logic past_valid;
always_ff @(posedge sys_clk or negedge sys_rst_n) begin
  if (!sys_rst_n) past_valid <= 1'b0;
  else            past_valid <= 1'b1;
end

// Always check past_valid when using $past
a_data_stable: assert property (
  past_valid && $rose(i_valid) |-> ##1 $stable(i_data)
) else $error("Data must be stable after valid rises");

3. Assertion Hygiene (Project Requirements)

never bare immediate assert(sig) inside always_ff (simulation-only, invisible to formal)

assert property (!(o_read_en && o_write_en));

(unbounded eventually is unprovable by BMC — see §5.3)

examples/fifo-sva-example.sv

4. Bind-File-First Policy

Attach assertions externally via a sva_{module}_checker module + bind statement — do NOT

modify the RTL module. The checker module ports mirror the RTL port names verbatim

(i_/o_ prefixes, sys_clk, sys_rst_n), so the bind uses (.*):

bind my_module sva_my_module_checker u_sva_checker (.*);

Complete scaffold (checker module + default clocking/disable + bind): templates/sva-bind-template.sv.

5. SymbiYosys Integration

5.0 sv2v Conversion (Mandatory for SymbiYosys/Yosys)

SymbiYosys uses Yosys internally, which has limited SystemVerilog support.

RTL .sv files must be converted to Verilog via sv2v before running sby:

sv2v rtl/{module}/*.sv -o rtl/{module}/{module}_v2v.v

so Yosys keeps real $assert / $cover cells.

commercial/full-SVA path and are read with -formal -sv by tools that support bind.

5.1 Formal Verification Modes

| Mode | Purpose | SBY Config |

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

| BMC (Bounded Model Check) | Search for counterexamples within finite depth | mode bmc, depth 20-50 |

| Induction (prove) | Mathematical proof at unbounded depth | mode prove |

| Cover | Verify reachability of cover points | mode cover |

5.2 assume vs assert

5.3 Liveness Caution

</Steps>

<Tool_Usage>

This skill is not executed directly. It is referenced by agents that generate SVA

(e.g., sva-extractor, protocol-checker). Agents should follow the conventions defined here.

</Tool_Usage>

<Examples>

Bind file with default clocking/disable, past_valid guard, and labeled+messaged assertions:

templates/sva-bind-template.sv and examples/fifo-sva-example.sv.

</Examples>

<Escalation_And_Stop_Conditions>

</Escalation_And_Stop_Conditions>

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