FVO — Formal Verification Online
Lesson 13.4 · Auxiliary Code and Modelling

Small reference models and scoreboards

Sometimes the spec is much simpler than the implementation. A priority encoder written with clever parallel logic, or a CRC computed four bits per cycle, has a one-line "obviously correct" description. Then the best property is:

output of the design == output of a simple model

Combinational reference: a function

function as reference model
// reference: index of the lowest set bit (simple loop, easy to review)
function automatic logic [2:0] ref_lowest(input logic [7:0] v);
  ref_lowest = '0;
  for (int i = 7; i >= 0; i--) if (v[i]) ref_lowest = 3'(i);
endfunction

a_matches_ref: assert property (|req |-> gnt_idx == ref_lowest(req));
a_none:        assert property (!(|req) |-> !gnt_valid);

Sequential reference: model only what you need

For a register file with 64 entries, a full reference model would double the state. Combine a reference with a symbolic address: remember only the last value written to one arbitrary address.

one-address scoreboard
(* anyconst *) logic [5:0] sym_addr;     // or: free input + $stable assumption
logic [31:0] ref_val;
logic        ref_valid;

always_ff @(posedge clk)
  if (rst)                               ref_valid <= 1'b0;
  else if (we && waddr == sym_addr) begin ref_valid <= 1'b1; ref_val <= wdata; end

a_read_back: assert property (ref_valid && re && raddr == sym_addr |=> rdata == $past(ref_val));

Note $past(ref_val): the read is issued in one cycle and the data appears in the next, so we compare with the model value from the read cycle. This models a memory that returns the old data when a read and a write to the same address happen together; a write-first memory would compare with ref_val instead. Getting such timing details right in the model is where most modelling bugs live — cover the corner case:

cover the corner case
c_rw_same: cover property (ref_valid && re && we && raddr == sym_addr && waddr == sym_addr);
Use a full reference model when…Use a partial / symbolic model when…
the spec is a short function of the inputsthe design stores a lot of data
state is small (a few flops)behaviour is the same for every address / ID
you can review the model in a minutea full model would double the proof complexity

Discussion

No comments yet.

Was this page helpful?

Tip: select any text on the page before clicking Report and it will be quoted in your report.