-
Notifications
You must be signed in to change notification settings - Fork 1
/
execute.v
71 lines (58 loc) · 1.52 KB
/
execute.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
module execute( isret, isbeq, isbgt,isubranch, isimmediate, branchtarget, alusignal, op1, op2, immx, aluresult1, branchpc,isbranchtaken );
input isret,isbeq,isbgt,isubranch,isimmediate;
input [4:0] alusignal;
input [31:0] op1,op2,immx,branchtarget;
output [31:0] aluresult1,branchpc;
output isbranchtaken;
wire isret,isbeq,isbgt,isubranch,isimmediate;
wire [4:0] alusignal;
wire [31:0] op1,op2,immx,branchtarget;
reg [31:0] aluresult1,branchpc;
reg isbranchtaken;
reg w1,w2;
always @(*)
begin
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 if (isimmediate == 0)
begin
p.b = op2;
end
aluresult1= p.alu1.aluresult;
end
endmodule