1
0
mirror of https://github.com/olofk/serv.git synced 2026-01-22 18:21:12 +00:00

Optimize take_branch condition

This commit is contained in:
Olof Kindgren 2019-07-08 22:37:52 +02:00
parent 88b199a97c
commit af3b82f9ac
3 changed files with 8 additions and 10 deletions

View File

@ -12,7 +12,6 @@ module serv_alu
input wire i_sub,
input wire [1:0] i_bool_op,
input wire i_cmp_sel,
input wire i_cmp_neg,
input wire i_cmp_uns,
output wire o_cmp,
input wire i_shamt_en,
@ -99,7 +98,7 @@ module serv_alu
.o_q (result_lt));
assign plus_1 = i_en & !en_r;
assign o_cmp = i_cmp_neg^((i_cmp_sel == ALU_CMP_EQ) ? result_eq : result_lt);
assign o_cmp = (i_cmp_sel == ALU_CMP_EQ) ? result_eq : result_lt;
localparam [15:0] BOOL_LUT = 16'h8E96;//And, Or, =, xor
wire result_bool = BOOL_LUT[{i_bool_op, i_rs1, i_op_b}];

View File

@ -34,7 +34,6 @@ module serv_decode
output wire o_alu_sub,
output wire [1:0] o_alu_bool_op,
output reg o_alu_cmp_sel,
output wire o_alu_cmp_neg,
output reg o_alu_cmp_uns,
input wire i_alu_cmp,
output wire o_alu_shamt_en,
@ -100,15 +99,19 @@ module serv_decode
assign shift_op = op_or_opimm & (o_funct3[1:0] == 2'b01);
assign slt_op = op_or_opimm & (o_funct3[2:1] == 2'b01);
assign branch_op = (opcode[4:2] == 3'b110) & !opcode[0];
assign e_op = (opcode[4:2] == 3'b111) & !op21 & !(|o_funct3);
assign o_bufreg_imm_en = !opcode[2];
assign o_bufreg_loop = op_or_opimm & !(state == INIT);
assign o_ctrl_pc_en = running | o_ctrl_trap;
wire take_branch = (opcode[4:2] == 3'b110) & (opcode[0] | i_alu_cmp);
//Take branch for jump or branch instructions (opcode == 1x0xx) if
//a) It's an unconditional branch (opcode[0] == 1)
//b) It's a conditional branch (opcode[0] == 0) of type beq,blt,bltu (o_funct3[0] == 0) and ALU compare is true
//c) It's a conditional branch (opcode[0] == 0) of type bne,bge,bgeu (o_funct3[0] == 1) and ALU compare is false
wire take_branch = (opcode[4] & !opcode[2]) & (opcode[0] | (i_alu_cmp^o_funct3[0]));
assign o_ctrl_jalr = opcode[4] & (opcode[1:0] == 2'b01);
@ -135,7 +138,6 @@ module serv_decode
always @(posedge clk)
alu_sub_r <= opcode[3] & imm30;
assign o_alu_cmp_neg = branch_op & o_funct3[0];
/*
300 0_000 mstatus RWSC
304 0_100 mie SCWi

View File

@ -86,7 +86,6 @@ module serv_top
wire alu_sub;
wire [1:0] alu_bool_op;
wire alu_cmp_sel;
wire alu_cmp_neg;
wire alu_cmp_uns;
wire alu_cmp;
wire alu_shamt_en;
@ -163,7 +162,6 @@ module serv_top
.o_alu_sub (alu_sub),
.o_alu_bool_op (alu_bool_op),
.o_alu_cmp_sel (alu_cmp_sel),
.o_alu_cmp_neg (alu_cmp_neg),
.o_alu_cmp_uns (alu_cmp_uns),
.i_alu_cmp (alu_cmp),
.o_alu_shamt_en (alu_shamt_en),
@ -263,7 +261,6 @@ module serv_top
.i_sub (alu_sub),
.i_bool_op (alu_bool_op),
.i_cmp_sel (alu_cmp_sel),
.i_cmp_neg (alu_cmp_neg),
.i_cmp_uns (alu_cmp_uns),
.o_cmp (alu_cmp),
.i_shamt_en (alu_shamt_en),