Skip to content

Commit 5503f11

Browse files
committed
Divide stall for SRAM and HazardUnit, use superStall
1 parent fd4ae9c commit 5503f11

File tree

6 files changed

+35
-21
lines changed

6 files changed

+35
-21
lines changed

Sec_8/EXE_Reg.v

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module EXE_Stage_reg
44
clk,
55
rst,
66
stall,
7+
superStall,
78
PC_in,
89
WB_En_in,
910
MEM_R_En_in,
@@ -28,6 +29,7 @@ module EXE_Stage_reg
2829
input clk;
2930
input rst;
3031
input stall;
32+
input superStall;
3133
input WB_En_in;
3234
input MEM_R_En_in;
3335
input MEM_W_En_in;
@@ -75,7 +77,7 @@ module EXE_Stage_reg
7577
end
7678
else
7779
begin
78-
if (~stall) begin
80+
if (~superStall) begin
7981
dest <= dest_in;
8082
PC <= PC_in;
8183
WB_En <= WB_En_in;
@@ -84,7 +86,7 @@ module EXE_Stage_reg
8486
Is_Imm <= Is_Imm_in;
8587
readdata <= readdata_in;
8688
Immediate <= Immediate_in;
87-
ALU_result <= ALU_result_in;
89+
ALU_result <= ALU_result_in;
8890
end
8991
end
9092
end

Sec_8/Hazard.v

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ module Hazard
1111
src2,
1212
dest1,
1313
dest2,
14-
Stall
14+
Stall,
15+
superStall
1516
);
1617

1718
// define input and output ports
@@ -26,12 +27,13 @@ module Hazard
2627
input [4:0] dest1;
2728
input [4:0] dest2;
2829
output Stall;
30+
output superStall;
2931

3032
// 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;
3537
wire shouldForwardMemFromExe;
3638
wire shouldForwardMemFromMem;
3739

@@ -51,10 +53,8 @@ module Hazard
5153
assign shouldForward2 = shouldForward2FromExe | shouldForward2FromMem;
5254

5355
// 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+
5959

6060
endmodule

Sec_8/ID_Reg.v

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module ID_Stage_reg
44
clk,
55
rst,
66
stall,
7+
superStall,
78
branch_taken,
89
src1_in,
910
src2_in,
@@ -41,6 +42,7 @@ module ID_Stage_reg
4142
input clk;
4243
input rst;
4344
input stall;
45+
input superStall;
4446
input branch_taken;
4547
input WB_En_in;
4648
input MEM_R_En_in;
@@ -116,7 +118,7 @@ module ID_Stage_reg
116118
end
117119
else
118120
begin
119-
if (~stall)
121+
if (~stall | ~superStall)
120122
begin
121123
dest <= dest_in;
122124
readdata1 <= readdata1_in;

Sec_8/IF_Reg.v

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,32 @@ module IF_Stage_reg
44
clk,
55
rst,
66
stall,
7+
superStall,
78
branch_taken,
89
Instruction_in,
910
PC_in,
1011
Instruction,
1112
PC
1213
);
13-
14+
1415
// input and outputs
1516
input clk;
1617
input rst;
1718
input stall;
19+
input superStall;
1820
input branch_taken;
1921
input [31:0] Instruction_in;
2022
input [31:0] PC_in;
2123
output [31:0] Instruction;
2224
output [31:0] PC;
2325

24-
26+
2527
// registers
2628
reg [31:0] Instruction;
2729
reg [31:0] PC;
28-
30+
2931
// build module
30-
32+
3133
// transition between
3234
always @(posedge clk)
3335
begin
@@ -38,12 +40,12 @@ module IF_Stage_reg
3840
end
3941
else
4042
begin
41-
if( ~stall )
43+
if( ~stall | ~superStall )
4244
begin
4345
Instruction <= Instruction_in;
4446
PC <= PC_in;
4547
end
4648
end
4749
end
48-
50+
4951
endmodule

Sec_8/MEM_Reg.v

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module MEM_Stage_reg
44
clk,
55
rst,
66
stall,
7+
superStall,
78
PC_in,
89
PC,
910
WB_En_in,
@@ -24,6 +25,7 @@ module MEM_Stage_reg
2425
input clk;
2526
input rst;
2627
input stall;
28+
input superStall;
2729
input WB_En_in;
2830
input MEM_R_En_in;
2931
input Is_Imm_in;
@@ -63,7 +65,7 @@ module MEM_Stage_reg
6365
end
6466
else
6567
begin
66-
if (~stall) begin
68+
if (~superStall) begin
6769
WB_En <= WB_En_in;
6870
MEM_R_En <= MEM_R_En_in;
6971
Is_Imm <= Is_Imm_in;

Sec_8/MIPS.v

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ module MIPS
4444
wire Branch_Taken;
4545
wire SRAM_NOT_READY;
4646
wire Stall;
47+
wire superStall;
4748
wire [1:0] BR_Type1;
4849
wire [1:0] BR_Type2;
4950
wire [4:0] src11;
@@ -110,6 +111,7 @@ module MIPS
110111
.clk(clk),
111112
.rst(rst),
112113
.stall(Stall),
114+
.superStall(superStall),
113115
.branch_taken(Branch_Taken),
114116
.Instruction_in(Instruction1),
115117
.PC_in(PC11),
@@ -154,14 +156,16 @@ module MIPS
154156
.src2(src21),
155157
.dest1(dest2),
156158
.dest2(dest3),
157-
.Stall(Stall)
159+
.Stall(Stall),
160+
.superStall(superStall)
158161
);
159162
// instruction decode register
160163
ID_Stage_reg IDR
161164
(
162165
.clk(clk),
163166
.rst(rst),
164167
.stall(Stall),
168+
.superStall(superStall),
165169
.branch_taken(Branch_Taken),
166170
.readdata1_in(readdata11),
167171
.readdata2_in(readdata21),
@@ -238,6 +242,7 @@ module MIPS
238242
.clk(clk),
239243
.rst(rst),
240244
.stall(Stall),
245+
.superStall(superStall),
241246
.PC_in(PC2),
242247
.PC(PC3),
243248
.WB_En_in(WB_En22),
@@ -280,6 +285,7 @@ module MIPS
280285
.clk(clk),
281286
.rst(rst),
282287
.stall(Stall),
288+
.superStall(superStall),
283289
.PC_in(PC3),
284290
.PC(PC4),
285291
.WB_En_in(WB_En32),

0 commit comments

Comments
 (0)