$assertcontrol
Use one task, $assertcontrol, to lock, switch and kill assertions, filtered by assertion type and directive type.
You Will Be Able To
- Read a
$assertcontrolcall: control type, assertion type, directive type, levels, list. - Lock checks that no later call may switch.
- Switch only concurrent assertions, or only assert directives, and leave the rest alone.
- Name the parts Verilator 5.052 does not follow.
- Lesson
- A7.7
- Time
- 25 min
- Runs on
- Verilator
- Check
- 5 questions
A power-down test needs three things at once. The design rules sleep with the block, the bench assumptions stay on, and a safety check stays on whatever a library calls. One task with filters does all three.
- Neutral
- Data
- What to do
The control type: Lock, Unlock, On, Off, Kill, or one of the six action controls.
- Which kinds
Two bit masks: the kind of assertion and the directive. Values can be ORed: 3 means concurrent and simple immediate.
- Where
Levels and a list of scopes or assertions, as for the older tasks.
Read the diagram as text
- control_type: 1 Lock ... 11 VacuousOff
- assertion_type: 1 concurrent, 2 immediate, ... (default 255)
- directive_type: 1 assert, 2 cover, 4 assume (default 7)
- levels: as $dumpvars (default 0)
- list: scopes or assertions
- control_type → assertion_type: filtered by
- assertion_type → directive_type: and by
- assertion_type → levels: within
- levels → list: of
IEEE 1800-2023 20.11, Tables 20-5 to 20-7. $assertoff is $assertcontrol(4, 15, 7).
Lock and Unlock
Control type 1 locks the selected assertions: no later $assertcontrol, and so no $assertoff or $assertkill, changes them. Type 2 unlocks them.
On, off and Kill
Types 3, 4 and 5 are On, Off and Kill. They behave like $asserton, $assertoff and $assertkill, with the filters added.
Pass, Fail and Vacuous Types
Types 6 to 11 are the action controls of A7.6: PassOn, PassOff, FailOn, FailOff, NonvacuousOn and VacuousOff. On Verilator 5.052, types 10 and 11 depart from the standard as their named tasks do.
The Assertion-Type Filter
The second argument picks kinds of assertion: 1 concurrent, 2 simple immediate, 4 and 8 the two deferred kinds, 16 expect. Values 32 to 128 pick the unique and priority violation reports. The default, 255, is all of them.
The Directive-Type Filter
The third argument picks directives: 1 assert, 2 cover, 4 assume. Default 7 is all three. A plan can silence the design rules and keep the bench assumptions checking.
Levels and the List
The last two arguments work as for $assertoff: $assertcontrol(4, 15, 7, 0, tb.p1) switches off everything in tb.p1 and below. Verilator 5.052 ignores them, as it does for the older tasks, and acts on the whole design.
Try It
Three rules, three treatments. The safety check is locked, so the library's Off at 40 does nothing and the bug at 55 is caught. The design rule sleeps with the block. The bench assumption catches the request at 35 during the sleep.
Change the directive type in both calls from 1 to 5, assert and assume. Predict which count drops to 0.
crit=1 hs=1 env=1Check Yourself
Common Mistakes
Wrong Pass directive type 2 to switch the design assertions off.
Directive type 2 selects cover directives; assert is 1 and assume is 4.
Fix Use 1 for assert directives, or 5 for assert and assume.
$assertcontrol(4, 15, 2);$assertcontrol(4, 15, 1);Wrong Lock a check after a library may already have switched it off.
A lock freezes the current state, off included.
Fix Lock at time 0, before any other control runs.
Wrong Expect the levels and list arguments to limit a call on Verilator 5.052.
The tool ignores them and applies the call to the whole design.
Fix Filter by assertion type and directive type, which the tool follows, or use an enable input per instance.
Remember
$assertcontrol(control, assertion_type, directive_type, levels, list)is the general form of every control task.- Lock (1) freezes the state of the selected assertions until Unlock (2).
- Assertion type and directive type are bit masks: 1 concurrent, 2 immediate; 1 assert, 2 cover, 4 assume.
- Verilator 5.052 follows the type filters but ignores levels and the list.