Automatically infer formal correctness properties from Verilog/SystemVerilog RTL code and generate SystemVerilog Assertions (SVA). Identifies control-flow invariants (mutual exclusion, valid-ready handshakes, pipeline ordering, safety properties), liveness expectations, and temporal properties. Use when working with RTL designs that need formal property generation, when adding assertions to existing RTL, or when users ask to infer properties, generate assertions, or create formal specifications from hardware designs.
This skill analyzes Verilog/SystemVerilog RTL code and automatically infers implicit correctness properties, generating formal SystemVerilog Assertions (SVA). The skill identifies common hardware patterns and generates appropriate safety, liveness, and fairness properties with clear explanations.
Analyze the input RTL code to extract key components:
Identify signals and their roles:
Recognize structural patterns:
Extract clock/reset conventions:
Systematically analyze the design for common invariant patterns:
Mutual Exclusion:
Valid-Ready Handshakes:
Pipeline Ordering:
Safety Properties (bad things never happen):
Look for patterns indicating "good things eventually happen":
Request-Response Patterns:
Progress Properties:
Fairness Constraints:
Note: Liveness properties require careful analysis. Only infer when there's clear evidence of intended eventual behavior. Use bounded liveness (with timeouts) when unbounded liveness may not hold.
Use the pattern library in common_patterns.md to generate appropriate assertions:
Refer to sva_syntax.md for SVA syntax details.
Separate properties into clear categories:
Strong Invariants (assert):
Assumed Environment Constraints (assume):
Coverage Properties (cover):
For each inferred property, provide:
SVA assertion code:
property_name: assert property (
@(posedge clk) disable iff (rst)
antecedent |-> consequent
) else $error("Description of violation");
Natural-language explanation:
Signal list:
Classification:
Additional context:
Structure the output as follows:
## Inferred Properties for [Module Name]
### Clock and Reset
- Clock: <signal_name> (<edge>)
- Reset: <signal_name> (<polarity>, <sync/async>)
### Strong Invariants (Assert)
#### Property 1: <Short Name>
**Type**: Safety | Liveness | Fairness
**Confidence**: High | Medium | Low
**Assertion**:
```systemverilog
<property_name>: assert property (
@(posedge clk) disable iff (rst)
<property_expression>
) else $error("<error_message>");
Explanation: <Natural language description of what this property checks and why>
Signals Involved:
<signal1>: <role/description><signal2>: <role/description>Rationale: <Why this property was inferred from the RTL structure>
[Repeat for each property]
[Same format as above, but using assume directive]
[Same format as above, but using cover directive]
## Important Guidelines
1. **Be conservative**: Only infer properties with clear evidence in the RTL
2. **Explain reasoning**: Always justify why a property was inferred
3. **Mark confidence**: Indicate confidence level (High/Medium/Low) for each property
4. **Avoid false positives**: Better to miss a property than infer an incorrect one
5. **Consider timing**: Ensure delay values match design behavior
6. **Check vacuity**: Suggest cover properties for antecedents to avoid vacuous success
7. **Document assumptions**: Clearly state any assumptions made during inference
8. **Provide context**: Explain how properties relate to overall design correctness
## Example Usage
**User request**: "Infer properties from this FIFO module"
**Process**:
1. Parse RTL and identify: full, empty, wr_en, rd_en, count signals
2. Recognize FIFO pattern with full/empty flags
3. Infer safety properties:
- No write when full
- No read when empty
- Count within bounds [0:DEPTH]
- Full and empty mutually exclusive (unless DEPTH=1)
4. Infer liveness property:
- Write eventually makes FIFO non-empty
5. Generate SVA assertions with explanations
6. Classify as strong invariants (assert)
7. Add coverage for full and empty conditions
## References
- [common_patterns.md](references/common_patterns.md) - Library of common RTL patterns and their properties
- [sva_syntax.md](references/sva_syntax.md) - SystemVerilog Assertions syntax reference
## Limitations
- Cannot infer properties requiring deep semantic understanding beyond structural patterns
- May miss complex cross-module properties
- Liveness properties may need manual refinement for unbounded cases
- Timing parameters (delays, timeouts) may need adjustment based on actual design constraints
- Does not replace manual formal specification for critical properties