Group nine unparenthesised sequences the way the precedence table, and so the simulator, groups them.
Hardware context: Unparenthesised assertion code read by a simulator. Group sequence operators the way the precedence table does.
Each question is an expression with no parentheses, and two ways to group it. Write answer(q) so it returns the option the standard uses: 0 or 1.
A simulator reads the code by the same table, so a wrong reading checks a different rule from the one you meant. Questions 0 to 2 are worked examples; questions 3 to 8 are graded only by the full check.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
question | 4 | input of each check |
Full specification
| q | Expression | Option 0 | Option 1 | Kind |
|---|---|---|---|---|
| 0 | req ##1 ack[*2] | req ##1 (ack[*2]) | (req ##1 ack)[*2] | worked example |
| 1 | a intersect b and c | a intersect (b and c) | (a intersect b) and c | worked example |
| 2 | a ##2 b ##1 c | (a ##2 b) ##1 c | a ##2 (b ##1 c) | worked example |
| 3 | req ##1 gnt and ready |-> done | (req ##1 (gnt and ready)) |-> done | ((req ##1 gnt) and ready) |-> done | graded |
| 4 | v throughout a ##1 b ##1 c | v throughout (a ##1 b ##1 c) | (v throughout a) ##1 b ##1 c | graded |
| 5 | v throughout a or b | (v throughout a) or b | v throughout (a or b) | graded |
| 6 | s ##1 a |-> b ##1 c | (s ##1 a) |-> (b ##1 c) | s ##1 (a |-> b ##1 c) | graded |
| 7 | a and b or c and d | a and (b or c) and d | (a and b) or (c and d) | graded |
| 8 | p within q ##1 r | (p within q) ##1 r | p within (q ##1 r) | graded |
Use IEEE 1800-2023 Table 16-1 for the sequence operators and Table 16-3 for the implications. Operators higher in a table bind tighter; within one row, the associativity decides. Operators on plain values, such as &&, || and !, bind tighter than every sequence operator.
Examples
Example 1
Repetition Before Delay- Input
answer(0)
- Output
option = 0
Repetition binds tightest, so [*2] applies to ack alone: option 0.
Example 2
Intersect Before And- Input
answer(1)
- Output
option = 1
intersect is higher in the table than and: option 1.
Example 3
## Groups to the Left- Input
answer(2)
- Output
option = 0
## is left-associative: option 0. Both groupings match the same traces, so here the rule changes nothing.
Constraints and Contract
- Return 0 or 1 for each question from answer(q).
- Keep the function header.
Hints
Hint 1
Find the row of each operator in Table 16-3. Which of the two sits higher?
Hint 2
## binds tighter than throughout, within, and and or.
Hint 3
Where do the implications sit in the table, compared with every sequence operator?
What the grader checks: Nine constant answers, graded against IEEE 1800-2023 Table 16-3. Five graded forms are also measured on Verilator 5.052 (tools/probes/sva-w1a/delays-precedence.mjs): each counts like the grouping the table gives.
9 checks on Verilator · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 6 steps and the final capstone