Immediate Assertions

assert, its pass and fail actions, severity tasks and handy checking functions.

An assertion states something that must be true. An immediate assertion is checked when the statement executes, like an if that reports an error when the condition is false. It documents assumptions in the code and catches violations the moment they happen.

Severity and helpers

assert (t.randomize()); // the call is inside the assertion ok = t.randomize(); assert (ok);

Assertions can be disabled (e.g. with $assertoff or a simulator switch); then the randomize call inside would also be skipped. Never put actions with side effects inside an assertion.

What does $isunknown(sig) return?

1 if any bit of sig is X or Z. assert (!$isunknown(data)) is a common check on valid data.