A9.1.1 Assume the Environment

MediumDebugIcarus · browser samples / server checksReview the topic

Five formal runs of one opcode decoder with different assumptions. Say which pass, which fail, and which covers are reached.

Hardware context: An opcode decoder proved with different environment assumptions. Tell an honest assumption from one that hides a bug or removes real behaviour.

An opcode decoder flags opcode 3 as an error and raises busy for opcode 1. The bench never sends opcode 3. One version has a bug: two op-2 in a row also flag an error. Five formal runs check it with different assumptions.

Write answer(q). For questions 3 to 7, return 1 if the run passes or its cover is reached. Return 0 if it fails or its cover is unreached.

Questions 0 to 2 are worked examples on the requester design. Questions 3 to 7 are graded only by the full check.

Signals in the Timeline

SignalWidthRole
question4input of each check
Full specification
The decoder. The buggy version adds the op-2 term.
module top(input clk, input [1:0] op, output reg err = 0, output reg busy = 0);
  reg [1:0] last = 0;                            // the previous opcode
  always @(posedge clk) begin
    err  <= (op == 2'd3) || (op == 2'd2 && last == 2'd2);   // a bug: two op-2 in a row also flag an error
    busy <= (op == 2'd1);
    last <= op;
  end
endmodule
q=3: Correct decoder, assume op != 3. Mode prove, depth 4, smtbmc yices. props.sv:
legal_op: assume property (@(posedge clk) op != 2'd3);
no_err: assert property (@(posedge clk) !err);
q=4: Buggy decoder, assume op != 3. Mode bmc, depth 12, smtbmc yices. props.sv:
legal_op: assume property (@(posedge clk) op != 2'd3);
no_err: assert property (@(posedge clk) !err);
q=5: Buggy decoder, assume !err. Mode bmc, depth 12, smtbmc yices. props.sv:
out_rule: assume property (@(posedge clk) !err);
no_err: assert property (@(posedge clk) !err);
q=6: Correct decoder, assume op == 0, cover busy. Mode cover, depth 10, smtbmc yices. props.sv:
only_nop: assume property (@(posedge clk) op == 2'd0);
c_busy: cover property (@(posedge clk) busy);
q=7: Correct decoder, no assumption. Mode bmc, depth 10, smtbmc yices. props.sv:
no_err: assert property (@(posedge clk) !err);
The worked examples, questions 0 to 2: the requester
module top(input clk, input want, output reg tok = 0, output req0, output req1);
  always @(posedge clk) if (want) tok <= !tok;
  assign req0 = want && !tok;
  assign req1 = want && tok;
endmodule
q=0: Requester, its guarantee. Mode prove, depth 4, smtbmc yices. props.sv:
one_req: assert property (@(posedge clk) !(req0 && req1));
q=1: Requester, assume !want, cover req1. Mode cover, depth 10, smtbmc yices. props.sv:
no_want: assume property (@(posedge clk) !want);
c_req1: cover property (@(posedge clk) req1);
q=2: Requester, assume want, cover req1. Mode cover, depth 10, smtbmc yices. props.sv:
all_want: assume property (@(posedge clk) want);
c_req1: cover property (@(posedge clk) req1);

Simulator note: Every key was measured with the formal engine v1 (SymbiYosys, smtbmc yices). Your answer function is checked by a small bench on Icarus 12.

Examples

Example 1

Requester, Its Guarantee
Input
answer(0)
Output
answer = 1

Proved: the token never lets both requests rise.

Example 2

Requester, Assume !want, Cover req1
Input
answer(1)
Output
answer = 0

No want, no request: the cover is unreached.

Example 3

Requester, Assume Want, Cover req1
Input
answer(2)
Output
answer = 1

With want held high the token alternates, so req1 rises: reached.

Constraints and Contract

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

Hints

Hint 1

An assumption removes input sequences. It cannot remove a bug that legal inputs reach.

Hint 2

An assumption on an output removes the design's own behaviour, bugs included.

Hint 3

A cover on a normal event tells you whether an assumption left that event possible.

What the grader checks: Eight constant answers: three worked examples and five graded questions, each the result of one real formal run.

8 checks on Icarus · browser samples / server checks. 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

Requester, Its Guarantee

Input
answer(0)
Expected output
answer = 1

Proved: the token never lets both requests rise.

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

Icarus · browser samples / server checks