Skip to content

Commit cd1f6c5

Browse files
mndstrmrmarnovandermaas
authored andcommitted
[dv/formal] Remove buildspec.py
buildspec.py previously allowed us to cut out specific instructions from the specification, this allowed for faster build times and so a tighter feedback loop. Now, building and elaborating the Sail specification is fast enough that this is no longer necessary. We can therefore remove `ISS_instr and {ex,wbexc}_is_pres_instr, as weel as instrs.json. Also renames Sources.mk to sail-sources.mk for clarity.
1 parent 9e8b32a commit cd1f6c5

File tree

11 files changed

+82
-323
lines changed

11 files changed

+82
-323
lines changed

dv/formal/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ SAIL=sail
44

55
SAIL_RISCV_MODEL_DIR=${LOWRISC_SAIL_RISCV_SRC}/model
66

7-
include Sources.mk
7+
include sail-sources.mk
88

99
PSGEN_SRCS=thm/btype.proof thm/ibex.proof thm/mem.proof thm/riscv.proof
1010
PSGEN_FLAGS=-root riscv -task

dv/formal/buildspec.py

Lines changed: 0 additions & 107 deletions
This file was deleted.

dv/formal/check/encodings.sv

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
// Original author: Louis-Emile Ploix
55
// SPDX-License-Identifier: Apache-2.0
66

7-
`include "../build/ibexspec_instrs.sv"
8-
97
`ifndef CMP_INSNS
108
`define CMP_INSNS
119

@@ -21,25 +19,12 @@
2119
`IS_ORI | `IS_ANDI \
2220
)
2321

24-
`define ISS_ADDI (`IS_ADDI & `SPEC_ITYPE)
25-
`define ISS_SLTI (`IS_SLTI & `SPEC_ITYPE)
26-
`define ISS_SLTIU (`IS_SLTIU & `SPEC_ITYPE)
27-
`define ISS_XORI (`IS_XORI & `SPEC_ITYPE)
28-
`define ISS_ORI (`IS_ORI & `SPEC_ITYPE)
29-
`define ISS_ANDI (`IS_ANDI & `SPEC_ITYPE)
30-
3122
`define IS_SLLI (`IS_ITYPE(3'b001) && `INSTR[31:25] == 7'b0000000)
3223
`define IS_SRLI (`IS_ITYPE(3'b101) && `INSTR[31:25] == 7'b0000000)
3324
`define IS_SRAI (`IS_ITYPE(3'b101) && `INSTR[31:25] == 7'b0100000)
3425

3526
`define IS_SHIFTIOP (`IS_SLLI | `IS_SRLI | `IS_SRAI)
3627

37-
`define ISS_SLLI (`IS_SLLI & `SPEC_SHIFTIOP)
38-
`define ISS_SRLI (`IS_SRLI & `SPEC_SHIFTIOP)
39-
`define ISS_SRAI (`IS_SRAI & `SPEC_SHIFTIOP)
40-
41-
`define ISS_SHIFTIOP (`ISS_SLLI | `ISS_SRLI | `ISS_SRAI)
42-
4328
`define IS_RTYPE_0(idx) \
4429
(`INSTR[6:0] == 7'b0110011 && `INSTR[31:25] == 7'b0000000 && `INSTR[14:12] == idx)
4530
`define IS_RTYPE_1(idx) \
@@ -55,54 +40,27 @@
5540
`define IS_OR `IS_RTYPE_0(3'b110)
5641
`define IS_AND `IS_RTYPE_0(3'b111)
5742

58-
`define ISS_ADD (`IS_ADD & `SPEC_RTYPE)
59-
`define ISS_SUB (`IS_SUB & `SPEC_RTYPE)
60-
`define ISS_SLL (`IS_SLL & `SPEC_RTYPE)
61-
`define ISS_SLT (`IS_SLT & `SPEC_RTYPE)
62-
`define ISS_SLTU (`IS_SLTU & `SPEC_RTYPE)
63-
`define ISS_XOR (`IS_XOR & `SPEC_RTYPE)
64-
`define ISS_SRL (`IS_SRL & `SPEC_RTYPE)
65-
`define ISS_SRA (`IS_SRA & `SPEC_RTYPE)
66-
`define ISS_OR (`IS_OR & `SPEC_RTYPE)
67-
`define ISS_AND (`IS_AND & `SPEC_RTYPE)
68-
6943
`define IS_FENCETYPE(idx) ( \
7044
`INSTR[31:25] == 4'b0000 && `INSTR[19:15] == 5'b00000 && \
7145
`INSTR[11:0] == 12'b000000001111 && `INSTR[14:12] == idx)
7246
`define IS_FENCE (`INSTR[31:28] == 4'b0 && `INSTR[19:0] == 20'b0001111)
7347
`define IS_FENCEI (`INSTR == 32'h100f)
7448

75-
`define ISS_FENCE (`IS_FENCE & `SPEC_FENCE)
76-
`define ISS_FENCEI (`IS_FENCEI & `SPEC_FENCEI)
77-
7849
`define IS_LOAD(idx) (`INSTR[6:0] == 7'b0000011 && `INSTR[14:12] == idx)
7950
`define IS_LB `IS_LOAD(3'b000)
8051
`define IS_LH `IS_LOAD(3'b001)
8152
`define IS_LW `IS_LOAD(3'b010)
8253
`define IS_LBU `IS_LOAD(3'b100)
8354
`define IS_LHU `IS_LOAD(3'b101)
8455

85-
`define ISS_LB (`IS_LB & `SPEC_LOAD)
86-
`define ISS_LH (`IS_LH & `SPEC_LOAD)
87-
`define ISS_LW (`IS_LW & `SPEC_LOAD)
88-
`define ISS_LBU (`IS_LBU & `SPEC_LOAD)
89-
`define ISS_LHU (`IS_LHU & `SPEC_LOAD)
90-
9156
`define IS_STORE(idx) (`INSTR[6:0] == 7'b0100011 && `INSTR[14:12] == idx)
9257
`define IS_SB `IS_STORE(3'b000)
9358
`define IS_SH `IS_STORE(3'b001)
9459
`define IS_SW `IS_STORE(3'b010)
9560

96-
`define ISS_SB (`IS_SB & `SPEC_STORE)
97-
`define ISS_SH (`IS_SH & `SPEC_STORE)
98-
`define ISS_SW (`IS_SW & `SPEC_STORE)
99-
10061
`define IS_JAL (`INSTR[6:0] == 7'h6f)
10162
`define IS_JALR (`INSTR[6:0] == 7'h67 && `INSTR[14:12] == 3'b0)
10263

103-
`define ISS_JAL (`IS_JAL & `SPEC_RISCV_JAL)
104-
`define ISS_JALR (`IS_JALR & `SPEC_RISCV_JALR)
105-
10664
`define IS_MTYPE(idx) \
10765
(`INSTR[6:0] == 7'b0110011 && `INSTR[31:25] == 7'b0000001 && `INSTR[14:12] == idx)
10866
`define IS_MUL `IS_MTYPE(3'b000)
@@ -114,38 +72,14 @@
11472
`define IS_REM `IS_MTYPE(3'b110)
11573
`define IS_REMU `IS_MTYPE(3'b111)
11674

117-
`define ISS_MUL (`IS_MUL & `SPEC_MUL)
118-
`define ISS_MULH (`IS_MULH & `SPEC_MUL)
119-
`define ISS_MULHSH (`IS_MULHSH & `SPEC_MUL)
120-
`define ISS_MULHU (`IS_MULHU & `SPEC_MUL)
121-
`define ISS_DIV (`IS_DIV & `SPEC_DIV)
122-
`define ISS_DIVU (`IS_DIVU & `SPEC_DIV)
123-
`define ISS_REM (`IS_REM & `SPEC_REM)
124-
`define ISS_REMU (`IS_REMU & `SPEC_REM)
125-
12675
`define IS_CSR (`INSTR[6:0] == 7'b1110011 && (|`INSTR[13:12]))
12776
`define CSR_ADDR (`INSTR[31:20])
128-
`define ISS_CSR (`IS_CSR & `SPEC_CSR)
129-
13077
`define IS_ECALL (`INSTR == 32'b00000000000000000000000001110011)
131-
`define ISS_ECALL (`IS_ECALL & `SPEC_ECALL)
132-
13378
`define IS_EBREAK (`INSTR == 32'b00000000000100000000000001110011)
134-
`define ISS_EBREAK (`IS_EBREAK & `SPEC_EBREAK)
135-
13679
`define IS_LUI (`INSTR[6:0] == 7'b0110111)
137-
`define ISS_LUI (`IS_LUI & `SPEC_UTYPE)
138-
13980
`define IS_AUIPC (`INSTR[6:0] == 7'b0010111)
140-
`define ISS_AUIPC (`IS_AUIPC & `SPEC_UTYPE)
141-
14281
`define IS_BTYPE (`INSTR[6:0] == 7'b1100011 && (`INSTR[13] -> `INSTR[14]))
143-
`define ISS_BTYPE (`IS_BTYPE & `SPEC_BTYPE)
144-
14582
`define IS_MRET (`INSTR == 32'b00110000001000000000000001110011)
146-
`define ISS_MRET (`IS_MRET & `SPEC_MRET)
147-
14883
`define IS_WFI (`INSTR == 32'b00010000010100000000000001110011)
149-
`define ISS_WFI (`IS_WFI & `SPEC_WFI)
15084

15185
`endif

dv/formal/check/peek/compare_helper.sv

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ some of it is checking spec conformance.
1111

1212
`define INSTR wbexc_decompressed_instr
1313

14-
assign wbexc_is_pres_load_instr = `ISS_LB | `ISS_LBU | `ISS_LH | `ISS_LHU | `ISS_LW;
15-
assign wbexc_is_pres_store_instr = `ISS_SB | `ISS_SH | `ISS_SW;
16-
assign wbexc_is_pres_mem_instr = wbexc_is_pres_load_instr | wbexc_is_pres_store_instr;
17-
1814
assign wbexc_is_load_instr = `IS_LB | `IS_LBU | `IS_LH | `IS_LHU | `IS_LW;
1915
assign wbexc_is_store_instr = `IS_SB | `IS_SH | `IS_SW;
2016

@@ -29,15 +25,12 @@ assign ex_is_load_instr = `IS_LB | `IS_LBU | `IS_LH | `IS_LHU | `IS_LW;
2925
assign ex_is_store_instr = `IS_SB | `IS_SH | `IS_SW;
3026
assign ex_is_mem_instr = ex_is_load_instr | ex_is_store_instr;
3127

32-
assign ex_is_pres_load_instr = `ISS_LB | `ISS_LBU | `ISS_LH | `ISS_LHU | `ISS_LW;
33-
assign ex_is_pres_store_instr = `ISS_SB | `ISS_SH | `ISS_SW;
34-
assign ex_is_pres_mem_instr = ex_is_pres_load_instr | ex_is_pres_store_instr;
35-
36-
assign ex_is_pres_btype = `ISS_BTYPE;
37-
assign ex_is_pres_jump = `ISS_JAL | `ISS_JALR;
28+
assign ex_is_btype = `IS_BTYPE;
29+
assign ex_is_jump = `IS_JAL | `IS_JALR;
3830
assign ex_is_wfi = `IS_WFI;
3931
assign ex_is_rtype = `IS_ADD | `IS_SUB | `IS_SLL | `IS_SLT | `IS_SLTU | `IS_XOR | `IS_SRL | `IS_SRA | `IS_OR | `IS_AND;
4032
assign ex_is_div = `IS_DIV | `IS_DIVU | `IS_REM | `IS_REMU;
33+
assign ex_is_mtype = ex_is_div | `IS_MUL | `IS_MULH | `IS_MULHSH | `IS_MULHU;
4134
`undef INSTR
4235

4336
// real_write checks that there is a write and the dest reg is not x0
@@ -59,8 +52,6 @@ Select CSRs based on the current state of the follower, in particular:
5952
- In the case of an IRQ we compare the the CSRs about to be written now with the CSRs from the spec now
6053
*/
6154

62-
`define INSTR `CR.instr_rdata_id
63-
6455
logic use_curr_dut, use_curr_spec;
6556
assign use_curr_dut = wbexc_err | wbexc_handling_irq;
6657
assign use_curr_spec = wbexc_handling_irq;

dv/formal/check/top.sv

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,9 @@ logic [31:0] pre_mip;
196196
// - ex_P is 1 if P is true for the instruction in the ID/EX stage.
197197
// - wbexc_P is 1 if P is true for the instruction in the WB/EXC (exception) stage.
198198

199-
logic ex_is_wfi, ex_is_rtype, ex_is_div;
200-
logic ex_is_pres_btype, ex_is_pres_jump;
199+
logic ex_is_wfi, ex_is_rtype, ex_is_div, ex_is_mtype;
200+
logic ex_is_btype, ex_is_jump;
201201
logic ex_is_mem_instr, ex_is_load_instr, ex_is_store_instr;
202-
logic ex_is_pres_mem_instr, ex_is_pres_load_instr, ex_is_pres_store_instr;
203202

204203
// Have we branched, or are we branching in this cycle?
205204
logic ex_has_branched_d, ex_has_branched_q;
@@ -221,9 +220,7 @@ logic has_two_resp_waiting_q, has_two_resp_waiting_d;
221220
assign has_two_resp_waiting_q = data_mem_assume.outstanding_reqs_q == 8'h2;
222221
assign has_two_resp_waiting_d = data_mem_assume.outstanding_reqs == 8'h2;
223222

224-
logic wbexc_is_pres_load_instr, wbexc_is_pres_store_instr;
225-
logic wbexc_is_load_instr, wbexc_is_store_instr;
226-
logic wbexc_is_pres_mem_instr, wbexc_is_mem_instr;
223+
logic wbexc_is_load_instr, wbexc_is_store_instr, wbexc_is_mem_instr;
227224
logic wbexc_is_wfi;
228225

229226
logic [31:0] ex_compressed_instr;
@@ -233,7 +230,7 @@ logic ex_has_compressed_instr;
233230
logic wbexc_post_int_err; // Spec had an internal error
234231

235232
logic [31:0] wbexc_post_wX;
236-
logic [5:0] wbexc_post_wX_addr;
233+
logic [4:0] wbexc_post_wX_addr;
237234
logic wbexc_post_wX_en;
238235

239236
`define X(n) wbexc_post_``n
@@ -432,13 +429,6 @@ assign ex_is_checkable_csr = ~(
432429
(`CSR_ADDR == CSR_MCOUNTINHIBIT)
433430
);
434431

435-
`undef INSTR
436-
`define INSTR wbexc_decompressed_instr
437-
438-
// Illegal instructions aren't checkable unless the relevant specifications are present.
439-
logic can_check_illegal;
440-
assign can_check_illegal = `SPEC_ILLEGAL & `SPEC_CSR & `SPEC_MRET & `SPEC_WFI;
441-
442432
`undef INSTR
443433

444434
////////////////////// Decompression Invariant Defs //////////////////////

dv/formal/instrs.json

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)