Skip to content

Commit 9ae49b1

Browse files
authored
treewide: Add Spyglass flow and fix reported violations (#313)
- Add Spyglass lint flow and bump nonfree repo - Fix all Spyglass lint errors and warnings - Remove redundant $signed conversions - Protect against negative array bounds when using default parameter values - Derive dependent type parameters - Fix bug in hive's PTW request connections - Make `snitch_cluster_pkg.sv` a required source of the cluster, no longer required only by the cluster wrapper and test harness - Bump OSEDA version to 2026.02 to include Verilator fix verilator/verilator#6824 - Add nonfree `pysynthutils` Python package dependency - Add Spyglass lint checks (based on pysynthutils) to Gitlab CI - Increase Yosys synthesis timeout to 3h in Gitlab CI
1 parent 53c8398 commit 9ae49b1

39 files changed

Lines changed: 391 additions & 359 deletions

.github/actions/setup-python/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ runs:
2525
- name: Sync Python environment
2626
shell: sh
2727
run: |
28-
uv sync --all-extras --locked
28+
uv sync --extra all --locked

.gitlab-ci.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ snitch-ip-tests:
7373
- snitch_ssr
7474
- reqrsp_interface
7575
script:
76+
- make rtl -j
7677
- cd hw/$IP
7778
- ./util/compile.sh
7879
- ./util/run_vsim.sh
@@ -176,7 +177,7 @@ snitch-cluster-copift-sc-vsim:
176177
###################################
177178

178179
yosys-synthesis:
179-
timeout: 2h
180+
timeout: 4h
180181
script:
181182
- make CFG_OVERRIDE=cfg/yosys-ci.json yosys
182183
# Following steps are not included in open-source CI since netlist
@@ -185,11 +186,20 @@ yosys-synthesis:
185186
- make sw -j
186187
- make vsim-run SN_BINARY=$PWD/sw/tests/build/simple.elf
187188

188-
################################
189-
# Non-free implementation flow #
190-
################################
189+
#################
190+
# Non-free jobs #
191+
#################
191192

192-
nonfree:
193+
# Non-free elaboration flow
194+
elab:
193195
script:
194196
- make nonfree
195197
- make elab
198+
199+
# Spyglass lint
200+
spyglass:
201+
script:
202+
- make nonfree
203+
- make spyglass
204+
- util/lint/check_spyglass_lint.py --threshold 3
205+
nonfree/lint/build/sg_projects/snitch_cluster/snitch_cluster/lint/lint_rtl/spyglass_reports/moresimple.rpt

Bender.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ sources:
171171
# snitch_cluster
172172
- files:
173173
# Level 0
174+
- hw/generated/snitch_cluster_pkg.sv
174175
- hw/snitch_cluster/src/snitch_amo_shim.sv
175176
- hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral_reg_pkg.sv
176177
- hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral_reg.sv
@@ -200,9 +201,6 @@ sources:
200201
- target/sim/tb/tb_bin.sv
201202

202203
# target/snitch_cluster
203-
- target: snitch_cluster_wrapper
204-
files:
205-
- hw/generated/snitch_cluster_pkg.sv
206204
- target: all(snitch_cluster_wrapper, not(netlist))
207205
files:
208206
- hw/generated/snitch_cluster_wrapper.sv

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ clean-rtl: sn-clean-rtl
141141
############
142142

143143
NONFREE_REMOTE ?= git@iis-git.ee.ethz.ch:pulp-restricted/snitch-cluster-nonfree.git
144-
NONFREE_COMMIT ?= 45ffdbd53f04cafbcd8369bbcaf04b3ee8a90b31
144+
NONFREE_COMMIT ?= 3da8864984e3dafbc63ce5de13f5e1fdaa135ac7
145145
NONFREE_DIR = $(SN_ROOT)/nonfree
146146

147147
.PHONY: nonfree clean-nonfree

hw/reqrsp_interface/src/reqrsp_iso.sv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module reqrsp_iso #(
4545
typedef logic [AddrWidth-1:0] addr_t;
4646
typedef logic [DataWidth-1:0] data_t;
4747
typedef logic [DataWidth/8-1:0] strb_t;
48-
typedef logic [UserWidth-1:0] user_t;
48+
typedef logic [cf_math_pkg::iomsb(UserWidth):0] user_t;
4949

5050
`REQRSP_TYPEDEF_ALL(reqrsp, addr_t, data_t, strb_t, user_t)
5151

@@ -115,7 +115,7 @@ module reqrsp_iso_intf #(
115115
typedef logic [AddrWidth-1:0] addr_t;
116116
typedef logic [DataWidth-1:0] data_t;
117117
typedef logic [DataWidth/8-1:0] strb_t;
118-
typedef logic [UserWidth-1:0] user_t;
118+
typedef logic [cf_math_pkg::iomsb(UserWidth):0] user_t;
119119

120120
`REQRSP_TYPEDEF_ALL(reqrsp, addr_t, data_t, strb_t, user_t)
121121

hw/reqrsp_interface/src/reqrsp_to_axi.sv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ module reqrsp_to_axi import reqrsp_pkg::*; import snitch_pkg::*; #(
172172
assign axi_req_o.ar.burst = axi_pkg::BURST_INCR;
173173
assign axi_req_o.ar.lock = (reqrsp_req_i.q.amo == AMOLR);
174174
assign axi_req_o.ar.cache = axi_pkg::CACHE_MODIFIABLE;
175-
assign axi_req_o.ar.id = $unsigned(ID);
175+
assign axi_req_o.ar.id = ID;
176176
assign axi_req_o.ar.user = reqrsp_req_i.q.user;
177177
assign axi_req_o.ar_valid = q_valid_read;
178178
assign q_ready_read = axi_rsp_i.ar_ready;
@@ -187,7 +187,7 @@ module reqrsp_to_axi import reqrsp_pkg::*; import snitch_pkg::*; #(
187187
assign axi_req_o.aw.burst = axi_pkg::BURST_INCR;
188188
assign axi_req_o.aw.lock = (reqrsp_req_i.q.amo == AMOSC);
189189
assign axi_req_o.aw.cache = axi_pkg::CACHE_MODIFIABLE;
190-
assign axi_req_o.aw.id = $unsigned(ID);
190+
assign axi_req_o.aw.id = ID;
191191
assign axi_req_o.aw.user = reqrsp_req_i.q.user;
192192
assign axi_req_o.w.data = write_data;
193193
assign axi_req_o.w.strb = reqrsp_req_i.q.strb;

hw/snitch/src/snitch.sv

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3605,13 +3605,13 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
36053605
alu_result = {30'b0, ~adder_result[32]};
36063606
end
36073607
Sltu: begin
3608-
alu_opa = $unsigned(opa);
3609-
alu_opb = -$unsigned(opb);
3608+
alu_opa = opa;
3609+
alu_opb = -opb;
36103610
alu_result = {30'b0, adder_result[32]};
36113611
end
36123612
Geu: begin
3613-
alu_opa = $unsigned(opa);
3614-
alu_opb = -$unsigned(opb);
3613+
alu_opa = opa;
3614+
alu_opb = -opb;
36153615
alu_result = {30'b0, ~adder_result[32]};
36163616
end
36173617
Sll: begin
@@ -3683,8 +3683,8 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
36833683
assign ptw_req_o[1].va = '0;
36843684
end
36853685

3686-
assign ptw_req_o[0].ppn = $unsigned(satp_q.ppn);
3687-
assign ptw_req_o[1].ppn = $unsigned(satp_q.ppn);
3686+
assign ptw_req_o[0].ppn = satp_q.ppn;
3687+
assign ptw_req_o[1].ppn = satp_q.ppn;
36883688

36893689
// Translation is active if it is set in SATP and we are not in machine mode or debug mode.
36903690
assign trans_active = satp_q.mode & (priv_lvl_q != PrivLvlM) & ~debug_q;
@@ -3710,7 +3710,7 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
37103710
// --------------------
37113711
data_t lsu_qdata;
37123712
// sign exten to appropriate length
3713-
assign lsu_qdata = $unsigned((ls_amo == AMONone) ? opc : opb);
3713+
assign lsu_qdata = (ls_amo == AMONone) ? opc : opb;
37143714

37153715
// Consider CAQ in accelerator handshake when offloading an FPU load or store.
37163716
assign caq_ena = is_fp_load | is_fp_store;

hw/snitch/src/snitch_l0_tlb.sv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@ module snitch_l0_tlb import snitch_pkg::*; #(
5555
/// This is a 4 mega page entry.
5656
logic is_4mega;
5757
} tag_t;
58-
tag_t [NrEntries-1:0] tag_d, tag_q;
59-
logic [NrEntries-1:0] is_4mega_exp; //expanded version
58+
tag_t [cf_math_pkg::iomsb(NrEntries):0] tag_d, tag_q;
59+
logic [cf_math_pkg::iomsb(NrEntries):0] is_4mega_exp; //expanded version
6060
logic is_4mega;
6161
// Tag is valid array.
62-
logic [NrEntries-1:0] tag_valid_d, tag_valid_q;
62+
logic [cf_math_pkg::iomsb(NrEntries):0] tag_valid_d, tag_valid_q;
6363
logic [$clog2(NrEntries+1)-1:0] evict_d, evict_q;
6464

65-
l0_pte_t [NrEntries-1:0] pte_q, pte_d;
65+
l0_pte_t [cf_math_pkg::iomsb(NrEntries):0] pte_q, pte_d;
6666

6767
l0_pte_t pte;
6868

6969
`FFAR(tag_valid_q, tag_valid_d, '0, clk_i, rst_i)
7070
`FFAR(tag_q, tag_d, '0, clk_i, rst_i)
7171
`FFAR(pte_q, pte_d, '0, clk_i, rst_i)
7272

73-
logic [NrEntries-1:0] hit;
73+
logic [cf_math_pkg::iomsb(NrEntries):0] hit;
7474
logic miss_d, miss_q; // we got a miss
7575
logic refill_d, refill_q; // refill request is underway
7676

hw/snitch/src/snitch_lsu.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ module snitch_lsu import cf_math_pkg::*; #(
273273

274274
// Re-align write data.
275275
/* verilator lint_off WIDTH */
276-
assign lsu_qdata = $unsigned(lsu_qdata_i);
276+
assign lsu_qdata = lsu_qdata_i;
277277
always_comb begin
278278
unique case (lsu_qaddr_i[DataAlign-1:0])
279279
3'b000: data_qdata = lsu_qdata;

hw/snitch_cluster/src/snitch_amo_shim.sv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ module snitch_amo_shim
186186
// Atomics
187187
// -------
188188
logic [63:0] wdata;
189-
assign wdata = $unsigned(wdata_i);
189+
assign wdata = wdata_i;
190190

191191
`FF(state_q, state_d, Idle)
192192
`FFL(amo_op_q, amo_i, load_amo, AMONone, clk_i, rst_ni)
@@ -295,13 +295,13 @@ module snitch_amo_alu import snitch_pkg::*; (
295295
result_o = adder_sum[32] ? operand_a_i : operand_b_i;
296296
end
297297
AMOMaxu: begin
298-
adder_operand_a = $unsigned(operand_a_i);
299-
adder_operand_b = -$unsigned(operand_b_i);
298+
adder_operand_a = operand_a_i;
299+
adder_operand_b = -operand_b_i;
300300
result_o = adder_sum[32] ? operand_b_i : operand_a_i;
301301
end
302302
AMOMinu: begin
303-
adder_operand_a = $unsigned(operand_a_i);
304-
adder_operand_b = -$unsigned(operand_b_i);
303+
adder_operand_a = operand_a_i;
304+
adder_operand_b = -operand_b_i;
305305
result_o = adder_sum[32] ? operand_a_i : operand_b_i;
306306
end
307307
default: result_o = '0;

0 commit comments

Comments
 (0)