Unstated Assumptions

Find the assumptions that nobody wrote: in a cell model, in a tool default and in a bench setting.

You Will Be Able To

  • Explain how a simplified cell model can hide a timing-dependent bug.
  • Predict what a multiply-driven net does in plain SBY, in this site's engine and in a simulator.
  • Decide whether logic that a bench cannot reach is dead or only out of scope.
  • List models, defaults and settings on the sign-off page.
Lesson
F10.3
Time
18 min
Runs on
SymbiYosys
Check
5 questions

A block gated its clock with a library cell. The formal library drew that cell as one AND gate. The proof said every requested cycle got its clock pulse. In silicon the enable arrived after the clock edge, and the real cell held it back for a whole cycle.

The latch keeps the late enable out of this cycle
01234clkfreewanttk0123phengclkrequest at tick 0en rises in the high phasetick 2: no pulse was seen
Scroll horizontally ↔

Measured with smtbmc yices at depth 20. en rises at step 2, when clk1 is already high. The latch is closed there, so gclk stays low for this cycle.

Below the Properties

What a Verdict Stands OnThe top row is what you wrote and reviewed. The bottom row is what came with the tool, the library and the bench. Every arrow feeds the verdict.
  • Property
  • Assumption
  • Result
  • Model
  • Structure
  • Analysis
What a verdict stands onThe top row is what you wrote and reviewed. The bottom row is what came with the tool, the library and the bench. Every arrow feeds the verdict. property Properties written and reviewed assumption Assumptions written and reviewed result PASS true undereverything on thispage model Cell and blockmodels a latch drawn as agate assumption Tool defaults two drivers tiedtogether assumption Bench settings a mode pin tied low
  1. property Propertieswritten and reviewed
    • Assumptions
  2. model Cell and block modelsa latch drawn as a gate
    • Properties
  3. assumption Assumptionswritten and reviewed
    • PASS
  4. assumption Tool defaultstwo drivers tied together
    • Assumptions
  5. result PASStrue under everything on this page
  6. assumption Bench settingsa mode pin tied low
    • PASS
Read the diagram as text
  • Properties: written and reviewed
  • Assumptions: written and reviewed
  • PASS: true under everything on this page
  • Cell and block models: a latch drawn as a gate
  • Tool defaults: two drivers tied together
  • Bench settings: a mode pin tied low
  • Properties → Assumptions
  • Assumptions → PASS
  • Cell and block models → Properties
  • Tool defaults → Assumptions
  • Bench settings → PASS

Nobody reviews the bottom row unless somebody writes it down.

A verdict depends on more than the properties and assumptions in your files. It also depends on three more things. They are the model of each cell, the defaults of the tool and the setup of the bench. Each of these can carry an assumption that nobody reviewed.

A Cell Drawn Simpler Than It Is

The cell as an AND gate

assign gclk = clk1 && en;

A late en still opens the gate for the rest of the high phase. "A wanted cycle gets a pulse": BMC PASS to depth 20.

The real cell: a latch, then the AND

always_latch if (!clk1) en_lat = en;
assign gclk = clk1 && en_lat;

The latch is open only while clk1 is low. A late en waits for the next cycle. The same check: FAIL at reported step 4.

Cell, on real gates in a simulatorPulses for an enable that changes while the clock is high
AND gateat 35, width 5; at 50, width 10; at 70, width 5
Latch, then ANDat 50, width 10; at 70, width 10

Icarus Verilog 12. The clock is high for 10 time units. The enable rises at 35 and falls at 75, both inside a high phase.

The AND model turns a late enable into a half-width pulse. A real flop may not clock on that. The proof counted it as a clock. The bug is the late enable, and the simple model hid it.

Run on cgAND modelLatch model
Late enable; a wanted cycle gets a pulseBMC PASS to depth 20FAIL at reported step 4
Late enable; every pulse is two ticks wideFAIL at reported step 3BMC PASS to depth 20
Enable moved to the low phase; a wanted cycle gets a pulse-BMC PASS to depth 20

Mode bmc, depth 20, smtbmc yices, reset assumed in step 0. One clk1 cycle is four ticks of the engine clock.

Two Drivers on One Net

Claim about w, with assign w = a; and assign w = b;Plain SBYMeaning
w == aPASSthe first driver wins?
w == bPASSthe second driver wins?
w == (a & b)PASSa wired AND?
a == bPASSthe two inputs are one signal

Mode bmc, depth 3, smtbmc yices, read_verilog and prep with no extra check. Yosys warns about "multiple conflicting drivers".

All four claims pass. Yosys joins the two drivers into one net, so in the formal model a and b are always equal. That is an assumption on two free inputs, and it sits in a warning line. A simulator resolves the same net to x when the drivers differ: a=1 b=1 w=1, a=1 b=0 w=x (Icarus 12).

This site's engine runs check -assert after elaboration and refuses the design. In your own flow, add that line or treat this warning as an error. Other tools pick other defaults, such as a wired AND. Find out which one yours uses.

Unreachable, and Still Needed

Bench for tmuxFunctional proofCover: shift in test mode
assume(!test_mode): the functional benchBMC PASS to depth 20Cover unreached within the depth
test_mode free-Cover reached, reported step 3

The scan path is used on the tester only. The functional bench ties test_mode low, as it should.

An unreached cover under a bench setting does not make the logic dead. The scan path, spare cells and feature-disable bits are all unreachable in a functional bench. Before you waive an unreachable item (F5.7), ask which setting made it unreachable.

Write the Bottom Row Down

ItemWhere it hidesHow to confirm it
Cell and block modelsthe formal library, a blackbox, a cutpointread the model against the real cell; run the checks the library asks for
Tool defaultsdriver resolution, initial values, unconnected pinsread the log for warnings; choose the stricter option
Bench settingsclock ratios, reset sequence, tied mode pinslist each one beside the assumptions
Out of scopetest mode, spare cells, disabled featuresname the flow that does verify them

These rows go on the sign-off page with the written assumptions (F7.3). A cut or a blackbox is a model too (F4.2).

Review the tool scripts with someone who knows the tool, as you review properties with someone who knows the design. When a setting has a strict choice and a forgiving one, start with the strict one.

Asked in Interviews

QuestionAnswer
Where can an assumption hide if it is not in an assume?In a cell or blackbox model, in a tool default and in a bench setting such as a tied pin.
A formal library models a clock gate as an AND gate. What can that hide?An enable that arrives while the clock is high. The real latch delays it by a cycle.
A net has two drivers. What does the proof mean?It depends on the tool. Plain Yosys ties the drivers together, which assumes they agree.
Is unreachable logic dead logic?Only if it is unreachable in the real environment. Test logic is unreachable in a functional bench and still needed.

Try It

The AND model in the bench

assign gclk = ph && en;

ph is clk1. en can change while ph is 1.

The latch model in the bench

reg en_lat=0;
always @(posedge clk)
  if (rst) en_lat <= 0;
  else if (!ph) en_lat <= en;
assign gclk = ph && en_lat;

en_lat only follows en in the low phase, so gclk is steady in the high phase.

The task. Depth stays at the default, 20.
[options]
mode bmc
depth 20
[engines]
smtbmc yices
[script]
read_verilog -formal -sv design.sv
prep -top cg
[files]
design.sv
  1. Run the AND model

    Run as it is: BMC PASS to depth 20. The request and the pulse are in the same cycle.

  2. Put the latch in

    Replace the gclk line with the latch model: FAIL at reported step 4. Read en and gclk around the failing step.

  3. Check the pulse width

    Go back to the AND model and assert that no pulse starts or stops at tick 1: FAIL at reported step 3.

  4. Fix the design

    Load en at tick 2, in the low phase, and sample the request there too. With the latch model: BMC PASS to depth 20.

design.sv

props.sv

Use assert property (@(posedge clk) ...);. Leave blank for immediate assertions in the design.

Inputs are free unless constrained. Run to find a counterexample or check a proof.

Model: one positive-edge clock, binary data. Sampled history requires declaration-initialized variables; primary-input history is unsupported.

SBY summary and log

Check Yourself

Predict the outputThe cg bench with the AND model and the late enable. One cover: a gclk pulse that starts at tick 1, in the middle of the high phase. Mode cover, default depth 20, smtbmc yices, reset assumed in step 0. The cover result is:
module cg(input clk, rst, want, output reg [1:0] tk=0, output ph, output reg en=0, output gclk);
  assign ph = !tk[1];                              // clk1: high in ticks 0 and 1
  always @(posedge clk) begin
    tk <= rst ? 2'd0 : tk + 2'd1;
    if (rst) en <= 0;
    else if (tk == 2'd0) en <= want;               // bug: the enable settles in the high phase
  end
  assign gclk = ph && en;                          // the cell drawn as an AND gate
`ifdef FORMAL
  always @(posedge clk) begin
    if ($initstate) begin assume(rst); end else begin assume(!rst); end
  end
  reg want_c=0;                                    // the request, as sampled with the enable
  reg pulse=0;                                     // a gclk tick was seen since the last tick 2
  reg gclk_q=0;
  always @(posedge clk) begin
    gclk_q <= gclk;
    if (tk == 2'd0) want_c <= !rst && want;
    pulse <= tk == 2'd2 ? 1'b0 : pulse || gclk;
    c_runt: cover(!rst && tk == 2'd1 && gclk && !gclk_q);       // a pulse that starts in the middle
  end
`endif
endmodule
ConceptPlain SBY proves w == a on a net w that is driven by a and by b. What did the proof assume?
Read the waveformIn this failing run of the latch model, why is there no gclk pulse in the cycle of the request?
The latch keeps the late enable out of this cycle
01234clkfreewanttk0123phengclkrequest at tick 0en rises in the high phasetick 2: no pulse was seen
Scroll horizontally ↔

Measured with smtbmc yices at depth 20. en rises at step 2, when clk1 is already high. The latch is closed there, so gclk stays low for this cycle.

ConceptYour functional bench ties test_mode low. A cover in the scan logic is unreached. What goes on the sign-off page?
ConceptA library ships a mux cell that is only correct when exactly one select is high. Its formal model is a plain two-input mux. What must your flow add?

Common Mistakes

Wrong Reading "multiple conflicting drivers" as a harmless warning.

The model ties the drivers together, so the proof assumes that they always agree.

Fix Fail the run on that warning, for example with check -assert in the Yosys script.

Wrong Modelling a cell by its logic function when the real cell has state.

A latch or a flop inside the cell changes when an input takes effect, and the simple model drops that.

Fix Model the state element, or prove the input timing that makes the simple model valid.

Before
// clock gate
assign gclk = clk && en;
After
// clock gate: latch, open while clk is low
always_latch if (!clk) en_lat = en;
assign gclk = clk && en_lat;

Wrong Waiving every unreached cover as dead code.

A cover can be unreached because a bench setting closed the path, not because the logic is unused.

Fix Free the setting and rerun the cover before you waive it.

Remember

  • A verdict stands on models, tool defaults and bench settings as well as on the files you wrote.
  • A cell model that drops a latch can hide an input that arrives at the wrong time.
  • Two drivers on a net: plain Yosys ties them together, and a simulator shows x.
  • Unreachable under a bench setting is out of scope, not dead.
  • List the bottom row on the sign-off page and review the tool scripts.

Practice

Report a problem with this page