Remote ENABLE_REGS_DUALPORT and init reg zero.

This commit is contained in:
colin.liang 2023-01-12 16:09:10 +08:00
parent 8b3d3390f5
commit af85947a58
1 changed files with 51 additions and 83 deletions

View File

@ -52,7 +52,6 @@
module picorv32 #( module picorv32 #(
parameter [ 0:0] ENABLE_REGS_16_31 = 1, parameter [ 0:0] ENABLE_REGS_16_31 = 1,
parameter [ 0:0] ENABLE_REGS_DUALPORT = 1,
parameter [ 0:0] LATCHED_MEM_RDATA = 0, parameter [ 0:0] LATCHED_MEM_RDATA = 0,
parameter [ 0:0] TWO_STAGE_SHIFT = 1, parameter [ 0:0] TWO_STAGE_SHIFT = 1,
parameter [ 0:0] BARREL_SHIFTER = 0, parameter [ 0:0] BARREL_SHIFTER = 0,
@ -66,7 +65,6 @@ module picorv32 #(
parameter [ 0:0] ENABLE_IRQ_QREGS = 1, parameter [ 0:0] ENABLE_IRQ_QREGS = 1,
parameter [ 0:0] ENABLE_IRQ_TIMER = 1, parameter [ 0:0] ENABLE_IRQ_TIMER = 1,
parameter [ 0:0] ENABLE_TRACE = 0, parameter [ 0:0] ENABLE_TRACE = 0,
parameter [ 0:0] REGS_INIT_ZERO = 0,
parameter [31:0] MASKED_IRQ = 32'h 0000_0000, parameter [31:0] MASKED_IRQ = 32'h 0000_0000,
parameter [31:0] LATCHED_IRQ = 32'h ffff_ffff, parameter [31:0] LATCHED_IRQ = 32'h ffff_ffff,
parameter [31:0] PROGADDR_RESET = 32'h 0000_0000, parameter [31:0] PROGADDR_RESET = 32'h 0000_0000,
@ -153,14 +151,6 @@ module picorv32 #(
`ifndef PICORV32_REGS `ifndef PICORV32_REGS
reg [31:0] cpuregs [0:regfile_size-1]; reg [31:0] cpuregs [0:regfile_size-1];
integer i;
initial begin
if (REGS_INIT_ZERO) begin
for (i = 0; i < regfile_size; i = i+1)
cpuregs[i] = 0;
end
end
`endif `endif
task empty_statement; task empty_statement;
@ -964,7 +954,6 @@ module picorv32 #(
always @* begin always @* begin
decoded_rs = 'bx; decoded_rs = 'bx;
if (ENABLE_REGS_DUALPORT) begin
`ifndef RISCV_FORMAL_BLACKBOX_REGS `ifndef RISCV_FORMAL_BLACKBOX_REGS
cpuregs_rs1 = decoded_rs1 ? cpuregs[decoded_rs1] : 0; cpuregs_rs1 = decoded_rs1 ? cpuregs[decoded_rs1] : 0;
cpuregs_rs2 = decoded_rs2 ? cpuregs[decoded_rs2] : 0; cpuregs_rs2 = decoded_rs2 ? cpuregs[decoded_rs2] : 0;
@ -972,23 +961,15 @@ module picorv32 #(
cpuregs_rs1 = decoded_rs1 ? $anyseq : 0; cpuregs_rs1 = decoded_rs1 ? $anyseq : 0;
cpuregs_rs2 = decoded_rs2 ? $anyseq : 0; cpuregs_rs2 = decoded_rs2 ? $anyseq : 0;
`endif `endif
end else begin
decoded_rs = (cpu_state == cpu_state_ld_rs2) ? decoded_rs2 : decoded_rs1;
`ifndef RISCV_FORMAL_BLACKBOX_REGS
cpuregs_rs1 = decoded_rs ? cpuregs[decoded_rs] : 0;
`else
cpuregs_rs1 = decoded_rs ? $anyseq : 0;
`endif
cpuregs_rs2 = cpuregs_rs1;
end
end end
`else `else
wire[31:0] cpuregs_rdata1; wire[31:0] cpuregs_rdata1;
wire[31:0] cpuregs_rdata2; wire[31:0] cpuregs_rdata2;
wire [5:0] cpuregs_waddr = latched_rd; wire [5:0] cpuregs_waddr = latched_rd;
wire [5:0] cpuregs_raddr1 = ENABLE_REGS_DUALPORT ? decoded_rs1 : decoded_rs; wire [5:0] cpuregs_raddr1 = decoded_rs1;
wire [5:0] cpuregs_raddr2 = ENABLE_REGS_DUALPORT ? decoded_rs2 : 0; wire [5:0] cpuregs_raddr2 = decoded_rs2;
`PICORV32_REGS cpuregs ( `PICORV32_REGS cpuregs (
.clk(clk), .clk(clk),
@ -1003,14 +984,8 @@ module picorv32 #(
always @* begin always @* begin
decoded_rs = 'bx; decoded_rs = 'bx;
if (ENABLE_REGS_DUALPORT) begin
cpuregs_rs1 = decoded_rs1 ? cpuregs_rdata1 : 0; cpuregs_rs1 = decoded_rs1 ? cpuregs_rdata1 : 0;
cpuregs_rs2 = decoded_rs2 ? cpuregs_rdata2 : 0; cpuregs_rs2 = decoded_rs2 ? cpuregs_rdata2 : 0;
end else begin
decoded_rs = (cpu_state == cpu_state_ld_rs2) ? decoded_rs2 : decoded_rs1;
cpuregs_rs1 = decoded_rs ? cpuregs_rdata1 : 0;
cpuregs_rs2 = cpuregs_rs1;
end
end end
`endif `endif
@ -1193,7 +1168,6 @@ module picorv32 #(
reg_op1 <= cpuregs_rs1; reg_op1 <= cpuregs_rs1;
dbg_rs1val <= cpuregs_rs1; dbg_rs1val <= cpuregs_rs1;
dbg_rs1val_valid <= 1; dbg_rs1val_valid <= 1;
if (ENABLE_REGS_DUALPORT) begin
pcpi_valid <= 1; pcpi_valid <= 1;
`debug($display("LD_RS2: %2d 0x%08x", decoded_rs2, cpuregs_rs2);) `debug($display("LD_RS2: %2d 0x%08x", decoded_rs2, cpuregs_rs2);)
reg_sh <= cpuregs_rs2; reg_sh <= cpuregs_rs2;
@ -1216,9 +1190,6 @@ module picorv32 #(
end else end else
cpu_state <= cpu_state_trap; cpu_state <= cpu_state_trap;
end end
end else begin
cpu_state <= cpu_state_ld_rs2;
end
end else begin end else begin
`debug($display("EBREAK OR UNSUPPORTED INSN AT 0x%08x", reg_pc);) `debug($display("EBREAK OR UNSUPPORTED INSN AT 0x%08x", reg_pc);)
if (ENABLE_IRQ && !irq_mask[irq_ebreak] && !irq_active) begin if (ENABLE_IRQ && !irq_mask[irq_ebreak] && !irq_active) begin
@ -1331,7 +1302,6 @@ module picorv32 #(
reg_op1 <= cpuregs_rs1; reg_op1 <= cpuregs_rs1;
dbg_rs1val <= cpuregs_rs1; dbg_rs1val <= cpuregs_rs1;
dbg_rs1val_valid <= 1; dbg_rs1val_valid <= 1;
if (ENABLE_REGS_DUALPORT) begin
`debug($display("LD_RS2: %2d 0x%08x", decoded_rs2, cpuregs_rs2);) `debug($display("LD_RS2: %2d 0x%08x", decoded_rs2, cpuregs_rs2);)
reg_sh <= cpuregs_rs2; reg_sh <= cpuregs_rs2;
reg_op2 <= cpuregs_rs2; reg_op2 <= cpuregs_rs2;
@ -1355,8 +1325,6 @@ module picorv32 #(
cpu_state <= cpu_state_exec; cpu_state <= cpu_state_exec;
end end
endcase endcase
end else
cpu_state <= cpu_state_ld_rs2;
end end
endcase endcase
end end