Skip to content

Commit 224f598

Browse files
Working operation lock in thread
1 parent 93790ab commit 224f598

5 files changed

Lines changed: 150 additions & 116 deletions

File tree

src/main/disabled-tests/ProgramCounterTest.scala renamed to src/main/disabled-tests/ProgramPointerTest.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ import chisel3._
22
import chiseltest._
33
import org.scalatest.flatspec.AnyFlatSpec
44

5-
class ProgramCounterTest extends AnyFlatSpec with ChiselScalatestTester {
6-
"Program Counter Increment" should "work" in {
7-
test(new ProgramCounter) { dut =>
5+
class ProgramPointerTest extends AnyFlatSpec with ChiselScalatestTester {
6+
"Program Pointer Increment" should "work" in {
7+
test(new ProgramPointer) { dut =>
88
dut.io.update.poke(true.B);
99

1010
dut.clock.step(1);
1111

12-
dut.io.program_counter.expect(1.U);
12+
dut.io.pointer.expect(1.U);
1313
}
1414
}
1515

16-
"Program Counter Jump" should "work" in {
17-
test(new ProgramCounter) { dut =>
16+
"Program Pointer Jump" should "work" in {
17+
test(new ProgramPointer) { dut =>
1818
dut.io.store_nzp.poke(true.B);
1919
dut.io.nzp.poke(1.U);
2020

@@ -27,12 +27,12 @@ class ProgramCounterTest extends AnyFlatSpec with ChiselScalatestTester {
2727

2828
dut.clock.step(1);
2929

30-
dut.io.program_counter.expect(8.U);
30+
dut.io.pointer.expect(8.U);
3131
}
3232
}
3333

34-
"Program Counter Jump Fail" should "work" in {
35-
test(new ProgramCounter) { dut =>
34+
"Program Pointer Jump Fail" should "work" in {
35+
test(new ProgramPointer) { dut =>
3636
dut.io.store_nzp.poke(true.B);
3737
dut.io.nzp.poke(1.U);
3838

@@ -45,7 +45,7 @@ class ProgramCounterTest extends AnyFlatSpec with ChiselScalatestTester {
4545

4646
dut.clock.step(1);
4747

48-
dut.io.program_counter.expect(1.U);
48+
dut.io.pointer.expect(1.U);
4949
}
5050
}
5151
}

src/main/scala/main/Core.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ class Core extends Module {
7474
io.debug_dispatcher_opcode := dispatcher.io.opcode;
7575
io.debug_dispatcher_program_pointer := dispatcher.io.program_pointer;
7676

77-
thread.io.dispatcher_opcode_loaded := dispatcher.io.opcode_loaded;
78-
thread.io.dispatcher_program_pointer := dispatcher.io.program_pointer;
7977
thread.io.operation := dispatcher.io.opcode;
78+
thread.io.operation_pointer := dispatcher.io.program_pointer;
8079
thread.io.src_register := dispatcher.io.src_register;
8180
thread.io.dst_register := dispatcher.io.dst_register;
8281
thread.io.immediate := Cat(
8382
dispatcher.io.read_immediate_u,
8483
dispatcher.io.read_immediate_l
8584
);
85+
thread.io.operation_loaded := dispatcher.io.opcode_loaded;
8686

8787
io.debug_thread_debug_output := thread.io.debug_output;
8888
}

src/main/scala/main/Main.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import _root_.circt.stage.ChiselStage
77
object Main extends App {
88
emitVerilog(new Alu(), Array("--target-dir", "generated"));
99
emitVerilog(new Lsu(), Array("--target-dir", "generated"));
10-
emitVerilog(new ProgramCounter(), Array("--target-dir", "generated"));
10+
emitVerilog(new ProgramPointer(), Array("--target-dir", "generated"));
1111

1212
test(new Lsu) { dut =>
1313
dut.io.write.poke(true.B);
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,33 @@ import chisel3._
22
import chisel3.util._
33
import _root_.circt.stage.ChiselStage
44

5-
class ProgramCounter extends Module {
5+
class ProgramPointer extends Module {
66
val io = IO(new Bundle {
77
val store_nzp = Input(Bool());
88
val nzp = Input(UInt(3.W));
99

1010
val update = Input(Bool());
1111
val branch = Input(Bool());
12-
val jump_location = Input(UInt(8.W));
12+
val jump_location = Input(UInt(16.W));
1313
val target_nzp = Input(UInt(3.W));
1414

15-
val program_counter = Output(UInt(8.W));
15+
val pointer = Output(UInt(16.W));
1616
})
1717

1818
val nzp = RegInit(0.U(3.W));
1919

20-
val program_counter = RegInit(0.U(8.W));
21-
io.program_counter := program_counter;
20+
val pointer = RegInit(0.U(16.W));
21+
io.pointer := pointer;
2222

2323
when(io.store_nzp) {
2424
nzp := io.nzp;
2525
}
2626

2727
when(io.update) {
2828
when(io.branch && (nzp & io.target_nzp) =/= 0.U) {
29-
program_counter := io.jump_location;
29+
pointer := io.jump_location;
3030
}.otherwise {
31-
program_counter := program_counter + 1.U;
31+
pointer := pointer + 1.U;
3232
}
3333
}
3434
}

0 commit comments

Comments
 (0)