Automate local and synchronous checks, detect X/Z values, and disable a check cleanly during reset.
An assertion expresses a specific rule and locates its failure. It complements the scoreboard: assertions suit invariants and signal sequences; scoreboards suit transaction results.
Check at the execution point
An immediate assertion belongs in a task, function, or procedural block:
checks++;
check_result: assert (actual === expected) else begin
errors++;
$error("actual=%h expected=%h time=%0t",
actual, expected, $time);
end
A label helps diagnosis. Choose $warning for tolerated anomalies, $error to continue checking, or $fatal when execution should stop.
Bench operation must not depend on a side effect inside an assertion expression. Avoid this form:
// Avoid: the cast is a required operation, not merely a check.assert ($cast(derived_handle, base_handle));
A configuration may disable assertion evaluation. Perform essential casts or randomization separately, then check the returned result.
Sample a rule on a clock
A concurrent assertion specifies its sampling event and can be declared at module or interface scope:
property control_is_known; @(posedge clk) disable iff (!rst_n) !$isunknown({valid, ready});endpropertyknown_control_a: assert property (control_is_known) else $error("valid/ready contains X or Z");
$isunknown detects X and Z. disable iff (!rst_n) disables the property during active-low reset. This is an asynchronous disabling condition, not simply another sampled signal.
Property signals are sampled and evaluated in assertion scheduling regions. That avoids arbitrary ordering between active procedural blocks, but does not repair a badly synchronized driver.
Put checks at the right boundary
An interface knows the protocol's signals and clock:
assert property judges a rule; cover property records occurrence. Transfer coverage shows whether a scenario happened without establishing a correct response.
A short property should state clock, reset policy, and failure action. For complete packets or identifier matching, monitors and scoreboards often give clearer diagnostics. Check simulator support for temporal constructs and enable assertions used for verdicts.