Skip to content

Commit bc4b765

Browse files
Start connecting thread to dispatcher
1 parent 230db83 commit bc4b765

4 files changed

Lines changed: 13 additions & 14 deletions

File tree

src/main/scala/main/Core.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,8 @@ class Core extends Module {
4444

4545
val thread = Module(new Thread());
4646
thread.io.dispatcher_opcode_loaded := dispatcher.io.opcode_loaded;
47-
thread.io.dispatcher_opcode := dispatcher.io.opcode;
4847
thread.io.dispatcher_program_pointer := dispatcher.io.program_pointer;
49-
50-
thread.io.operation_ready := false.B;
51-
thread.io.operation := Operation.NoOp;
48+
thread.io.operation := dispatcher.io.opcode;
5249
thread.io.immediate_a := 0.U(8.W);
5350
thread.io.immediate_b := 0.U(8.W);
5451
}

src/main/scala/main/Thread.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import _root_.circt.stage.ChiselStage
55
class Thread extends Module {
66
val io = IO(new Bundle {
77
val dispatcher_opcode_loaded = Input(Bool());
8-
val dispatcher_opcode = Input(Operation());
98
val dispatcher_program_pointer = Input(UInt(8.W));
109

11-
val operation_ready = Input(Bool());
1210
val operation = Input(Operation());
1311
val immediate_a = Input(UInt(8.W));
1412
val immediate_b = Input(UInt(8.W));
@@ -46,7 +44,7 @@ class Thread extends Module {
4644
io.end_of_program := end_of_program;
4745
io.idle := idle;
4846

49-
when(io.operation_ready) {
47+
when(io.dispatcher_opcode_loaded && io.dispatcher_program_pointer === program_counter.io.program_counter) {
5048
operation := io.operation;
5149
immediate_a := io.immediate_a;
5250
immediate_b := io.immediate_b;

src/test/scala/main/CoreTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ class CoreTest extends AnyFlatSpec with ChiselScalatestTester {
66
"Core" should "work" in {
77
test(new Core) { dut =>
88
dut.io.debug_memory_write.poke(true.B);
9-
dut.io.debug_memory_write_address.poke(1.U(8.W));
9+
dut.io.debug_memory_write_address.poke(0.U(8.W));
1010
dut.io.debug_memory_write_data.poke(1.U(8.W));
1111

1212
dut.clock.step(1);
1313

1414
dut.io.debug_dispatcher_thread_requesting_opcode.poke(true.B);
15-
dut.io.debug_dispatcher_thread_program_pointer.poke(1.U(8.W));
15+
dut.io.debug_dispatcher_thread_program_pointer.poke(0.U(8.W));
1616

1717
dut.clock.step(1);
1818

@@ -21,7 +21,7 @@ class CoreTest extends AnyFlatSpec with ChiselScalatestTester {
2121
dut.clock.step(1);
2222

2323
dut.io.debug_dispatcher_opcode.expect(Operation.Add);
24-
dut.io.debug_dispatcher_program_pointer.expect(1.U(8.W));
24+
dut.io.debug_dispatcher_program_pointer.expect(0.U(8.W));
2525
}
2626
}
2727
}

src/test/scala/main/ThreadTest.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import org.scalatest.flatspec.AnyFlatSpec
55
class ThreadTest extends AnyFlatSpec with ChiselScalatestTester {
66
"Thread ALU Operations" should "work" in {
77
test(new Thread) { dut =>
8-
dut.io.operation_ready.poke(true.B);
8+
dut.io.dispatcher_opcode_loaded.poke(true.B);
9+
dut.io.dispatcher_program_pointer.poke(0.U(8.W));
910
dut.io.operation.poke(Operation.Add);
1011
dut.io.immediate_a.poke(2.U);
1112
dut.io.immediate_b.poke(3.U);
@@ -14,7 +15,8 @@ class ThreadTest extends AnyFlatSpec with ChiselScalatestTester {
1415

1516
dut.io.debug_output.expect(5.U);
1617

17-
dut.io.operation_ready.poke(true.B);
18+
dut.io.dispatcher_opcode_loaded.poke(true.B);
19+
dut.io.dispatcher_program_pointer.poke(0.U(8.W));
1820
dut.io.operation.poke(Operation.Mul);
1921
dut.io.immediate_a.poke(2.U);
2022
dut.io.immediate_b.poke(3.U);
@@ -23,7 +25,8 @@ class ThreadTest extends AnyFlatSpec with ChiselScalatestTester {
2325

2426
dut.io.debug_output.expect(6.U);
2527

26-
dut.io.operation_ready.poke(true.B);
28+
dut.io.dispatcher_opcode_loaded.poke(true.B);
29+
dut.io.dispatcher_program_pointer.poke(0.U(8.W));
2730
dut.io.operation.poke(Operation.Sub);
2831
dut.io.immediate_a.poke(3.U);
2932
dut.io.immediate_b.poke(2.U);
@@ -32,7 +35,8 @@ class ThreadTest extends AnyFlatSpec with ChiselScalatestTester {
3235

3336
dut.io.debug_output.expect(1.U);
3437

35-
dut.io.operation_ready.poke(true.B);
38+
dut.io.dispatcher_opcode_loaded.poke(true.B);
39+
dut.io.dispatcher_program_pointer.poke(0.U(8.W));
3640
dut.io.operation.poke(Operation.Div);
3741
dut.io.immediate_a.poke(6.U);
3842
dut.io.immediate_b.poke(3.U);

0 commit comments

Comments
 (0)