-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathEX.v
More file actions
93 lines (75 loc) · 1.87 KB
/
Copy pathEX.v
File metadata and controls
93 lines (75 loc) · 1.87 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
EX:
Author: 2016eeb1087(sanket Nyayadhish)
Date: 26/12/2017
*/
module EX(
input IsRet,
input IsBeq,
input IsBgt,
input IsUBranch,
input IsImmediate,
input [31:0] BranchTarget,
input [4:0] AluSignal,
input [31:0] Op1,
input [31:0] Op2,
input [31:0] Immx,
output [31:0] AluResult,
output [31:0] BranchPC,
output IsBranchTaken
);
wire IsRet,IsBeq,IsBgt,IsUBranch,IsImmediate;
wire [4:0] AluSignal;
wire [31:0] Op1,Op2,Immx,BranchTarget;
reg [31:0] AluResult,BranchPC;
reg IsBranchTaken;
reg w1,w2;
//--------------------------------------------
always @(*)
begin
IsBranchTaken = 0;
if ( IsRet == 1)
begin
BranchPC = Op1;
end
else
begin
BranchPC = BranchTarget;
end
if (IsBeq == 1 && P.Flags[0] == 1)
begin
w1 = 1;
end
else
begin
w1=0;
end
if (IsBgt == 1 && P.Flags[1] == 1)
begin
w2 = 1 ;
end
else
begin
w2=0;
end
if (IsUBranch == 1 || w1 == 1 || w2 == 1 )
begin
IsBranchTaken = 1;
end
else
begin
IsBranchTaken = 0;
end
//---------------------------------------------
P.A = Op1;
if (IsImmediate == 1)
begin
P.B = Immx;
end
else
begin
P.B = Op2;
end
AluResult = P.ALU1.AluResult;
end
endmodule