Skip to content

Commit f3abfd3

Browse files
committed
Fix double stalling in IF and ID
1 parent dbd5205 commit f3abfd3

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

Sec_8/ID_Reg.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ module ID_Stage_reg
118118
end
119119
else
120120
begin
121-
if (~stall | ~superStall)
121+
if (~stall & ~superStall)
122122
begin
123123
dest <= dest_in;
124124
readdata1 <= readdata1_in;

Sec_8/IF.v

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module IF_Stage
44
clk,
55
rst,
66
stall,
7+
superStall,
78
Instruction,
89
branch_taken,
910
branch_address,
@@ -14,6 +15,7 @@ module IF_Stage
1415
input clk;
1516
input rst;
1617
input stall;
18+
input superStall;
1719
input branch_taken;
1820
input [31:0] branch_address;
1921
output [31:0] Instruction;
@@ -35,7 +37,7 @@ module IF_Stage
3537
if(branch_taken)
3638
PC <= branch_address;
3739
else
38-
if( !stall )
40+
if( ~stall & ~superStall )
3941
PC <= PC + 4;
4042
end
4143
end
@@ -71,26 +73,26 @@ module IF_Stage
7173
25: Instruction = 32'b100100_00001_01011_00000_00000000100;//-- ld r11 ,r1 ,4//r11=-1456
7274
26: Instruction = 32'b100101_00001_01011_00000_00000011000;//-- st r11 ,r1 ,24
7375
27: Instruction = 32'b100101_00001_01001_00000_00000011100;//-- st r9 ,r1 ,28
74-
28: Instruction = 32'b100101_00001_01010_00000_00000100000;//-- st r10 ,r1 ,32
76+
28: Instruction = 32'b100101_00001_01010_00000_00000100000;//-- st r10 ,r1 ,32
7577
29: Instruction = 32'b100101_00001_01000_00000_00000100100;//-- st r8 ,r1 ,36
7678
30: Instruction = 32'b100000_00000_00001_00000_00000000011;//-- Addi r1 ,r0 ,3 //r1=3
77-
31: Instruction = 32'b100000_00000_00100_00000_10000000000;//-- Addi r4 ,r0 ,1024 //r4=1024
79+
31: Instruction = 32'b100000_00000_00100_00000_10000000000;//-- Addi r4 ,r0 ,1024 //r4=1024
7880
32: Instruction = 32'b100000_00000_00010_00000_00000000000;//-- Addi r2 ,r0 ,0 //r2=0
7981
33: Instruction = 32'b100000_00000_00011_00000_00000000001;//-- Addi r3 ,r0 ,1 //r3=1
8082
34: Instruction = 32'b100000_00000_01001_00000_00000000010;//-- Addi r9 ,r0 ,2 //r9=2
8183
35: Instruction = 32'b001010_00011_01001_01000_00000000000;//-- sll r8 ,r3 ,r9 //r8=r3*4
8284
36: Instruction = 32'b000001_00100_01000_01000_00000000000;//-- Add r8 ,r4 ,r8 //r8=1024+r3*4
8385
37: Instruction = 32'b100100_01000_00101_00000_00000000000;//-- ld r5 ,r8 ,0 //
8486
38: Instruction = 32'b100100_01000_00110_11111_11111111100;//-- ld r6 ,r8 ,-4 //
85-
39: Instruction = 32'b000011_00101_00110_01001_00000000000;//-- sub r9 ,r5 ,r6
87+
39: Instruction = 32'b000011_00101_00110_01001_00000000000;//-- sub r9 ,r5 ,r6
8688
40: Instruction = 32'b100000_00000_01010_10000_00000000000;//-- Addi r10 ,r0 ,0x8000
8789
41: Instruction = 32'b100000_00000_01011_00000_00000010000;//-- Addi r11 ,r0 ,16 // r11 = 16
88-
42: Instruction = 32'b001010_01010_01011_01010_00000000000;//-- sll r10 ,r10 ,r11 // r10 = 2147483648
90+
42: Instruction = 32'b001010_01010_01011_01010_00000000000;//-- sll r10 ,r10 ,r11 // r10 = 2147483648
8991
43: Instruction = 32'b000101_01001_01010_01001_00000000000;//-- And r9 ,r9 ,r10 // if(r5>r6) r9=0 else r9=-2147483648
90-
44: Instruction = 32'b101000_01001_00000_00000_00000000010;//-- Bez r9 ,2
91-
45: Instruction = 32'b100101_01000_00101_11111_11111111100;//-- st r5 ,r8 ,-4
92+
44: Instruction = 32'b101000_01001_00000_00000_00000000010;//-- Bez r9 ,2
93+
45: Instruction = 32'b100101_01000_00101_11111_11111111100;//-- st r5 ,r8 ,-4
9294
46: Instruction = 32'b100101_01000_00110_00000_00000000000;//-- st r6 ,r8 ,0
93-
47: Instruction = 32'b100000_00011_00011_00000_00000000001;//-- Addi r3 ,r3 ,1 //
95+
47: Instruction = 32'b100000_00011_00011_00000_00000000001;//-- Addi r3 ,r3 ,1 //
9496
48: Instruction = 32'b101001_00001_00011_11111_11111110001;//-- BNE r1 ,r3 ,-15
9597
49: Instruction = 32'b100000_00010_00010_00000_00000000001;//-- Addi r2 ,r2 ,1 //2
9698
50: Instruction = 32'b101001_00001_00010_11111_11111101110;//-- BNE r1 ,r2 ,-18

Sec_8/IF_Reg.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module IF_Stage_reg
4040
end
4141
else
4242
begin
43-
if( ~stall | ~superStall )
43+
if( ~stall & ~superStall )
4444
begin
4545
Instruction <= Instruction_in;
4646
PC <= PC_in;

Sec_8/MIPS.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ module MIPS
9999
.clk(clk),
100100
.rst(rst),
101101
.stall(Stall),
102+
.superStall(superStall),
102103
.branch_address(Branch_Address),
103104
.Instruction(Instruction1),
104105
.branch_taken(Branch_Taken),

0 commit comments

Comments
 (0)