Skip to content

Commit e20699a

Browse files
committed
RTL: recoded func3 muxes from one-hot to binary, the ALU-mux change made no difference, the BRANCH-mux change saved 2 LC
1 parent 4d3c39a commit e20699a

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

FemtoRV/RTL/PROCESSOR/femtorv32_quark.v

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,18 @@ module FemtoRV32 #(
149149
// - for SUB, need to test also instr[5] to discriminate ADDI:
150150
// (1 for ADD/SUB, 0 for ADDI, and Iimm used by ADDI overlaps bit 30 !)
151151
// - instr[30] is 1 for SRA (do sign extension) and 0 for SRL
152-
153-
wire [31:0] aluOut =
154-
(funct3Is[0] ? instr[30] & instr[5] ? aluMinus[31:0] : aluPlus : 32'b0) |
155-
(funct3Is[2] ? {31'b0, LT} : 32'b0) |
156-
(funct3Is[3] ? {31'b0, LTU} : 32'b0) |
157-
(funct3Is[4] ? aluLog : 32'b0) |
158-
(funct3Is[6] ? aluLog : 32'b0) |
159-
(funct3Is[7] ? aluLog : 32'b0) |
160-
(funct3IsShift ? aluReg : 32'b0) ;
152+
reg [32-1:0] aluOut;
153+
always @(*)
154+
case (instr[14:12])
155+
3'b000: aluOut = instr[30] & instr[5] ? aluMinus[31:0] : aluPlus; // ADD
156+
3'b001: aluOut = aluReg; // SL
157+
3'b010: aluOut = {31'b0, LT}; // SLT
158+
3'b011: aluOut = {31'b0, LTU}; // SLTU
159+
3'b100: aluOut = aluLog; // XOR
160+
3'b101: aluOut = aluReg; // SR
161+
3'b110: aluOut = aluLog; // OR
162+
3'b111: aluOut = aluLog; // AND
163+
endcase
161164

162165
wire funct3IsShift = funct3Is[1] | funct3Is[5];
163166

@@ -192,13 +195,19 @@ module FemtoRV32 #(
192195
// The predicate for conditional branches.
193196
/***************************************************************************/
194197

195-
wire predicate =
196-
funct3Is[0] & EQ | // BEQ
197-
funct3Is[1] & !EQ | // BNE
198-
funct3Is[4] & LT | // BLT
199-
funct3Is[5] & !LT | // BGE
200-
funct3Is[6] & LTU | // BLTU
201-
funct3Is[7] & !LTU ; // BGEU
198+
reg predicate;
199+
200+
always @(*)
201+
case (instr[14:12])
202+
3'b000: predicate = EQ ; // BEQ
203+
3'b001: predicate = !EQ ; // BNE
204+
3'b010: predicate = 1'bx; //
205+
3'b011: predicate = 1'bx; //
206+
3'b100: predicate = LT ; // BLT
207+
3'b101: predicate = !LT ; // BGE
208+
3'b110: predicate = LTU; // BLTU
209+
3'b111: predicate = !LTU; // BGEU
210+
endcase
202211

203212
/***************************************************************************/
204213
// Program counter and branch target computation.

0 commit comments

Comments
 (0)