Formal properties for a credit link
Here is a complete property set for a credit-based link, grouped by what each property protects.
| Property | Protects against | Form |
|---|---|---|
| No overdraft: send only with a credit | Sender ignoring its counter | tx_take |-> credits != 0 |
| Credit ceiling | Duplicated credits (double return) | credits <= DEPTH |
| No overflow | Data arriving at a full buffer | link_vld |-> rx_count < DEPTH |
| Conservation | Lost or created credits anywhere | sum of all locations == DEPTH |
| No deadlock | All credits lost | not (no credits and nothing in flight and buffer empty) |
| Work conserving | Sender stalling with credits in hand | tx_valid && credits != 0 |-> tx_take |
| Liveness (optional) | Starvation | tx_valid |-> s_eventually tx_take, with a fairness assumption on the consumer |
// credits on the forward link and on the return path are one bit each here
wire [7:0] total = 8'(credits) + 8'(link_vld) + 8'(rx_count) + 8'(cred_ret);
a_conserve: assert property (total == 8'(DEPTH));
a_no_overdraft: assert property (tx_take |-> credits != '0);
a_credit_max: assert property (credits <= CW'(DEPTH));
a_no_overflow: assert property (link_vld |-> rx_count < CW'(DEPTH));Deeper links: model the pipeline
With a link of several pipeline stages, "data in flight" is a count, not one bit. Write it as auxiliary code: a counter that goes up when the sender sends and down when data arrives at the receiver (and the same for returning credits). The conservation property keeps the same shape.
Liveness needs fairness
"The sender eventually sends" is only true if the receiver's consumer eventually pops. Without that, the tool shows a trivial counterexample: the consumer simply never reads. State the environment promise explicitly:
am_consumer_fair: assume property (rx_valid |-> s_eventually rx_pop);
a_tx_progress: assert property (tx_valid |-> s_eventually tx_take);Data integrity
Credit logic is about space. Check data separately with the tracked-item technique from Chapter 6: choose one arbitrary sent item, count the items in front of it across the link and the buffer, and check that it pops out unchanged and in order.