Skip to content

Commit c1aa535

Browse files
Functioning program execution
1 parent 02a4061 commit c1aa535

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

src/main/scala/main/Core.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@ class Core extends Module {
2828
dispatcher.io.thread_requesting_opcode := thread.io.idle;
2929
dispatcher.io.thread_program_pointer := thread.io.program_pointer;
3030

31-
// val read_ready_delayed = RegNext(dispatcher.io.read_requested, false.B);
32-
// dispatcher.io.read_ready := read_ready_delayed;
33-
dispatcher.io.read_ready := dispatcher.io.read_requested;
31+
val read_ready_delayed = RegNext(dispatcher.io.read_requested, false.B);
32+
dispatcher.io.read_ready := read_ready_delayed;
3433
dispatcher.io.read_opcode := Operation.safe(memory.io.readPorts(0).data(3, 0))._1;
3534

3635
when(true.B) {
3736
printf(p"\t[Core]=====");
3837
printf(p"\n\t\tdispatcher.io.read_requested=${dispatcher.io.read_requested}");
38+
printf(p"\n\t\tread_ready_delayed=${read_ready_delayed}");
3939
printf(p"\n\t\tdispatcher.io.read_program_pointer=${dispatcher.io.read_program_pointer}");
4040
printf(p"\n\t\tdispatcher.io.read_opcode=${dispatcher.io.read_opcode}");
4141
// printf(p"\n\t\tread_ready_delayed=${read_ready_delayed}");
42+
printf(p"\n\t\tdispatcher_read_ready=${dispatcher.io.read_ready}");
4243
printf(p"\n\t\tdebug_dispatcher_opcode=${io.debug_dispatcher_opcode}");
4344
printf(p"\n\t\tdebug_dispatcher_program_pointer=${io.debug_dispatcher_program_pointer}");
4445
printf(p"\n\n");

src/main/scala/main/Dispatcher.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class Dispatcher extends Module {
3838
}
3939

4040
when(io.read_ready) {
41-
// printf(p"\t[Dispatcher]=====");
42-
// printf(p"\n\t\tMarked read not requested!\n\n");
41+
printf(p"\t[Dispatcher]=====");
42+
printf(p"\n\t\tRead Complete ${io.read_opcode}\n\n");
4343
opcode := io.read_opcode;
4444
opcode_loaded := true.B;
4545
program_pointer := io.read_program_pointer;

src/main/scala/main/ProgramCounter.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ class ProgramCounter extends Module {
2626

2727
when(io.update) {
2828
when(io.branch && (nzp & io.target_nzp) =/= 0.U) {
29-
io.program_counter := io.jump_location;
3029
program_counter := io.jump_location;
3130
}.otherwise {
32-
io.program_counter := program_counter + 1.U;
3331
program_counter := program_counter + 1.U;
3432
}
3533
}

src/main/scala/main/Thread.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class Thread extends Module {
5353

5454
program_counter.io.update := true.B;
5555
program_counter.io.branch := false.B;
56+
57+
io.idle := false.B;
5658
}
5759
}
5860

@@ -61,6 +63,7 @@ class Thread extends Module {
6163
printf(p"\n\t\tio.operation=${io.operation}");
6264
printf(p"\n\t\tprogram_pointer=${program_counter.io.program_counter}");
6365
printf(p"\n\t\tidle=${idle}");
66+
printf(p"\n\t\tio.idle=${io.idle}");
6467
printf(p"\n\t\tio.debug_output=${io.debug_output}");
6568
printf(p"\n\n");
6669
}

src/test/scala/main/ProgramCounterTest.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ class ProgramCounterTest extends AnyFlatSpec with ChiselScalatestTester {
66
"Program Counter Increment" should "work" in {
77
test(new ProgramCounter) { dut =>
88
dut.io.update.poke(true.B);
9+
10+
dut.clock.step(1);
11+
912
dut.io.program_counter.expect(1.U);
1013
}
1114
}
@@ -22,6 +25,8 @@ class ProgramCounterTest extends AnyFlatSpec with ChiselScalatestTester {
2225
dut.io.jump_location.poke(8.U);
2326
dut.io.target_nzp.poke(1.U);
2427

28+
dut.clock.step(1);
29+
2530
dut.io.program_counter.expect(8.U);
2631
}
2732
}
@@ -38,6 +43,8 @@ class ProgramCounterTest extends AnyFlatSpec with ChiselScalatestTester {
3843
dut.io.jump_location.poke(8.U);
3944
dut.io.target_nzp.poke(2.U);
4045

46+
dut.clock.step(1);
47+
4148
dut.io.program_counter.expect(1.U);
4249
}
4350
}

0 commit comments

Comments
 (0)