// credit_link_fv.sv — formal wrapper: conservation, overflow, overdraft, deadlock module credit_link_fv #( parameter int DEPTH = 4, parameter int W = 2, parameter bit BUG = 1'b0 ) ( input logic clk, input logic rst, input logic tx_valid, input logic [W-1:0] tx_data, input logic rx_pop ); localparam int CW = $clog2(DEPTH + 1); logic tx_take, rx_valid, link_vld, cred_ret; logic [W-1:0] rx_data; logic [CW-1:0] credits, rx_count; credit_link #(.DEPTH(DEPTH), .W(W), .BUG(BUG)) dut (.*); initial assume (rst); default clocking cb @(posedge clk); endclocking default disable iff (rst); // auxiliary: where are all the credits? 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)); a_no_deadlock: assert property (!(credits == '0 && rx_count == '0 && !link_vld && !cred_ret)); a_work_conserve: assert property (tx_valid && credits != '0 |-> tx_take); c_no_credits: cover property (credits == '0); c_buffer_full: cover property (rx_count == CW'(DEPTH)); c_send_and_ret: cover property (tx_take && cred_ret); c_full_drain: cover property (rx_count == CW'(DEPTH) ##[1:$] credits == CW'(DEPTH)); endmodule