User guide

23-68
SystemVerilog Assertion Constructs
Assertion System Functions
The assertion system functions are $onehot, $onehot0, and
$isunknown. Their purposes are as follows:
$onehot
Returns true if only one bit in the expression is true.
$onehot0
Returns true if at the most one bit of the expression is true (also
returns true if none of the bits are true).
$isunknown
Returns true if one of the bits in the expression has an X value.
In the VCS implementation, this function also returns true if one
of the bits in the expression has a Z value.
The following is an example of their use:
a1: assert property (@ (posedge clk) $onehot({lg1,lg2}));
a2: assert property (@ (posedge clk) $onehot0({lg1,lg3}));
a3: assert property (@ (posedge clk)$isunknown({r1,r2,r3}));
Another useful function is $countones. This function returns the
number of 1s in a bit vector expression.
Using Assertion Categories
You can categorize assertions and then enable and disable them by
category. There are two ways to categorize SystemVerilog
assertions:
Using OpenVera assertions system tasks for categorizing
assertions