Skip to content

Commit 48b971e

Browse files
committed
branch prediction works
1 parent c0df37e commit 48b971e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pipelined/verilog/cpu_pipelined.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,6 @@ module cpu_pipelined(
363363
assign reg_rd = mem_wb_rd_fixed;
364364

365365
// End of Program
366-
assign end_program = mem_wb_nop_instruction;
366+
assign end_program = mem_wb_nop_instruction & ~ branch_predicted;
367367

368368
endmodule

pipelined/verilog/testbench_pipelined.v

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

1818
// Initialize instruction memory first
19-
cpu.imem.memory[0] = 32'b00000000000000000000010001100011;
20-
cpu.imem.memory[1] = 32'b00000000001100000000001100010011;
21-
cpu.imem.memory[2] = 32'b00000000010000000000001010010011;
22-
cpu.imem.memory[3] = 32'b00000000000000000000000000000000;
19+
cpu.imem.memory[0] = 32'b00000000000000000000100001100011;
20+
cpu.imem.memory[1] = 32'b00000000010000000000001010010011;
21+
cpu.imem.memory[2] = 32'b00000000010000000000001100010011;
22+
cpu.imem.memory[3] = 32'b00000000010000000000001110010011;
23+
cpu.imem.memory[4] = 32'b00000000000000000000000000000000;
2324

2425
// promper initialization
2526
#10 reset = 0;

0 commit comments

Comments
 (0)