Counters, sticky flags and shadow registers
1. Counters: "how many are in flight?"
A block issues requests and later receives responses. The spec says at most MAX_OUT may be outstanding.
Count them in the testbench and the property is one line:
// outstanding = requests sent - responses received
logic [3:0] outstanding;
always_ff @(posedge clk)
if (rst) outstanding <= '0;
else outstanding <= outstanding + 4'(req_fire) - 4'(rsp_fire);
a_max_out: assert property (outstanding <= MAX_OUT);
a_no_orphan: assert property (rsp_fire |-> outstanding != 0); // no response without a request
a_stop_req: assert property (outstanding == MAX_OUT |-> !req_fire); // design must stop issuing
c_full_load: cover property (outstanding == MAX_OUT); // the model is exercised2. Sticky flags: "has it ever happened?"
A flag that is set by an event and never cleared (until reset) answers "since reset, has X happened?".
// configuration must be written before the first transfer is started
logic cfg_done;
always_ff @(posedge clk)
if (rst) cfg_done <= 1'b0;
else if (cfg_write) cfg_done <= 1'b1;
a_cfg_first: assert property (start |-> cfg_done || cfg_write);Variants clear the flag on a second event, which gives "X happened since the last Y" — for example "an error was reported since the last status read".
3. Shadow registers: "what was the last value?"
When an output must reflect a value written earlier, keep a copy:
// a status register must read back exactly what software last wrote
logic [7:0] shadow;
always_ff @(posedge clk)
if (rst) shadow <= 8'h00; // documented reset value
else if (wr_en && addr == CTRL) shadow <= wdata;
a_readback: assert property (rd_en && addr == CTRL |-> rdata == shadow);This is exactly how CSR apps (Chapter 7) work under the hood: one shadow per register field, generated from the register description.