Skip to content

Commit 2c3519e

Browse files
committed
Refine fazyrv_pc formal checks
1 parent a8e5403 commit 2c3519e

4 files changed

Lines changed: 28 additions & 23 deletions

File tree

fv/pc/fazyrv_pc_bmc.sby

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
[options]
33
mode bmc
4-
depth 80
4+
depth 200
55

66
[engines]
77
smtbmc z3

fv/pc/fazyrv_pc_cov.sby

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
[options]
33
mode cover
4-
depth 80
4+
depth 200
55

66
[engines]
77
smtbmc z3

fv/pc/fazyrv_pc_fv.sv

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,14 @@ end
6363

6464
// Remember shifted in data
6565
//
66-
logic [31:0] fv_din = 'b0;
66+
logic [31:0] fv_din = 2'b11;
6767
always_ff @(posedge clk_i) fv_din <= {din, fv_din[31:CHUNKSIZE]};
6868

69+
// We can safely assume the PC does not overflow
70+
always_ff @(posedge clk_i) begin
71+
if (fv_cycle_check) assume (fv_din != 32'hFFFF_FFFF);
72+
end
73+
6974
logic [31:0] fv_pcinc = 'b0;
7075
always_ff @(posedge clk_i) fv_pcinc <= {pc_ser_inc, fv_pcinc[31:CHUNKSIZE]};
7176

@@ -85,7 +90,7 @@ fazyrv_pc #(
8590
.rst_in ( rst_in ),
8691
// Continuous inc to strobe; handle here for simplicity
8792
.inc_i ( inc & fv_cycle_lsb & fv_pc_op ),
88-
.shift_i ( shift & fv_pc_op ),
93+
.shift_i ( shift & fv_pc_op ),
8994
.din_i ( din ),
9095
.pc_ser_o ( pc_ser ),
9196
.pc_ser_inc_o ( pc_ser_inc ),
@@ -101,8 +106,6 @@ always_comb begin
101106
if (inc) assume(shift);
102107
// Assume normal pc increment
103108
if (inc) assume(din == pc_ser_inc);
104-
// Loading PC, assume data != 0 for easier debugging
105-
if (shift & ~inc) assume(din != 'b0);
106109
end
107110

108111

@@ -152,18 +155,22 @@ end
152155

153156
always_ff @(posedge clk_i) begin
154157
cover (rst_in);
155-
cover (rst_in & (pc == BOOTADR));
156-
cover (fv_cycle_check);
157-
cover (fv_cycle_check && $past(inc));
158-
cover (fv_cycle_check && $past(shift));
159-
cover (fv_cycle_check & (~inc & ~shift));
160-
cover (fv_cycle_check & (inc != $past(inc)));
161-
158+
cover (rst_in && (pc == BOOTADR));
159+
cover (rst_in && fv_cycle_check);
160+
cover (rst_in && fv_cycle_check && $past(inc));
161+
cover (rst_in && fv_cycle_check && $past(shift));
162+
163+
cover (rst_in && fv_cycle_check & (inc != $past(inc)));
164+
cover (rst_in && fv_cycle_check && (fv_pcinc == 32'h0000_00F3) && $past(inc));
165+
cover (rst_in && fv_cycle_check && (fv_pcinc == 32'h0000_FF03) && $past(inc));
166+
cover (rst_in && fv_cycle_check && (fv_pcinc == 32'hFFFF_FFF3) && $past(inc));
167+
cover (rst_in && fv_cycle_check && (fv_pcinc == 32'h0000_FF03) && $past(inc));
168+
cover (rst_in && fv_cycle_check && (fv_pcinc == 32'hFFFF_FFF3) && $past(inc));
162169
//
163-
cover ($past(shift) & $past(inc) & (pc == fv_prev_pc + 'd4));
164-
cover ($past(shift) & $past(inc) & (pc == fv_pcinc));
165-
cover ($past(shift) & (pc == fv_din));
166-
cover ($past(shift) & (fv_prev_pc == fv_pcser));
170+
cover (rst_in && fv_cycle_check && $past(shift) && $past(inc) && (pc == fv_prev_pc + 'd4));
171+
cover (rst_in && fv_cycle_check && $past(shift) && $past(inc) && (pc == fv_pcinc));
172+
cover (rst_in && fv_cycle_check && $past(shift) && (pc == fv_din));
173+
cover (rst_in && fv_cycle_check && $past(shift) && (fv_prev_pc == fv_pcser));
167174
end
168175

169176
endmodule

rtl/fazyrv_pc.sv

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023 - 2024 Meinhard Kissich
1+
// Copyright (c) 2023 - 2025 Meinhard Kissich
22
// SPDX-License-Identifier: MIT
33
// -----------------------------------------------------------------------------
44
// File : fazyrv_pc.sv
@@ -11,7 +11,7 @@
1111
// Ports
1212
// - clk_i Clock input, sensitive to rising edge.
1313
// - rst_in Reset, low active.
14-
// - inc_i Strobe to increment PC in the subsequent cylce.
14+
// - inc_i Strobe to increment PC in the subsequent cycle.
1515
// - shift_i Shift PC register.
1616
// - din_i New input data part when PC is shifted.
1717
// - pc_ser_o Serial output part of PC register.
@@ -31,11 +31,9 @@ module fazyrv_pc #( parameter CHUNKSIZE=2, parameter BOOTADR=32'hFFFF )
3131
output logic [31:0] pc_o
3232
);
3333

34-
// restrictions: pc currenctly must be %4
35-
// otherwise opt with carry does not work
3634

3735
logic [31:0] pc_r, pc_n;
38-
logic [CHUNKSIZE-1:0] pc_inc;
36+
logic [CHUNKSIZE-1:0] pc_inc;
3937

4038
assign pc_o = pc_r;
4139
assign pc_ser_o = pc_r[CHUNKSIZE-1:0];
@@ -87,7 +85,7 @@ generate
8785
end else begin
8886
assign b = carry_vec[i];
8987
end
90-
// a, b, y, c
88+
// a, b, y, c
9189
fazyrv_hadd i_hadd (pc_r[i], b, pc_inc[i], carry_vec[i+1]);
9290
end
9391
endgenerate

0 commit comments

Comments
 (0)