From 0c6297a079795927ea2c85e884aaa57cd5a6ca30 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Tue, 3 Nov 2026 21:32:31 +0200 Subject: compile with verilator -Wall + I also found out that iverilog does not agree with Verilator that the testbenches work (the ones that iverilog can compile, anyway). That's rather annoying, I'm not quite sure what the root cause is. Timing difference in when registers are evaluated versus clock edges or something along those lines? --- src/rv2insn.sv | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/rv2insn.sv') diff --git a/src/rv2insn.sv b/src/rv2insn.sv index aeb7a8d..65abfab 100644 --- a/src/rv2insn.sv +++ b/src/rv2insn.sv @@ -28,12 +28,16 @@ function automatic insn_t halt(); return -1; endfunction -function automatic alu_counter_t next_alu(alu_counter_t alu_counter); - return (alu_counter + 1) % ALU_COUNT; +function automatic alu_counter_t next_alu(alu_counter_t c); + return (c + 1) % ALU_COUNT; endfunction -function automatic decode_out_t op_imm(xlen_t pc, itype_t rv, alu_counter_t alu_counter); - alu_counter_t fu = next_alu(alu_counter); +/** verilator warns about unused bits in rv, not sure how to deal with that. + * Explode itype to the relevant bits? Seems verbose, hmm. */ + +/* verilator lint_off UNUSEDSIGNAL */ +function automatic decode_out_t op_imm(xlen_t pc, itype_t rv, alu_counter_t c); + alu_counter_t fu = next_alu(c); unique case (rv.funct3) 3'b000: return {{`rn(rv.rs1), `alu(fu)}, {NOP, NOP}, @@ -45,9 +49,10 @@ function automatic decode_out_t op_imm(xlen_t pc, itype_t rv, alu_counter_t alu_ return 0; endfunction +/* verilator lint_on */ -function automatic decode_out_t op(xlen_t pc, rtype_t rv, alu_counter_t alu_counter); - alu_counter_t fu = next_alu(alu_counter); +function automatic decode_out_t op(xlen_t pc, rtype_t rv, alu_counter_t c); + alu_counter_t fu = next_alu(c); unique case (rv.funct3) 3'b000: begin unique case (rv.funct7) @@ -69,11 +74,11 @@ function automatic decode_out_t op(xlen_t pc, rtype_t rv, alu_counter_t alu_coun endcase endfunction -function automatic decode_out_t decode(xlen_t pc, rv_t rv, alu_counter_t alu_counter); +function automatic decode_out_t decode(xlen_t pc, rv_t rv, alu_counter_t c); unique case (rv[`RV_OP_FIELD]) - OP_IMM: return op_imm (pc, rv, alu_counter); - OP: return op (pc, rv, alu_counter); - default: return {halt(), alu_counter}; + OP_IMM: return op_imm (pc, rv, c); + OP: return op (pc, rv, c); + default: return {halt(), c}; endcase endfunction @@ -83,13 +88,13 @@ typedef struct packed { } stages_out_t; function automatic stages_out_t stages(int i, xlen_t pc, - rv_t[QUE_DEPTH-1:0] rv, insn_t[QUE_DEPTH-1:0] que, alu_counter_t alu_counter); + rv_t[QUE_DEPTH-1:0] rv, insn_t[QUE_DEPTH-1:0] que, alu_counter_t c); if (i < QUE_DEPTH) begin - decode_out_t out = decode(pc + i, rv[i], alu_counter); + decode_out_t out = decode(pc + i, rv[i], c); que[i] = out.insn; return stages(i + 1, pc, rv, que, out.alu_counter); end else begin - return {que, alu_counter}; + return {que, c}; end endfunction -- cgit v1.3