Skip to content

Commit 3009950

Browse files
committed
Report Added
1 parent 3e85c74 commit 3009950

35 files changed

+23132
-28
lines changed

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,36 @@ PS: I recommend testing 2.s ( a really long programme that checks all the ALU fu
1919
./test_sequential.sh 6.s
2020
```
2121

22+
## Pipelined Implementation
23+
24+
The pipelined implementation features a 5-stage pipeline with hazard detection, data forwarding, and branch prediction. To run tests on the pipelined CPU:
25+
26+
27+
```sh
28+
cd pipelined
29+
chmod +x test_pipelined.sh
30+
./test_pipelined.sh <filename>.s
31+
```
32+
33+
### Key Pipelined Features:
34+
35+
- 5-stage pipeline: IF, ID, EX, MEM, and WB stages
36+
- Static branch prediction: Always-taken strategy for branches
37+
- Data hazard handling: Forwarding paths for most hazards, stalling for load-use hazards
38+
- Control hazard handling: Pipeline flush on branch misprediction
39+
- Performance: Multiple test cases demonstrate improved throughput over sequential design
40+
41+
42+
### Test Cases:
43+
- 2.s: Tests loop with data dependencies, showcasing forwarding paths
44+
- 4.s: Tests branch prediction with unconditional branches
45+
- 7.s: Tests branch prediction and control hazard handling
46+
- 8.s: Tests load-use hazard detection and stalling mechanism
47+
2248
## Assembly Instructions Supported
2349

2450
The assembler supports a subset of RISC-V instructions:
25-
- **R-type**: `add`, `sub`, `or`, `and`
51+
- **R-type**: `add`, `sub`, `or`, `and`, `addi`
2652
- **I-type**: `addi`, `ld` (load doubleword)
2753
- **S-type**: `sd` (store doubleword)
2854
- **B-type**: `beq` (branch if equal)

pipelined/verilog/testbench_pipelined.v

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ module testbench_pipelined();
1616
reset = 1;
1717

1818
// Initialize instruction memory first
19-
cpu.imem.memory[0] = 32'b00000000000000000010000100000011;
20-
cpu.imem.memory[1] = 32'b00000000000100010000001000010011;
21-
cpu.imem.memory[2] = 32'b00000000001000110000010000110011;
22-
cpu.imem.memory[3] = 32'b00000000001000100000010010110011;
23-
cpu.imem.memory[4] = 32'b00000000000000000000000000000000;
19+
cpu.imem.memory[0] = 32'b00000000001100000000000010010011;
20+
cpu.imem.memory[1] = 32'b00000000011100000000000100010011;
21+
cpu.imem.memory[2] = 32'b00000000000000001000100001100011;
22+
cpu.imem.memory[3] = 32'b00000000000100010000000100110011;
23+
cpu.imem.memory[4] = 32'b11111111111100001000000010010011;
24+
cpu.imem.memory[5] = 32'b11111110000000000000101011100011;
25+
cpu.imem.memory[6] = 32'b00000000000000000000000000000000;
2426

2527
// promper initialization
2628
#10 reset = 0;
40.2 KB
Loading

report/Control_Signals.jpg

148 KB
Loading
26.1 KB
Loading
182 KB
Loading

report/Sequential_fibonacci.png

72.7 KB
Loading

report/addix0.jpg

52.1 KB
Loading

report/basic_test_sequential.jpg

69.2 KB
Loading

report/branchshift.png

125 KB
Loading

0 commit comments

Comments
 (0)