A2.3.2 Legal Declarations

MediumDebugVerilator · serverReview the topic

For nine sequence and property declarations, say whether the standard allows each one and whether Verilator 5.052 compiles it.

Hardware context: Named sequence and property declarations for a handshake checker library. Tell legal declarations from illegal ones, and the standard from what one simulator accepts.

Each question is one declaration and one assertion that uses it, placed in the same small module. Some are legal, some are not, and the simulator does not always agree with the standard.

Write answer(q). Bit 0 says whether IEEE 1800-2023 allows the code. Bit 1 says whether Verilator 5.052 compiles it.

Questions 0 to 2 are worked examples. Questions 3 to 8 are graded only by the full check.

Signals in the Timeline

SignalWidthRole
question4input of each check
Full specification
The module around each question: <declaration> and <use> change
module tb;
  logic clk = 0, a = 0, b = 0, c = 0, rst = 0;
  always #5 clk = ~clk;
  <declaration>
  <use>
  initial #20 $finish;
endmodule
qDeclarationUseKind
0sequence s; a ##1 b[*2]; endsequencea1: assert property (@(posedge clk) c |=> s);worked example
1sequence s; a until b; endsequencea1: assert property (@(posedge clk) s);worked example
2property p(x, y); x |=> y; endpropertya1: assert property (@(posedge clk) p(a, b));worked example
3property hs; a ##1 b; endproperty sequence s; hs ##1 c; endsequencea1: assert property (@(posedge clk) s);graded
4property resp_by(x, y, int n = 2); x |-> ##[1:n] y; endpropertya1: assert property (@(posedge clk) resp_by(a, b));graded
5property after_n(int n, d); d; endpropertya1: assert property (@(posedge clk) after_n(a ##1 b, c));graded
6property then_done(sequence q, d); q |=> d; endpropertya1: assert property (@(posedge clk) then_done(a ##1 b, c));graded
7sequence later(n); a ##n b; endsequencea1: assert property (@(posedge clk) later(2));graded
8sequence pair(logic x, logic y); x ##1 y; endsequencea1: assert property (@(posedge clk) pair(.y(b), .x(a)));graded

Examples

Example 1

A Plain Named Sequence
Input
answer(0)
Output
answer = 3

Delays and repetitions are sequence operators, so the declaration is legal, and Verilator 5.052 compiles it: 1 + 2 = 3.

Example 2

A Property Operator in a Sequence
Input
answer(1)
Output
answer = 0

until is a property operator (16.12.12), so a sequence cannot hold it: illegal. Verilator 5.052 rejects it too: 0.

Example 3

A Property with Untyped Formals
Input
answer(2)
Output
answer = 3

Untyped formals of a property are legal and Verilator 5.052 compiles them: 3.

Constraints and Contract

  • Return one value from 0 to 3 per question from answer(q).
  • Keep the function header.

Hints

Hint 1

Which operators belong only to properties? A sequence cannot hold them, nor an instance of a property.

Hint 2

A typed formal casts its actual to the type. Can a sequence be cast to an int?

Hint 3

The lesson lists four legal forms that Verilator 5.052 rejects, and one silent narrowing.

What the grader checks: Nine constant answers. Bit 1 of each key is measured on Verilator 5.052; bit 0 follows IEEE 1800-2023 16.8, 16.8.1 and 16.12.

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 3 steps and the final capstone

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

A Plain Named Sequence

Input
answer(0)
Expected output
answer = 3

Delays and repetitions are sequence operators, so the declaration is legal, and Verilator 5.052 compiles it: 1 + 2 = 3.

Run samples executes all 3 public checks. Check all tests runs 9 checks on the server.

Verilator · server