📌 What is the Cover Directive?#
In SystemVerilog, the cover
directive is used in the design or testbench environment to check whether a certain behavior has occurred. It is a critical mechanism for functional coverage tracking.
Example:
cover property (@(posedge clk) req |-> ack);
In this example:
- When the
req
signal is active, it checks whether theack
signal is active in the next cycle. - It does not produce an assertion failure; it only triggers a coverage event when the condition is met.
🛠️ Why Use Cover?#
✅ Testbench Activity: Used to see whether every path in the design (e.g., state transitions or handshake scenarios) has been exercised.
✅ Coverage Analysis: Measures test coverage, reporting which behaviors have been tested and which are missing.
✅ Combination with Assertions: The same property can be used with both assert and cover directives:
assert property (p_handshake);
cover property (p_handshake);
🔍 Use Cases for Cover#
FSM (Finite State Machine) Coverage: Ensures all state transitions are tested.
Handshake Protocols: Checks whether every combination of request-acknowledge, valid-ready, etc. has occurred.
Protocol Coverage: Monitors different transaction combinations in protocols like PCIe and AMBA.
📝 Considerations When Using Cover#
Simulation Dependent: The cover directive only checks for behavior occurrences during simulation. For formal verification, assertion coverage depends on the assertion coverage tool.
No Error Messages: If the cover condition is not met, the test does not fail; only coverage is reported as missing.
🔧 Simple Example#
property p_valid_ready;
@(posedge clk) valid |-> ready;
endproperty
cover property(p_valid_ready);
In this example:
- When
valid
is asserted,ready
is checked in the next cycle. - If this scenario occurs, the coverage is ticked.