-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBranch_type.v
72 lines (47 loc) · 934 Bytes
/
Branch_type.v
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
// Author:0711282 邱頎霖
module Branch_type(
Branch_type_i,
Zero_i,
ALU_result_i,
branch_type_result_o
);
input [2-1:0] Branch_type_i;
input Zero_i;
input ALU_result_i;
output branch_type_result_o;
reg branch_type_result_o;
always @(*) begin
if(Branch_type_i==0)begin //beq
if(Zero_i==1)begin
branch_type_result_o <= 1;
end
else begin
branch_type_result_o <= 0;
end
end
else if(Branch_type_i==1)begin //bne
if(Zero_i==1)begin
branch_type_result_o <= 0;
end
else begin
branch_type_result_o <= 1;
end
end
else if(Branch_type_i==2)begin //blez <=
if(Zero_i==1 || ALU_result_i==1)begin
branch_type_result_o <= 1;
end
else begin
branch_type_result_o <= 0;
end
end
else if(Branch_type_i==3)begin
if(ALU_result_i==0 && Zero_i!=1)begin
branch_type_result_o <= 1;
end
else begin
branch_type_result_o <= 0;
end
end
end
endmodule