-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBranch_Unit.v
More file actions
38 lines (36 loc) · 1.05 KB
/
Branch_Unit.v
File metadata and controls
38 lines (36 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// msrv32_branch_unit 21BCE0289
module msrv32_branch_unit(
input [31:0] rs1_in,
input [31:0] rs2_in,
input [4:0] opcode_6_to_2_in,
input [2:0] funct3_in,
output reg branch_taken_out
);
parameter BRANCH = 5'B110_00,
JAL = 5'b110_11,
JALR = 5'b110_01;
parameter EQS = 3'b000,
NEQ = 3'b001,
LT = 3'b100,
GTE = 3'b101,
LTU = 3'b110,
GTEU = 3'b111;
always @(*) begin
case(opcode_6_to_2_in)
BRANCH: begin
case(funct3_in)
EQS: branch_taken_out = (rs1_in == rs2_in) ? 1'b1 : 1'b0;
NEQ: branch_taken_out = (rs1_in != rs2_in) ? 1'b1 : 1'b0;
LT: branch_taken_out = ($signed(rs1_in) < $signed(rs2_in)) ? 1'b1 : 1'b0;
GTE: branch_taken_out = ($signed(rs1_in) >= $signed(rs2_in)) ? 1'b1 : 1'b0;
LTU: branch_taken_out = (rs1_in < rs2_in) ? 1'b1 : 1'b0;
GTEU: branch_taken_out = (rs1_in >= rs2_in) ? 1'b1 : 1'b0;
default:branch_taken_out = (rs1_in == rs2_in) ? 1'b1 : 1'b0;
endcase
end
JAL: branch_taken_out = 1'b1;
JALR: branch_taken_out = 1'b1;
default:branch_taken_out = 1'b0;
endcase
end
endmodule