-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBranch.v
More file actions
59 lines (53 loc) · 1.45 KB
/
Copy pathBranch.v
File metadata and controls
59 lines (53 loc) · 1.45 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 05.02.2025 11:37:19
// Design Name:
// Module Name: Branch
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module Branch(
input enable, j, b,
input [2:0] funct3,
input [19:0] imm,
input [31:0] op1, op2,
input [9:0] address,
output reg branch,
output reg [9:0] targetAddress,
output reg done
);
reg signed [31:0] s_op1, s_op2;
always @ (posedge enable) begin
done = 0;
targetAddress = address + imm;
s_op1 = op1; s_op2 = op2;
#1;
//Branch Logic
if(j) branch = 1;
else if(b) begin
case(funct3)
3'b000: branch = (op1 == op2);
3'b001: branch = ~(op1 == op2);
3'b100: branch = (s_op1 < s_op2);
3'b101: branch = ~(s_op1 < s_op2);
3'b110: branch = (op1 < op2);
3'b111: branch = ~(op1 < op2);
default: branch = 0;
endcase
end
else branch = 0;
#1 done = 1;
end
endmodule