File tree Expand file tree Collapse file tree 6 files changed +35
-21
lines changed Expand file tree Collapse file tree 6 files changed +35
-21
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ module EXE_Stage_reg
4
4
clk,
5
5
rst,
6
6
stall,
7
+ superStall,
7
8
PC_in,
8
9
WB_En_in,
9
10
MEM_R_En_in,
@@ -28,6 +29,7 @@ module EXE_Stage_reg
28
29
input clk;
29
30
input rst;
30
31
input stall;
32
+ input superStall;
31
33
input WB_En_in;
32
34
input MEM_R_En_in;
33
35
input MEM_W_En_in;
@@ -75,7 +77,7 @@ module EXE_Stage_reg
75
77
end
76
78
else
77
79
begin
78
- if (~ stall ) begin
80
+ if (~ superStall ) begin
79
81
dest <= dest_in;
80
82
PC <= PC_in;
81
83
WB_En <= WB_En_in;
@@ -84,7 +86,7 @@ module EXE_Stage_reg
84
86
Is_Imm <= Is_Imm_in;
85
87
readdata <= readdata_in;
86
88
Immediate <= Immediate_in;
87
- ALU_result <= ALU_result_in;
89
+ ALU_result <= ALU_result_in;
88
90
end
89
91
end
90
92
end
Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ module Hazard
11
11
src2,
12
12
dest1,
13
13
dest2,
14
- Stall
14
+ Stall,
15
+ superStall
15
16
);
16
17
17
18
// define input and output ports
@@ -26,12 +27,13 @@ module Hazard
26
27
input [4 :0 ] dest1;
27
28
input [4 :0 ] dest2;
28
29
output Stall;
30
+ output superStall;
29
31
30
32
// wires and registers
31
- wire shouldForward1FromExe;
32
- wire shouldForward2FromExe;
33
- wire shouldForward1FromMem;
34
- wire shouldForward2FromMem;
33
+ wire shouldForward1FromExe;
34
+ wire shouldForward2FromExe;
35
+ wire shouldForward1FromMem;
36
+ wire shouldForward2FromMem;
35
37
wire shouldForwardMemFromExe;
36
38
wire shouldForwardMemFromMem;
37
39
@@ -51,10 +53,8 @@ module Hazard
51
53
assign shouldForward2 = shouldForward2FromExe | shouldForward2FromMem;
52
54
53
55
// build module
54
- assign Stall = (
55
- shouldForward1 |
56
- shouldForward2 &
57
- Sel
58
- ) | SRAM_NOT_READY ;
56
+ assign Stall = ( shouldForward1 | shouldForward2) & Sel;
57
+ assign superStall = SRAM_NOT_READY;
58
+
59
59
60
60
endmodule
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ module ID_Stage_reg
4
4
clk,
5
5
rst,
6
6
stall,
7
+ superStall,
7
8
branch_taken,
8
9
src1_in,
9
10
src2_in,
@@ -41,6 +42,7 @@ module ID_Stage_reg
41
42
input clk;
42
43
input rst;
43
44
input stall;
45
+ input superStall;
44
46
input branch_taken;
45
47
input WB_En_in;
46
48
input MEM_R_En_in;
@@ -116,7 +118,7 @@ module ID_Stage_reg
116
118
end
117
119
else
118
120
begin
119
- if (~ stall)
121
+ if (~ stall | ~ superStall )
120
122
begin
121
123
dest <= dest_in;
122
124
readdata1 <= readdata1_in;
Original file line number Diff line number Diff line change @@ -4,30 +4,32 @@ module IF_Stage_reg
4
4
clk,
5
5
rst,
6
6
stall,
7
+ superStall,
7
8
branch_taken,
8
9
Instruction_in,
9
10
PC_in,
10
11
Instruction,
11
12
PC
12
13
);
13
-
14
+
14
15
// input and outputs
15
16
input clk;
16
17
input rst;
17
18
input stall;
19
+ input superStall;
18
20
input branch_taken;
19
21
input [31 :0 ] Instruction_in;
20
22
input [31 :0 ] PC_in;
21
23
output [31 :0 ] Instruction;
22
24
output [31 :0 ] PC;
23
25
24
-
26
+
25
27
// registers
26
28
reg [31 :0 ] Instruction;
27
29
reg [31 :0 ] PC;
28
-
30
+
29
31
// build module
30
-
32
+
31
33
// transition between
32
34
always @(posedge clk)
33
35
begin
@@ -38,12 +40,12 @@ module IF_Stage_reg
38
40
end
39
41
else
40
42
begin
41
- if ( ~ stall )
43
+ if ( ~ stall | ~ superStall )
42
44
begin
43
45
Instruction <= Instruction_in;
44
46
PC <= PC_in;
45
47
end
46
48
end
47
49
end
48
-
50
+
49
51
endmodule
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ module MEM_Stage_reg
4
4
clk,
5
5
rst,
6
6
stall,
7
+ superStall,
7
8
PC_in,
8
9
PC,
9
10
WB_En_in,
@@ -24,6 +25,7 @@ module MEM_Stage_reg
24
25
input clk;
25
26
input rst;
26
27
input stall;
28
+ input superStall;
27
29
input WB_En_in;
28
30
input MEM_R_En_in;
29
31
input Is_Imm_in;
@@ -63,7 +65,7 @@ module MEM_Stage_reg
63
65
end
64
66
else
65
67
begin
66
- if (~ stall ) begin
68
+ if (~ superStall ) begin
67
69
WB_En <= WB_En_in;
68
70
MEM_R_En <= MEM_R_En_in;
69
71
Is_Imm <= Is_Imm_in;
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ module MIPS
44
44
wire Branch_Taken;
45
45
wire SRAM_NOT_READY;
46
46
wire Stall;
47
+ wire superStall;
47
48
wire [1 :0 ] BR_Type1;
48
49
wire [1 :0 ] BR_Type2;
49
50
wire [4 :0 ] src11;
@@ -110,6 +111,7 @@ module MIPS
110
111
.clk(clk),
111
112
.rst(rst),
112
113
.stall(Stall),
114
+ .superStall(superStall),
113
115
.branch_taken(Branch_Taken),
114
116
.Instruction_in(Instruction1),
115
117
.PC_in(PC11),
@@ -154,14 +156,16 @@ module MIPS
154
156
.src2(src21),
155
157
.dest1(dest2),
156
158
.dest2(dest3),
157
- .Stall(Stall)
159
+ .Stall(Stall),
160
+ .superStall(superStall)
158
161
);
159
162
// instruction decode register
160
163
ID_Stage_reg IDR
161
164
(
162
165
.clk(clk),
163
166
.rst(rst),
164
167
.stall(Stall),
168
+ .superStall(superStall),
165
169
.branch_taken(Branch_Taken),
166
170
.readdata1_in(readdata11),
167
171
.readdata2_in(readdata21),
@@ -238,6 +242,7 @@ module MIPS
238
242
.clk(clk),
239
243
.rst(rst),
240
244
.stall(Stall),
245
+ .superStall(superStall),
241
246
.PC_in(PC2),
242
247
.PC(PC3),
243
248
.WB_En_in(WB_En22),
@@ -280,6 +285,7 @@ module MIPS
280
285
.clk(clk),
281
286
.rst(rst),
282
287
.stall(Stall),
288
+ .superStall(superStall),
283
289
.PC_in(PC3),
284
290
.PC(PC4),
285
291
.WB_En_in(WB_En32),
You can’t perform that action at this time.
0 commit comments