Skip to content

Commit f022b7c

Browse files
Loading 24 bits of memory per instruction
1 parent e2628ea commit f022b7c

File tree

11 files changed

+25
-9
lines changed

11 files changed

+25
-9
lines changed
File renamed without changes.
File renamed without changes.

src/main/scala/main/Core.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ class Core extends Module {
1818
val dispatcher = Module(new Dispatcher());
1919
val thread = Module(new Thread());
2020

21-
memory.io.readPorts(0).enable := dispatcher.io.read_requested;
21+
memory.io.readPorts(0).enable := 3.U * dispatcher.io.read_requested;
2222
memory.io.readPorts(0).address := dispatcher.io.read_program_pointer;
23+
memory.io.readPorts(1).enable := dispatcher.io.read_requested;
24+
memory.io.readPorts(1).address := 3.U * dispatcher.io.read_program_pointer + 1.U;
25+
memory.io.readPorts(2).enable := dispatcher.io.read_requested;
26+
memory.io.readPorts(2).address := 3.U * dispatcher.io.read_program_pointer + 2.U;
2327

2428
memory.io.writePorts(0).enable := io.debug_memory_write;
2529
memory.io.writePorts(0).address := io.debug_memory_write_address;
@@ -30,7 +34,9 @@ class Core extends Module {
3034

3135
val read_ready_delayed = RegNext(dispatcher.io.read_requested, false.B);
3236
dispatcher.io.read_ready := read_ready_delayed;
33-
dispatcher.io.read_opcode := Operation.safe(memory.io.readPorts(0).data(3, 0))._1;
37+
dispatcher.io.read_opcode := Operation.safe(memory.io.readPorts(0).data(6, 3))._1;
38+
dispatcher.io.read_immediate_l := memory.io.readPorts(1).data(7, 0);
39+
dispatcher.io.read_immediate_u := memory.io.readPorts(2).data(7, 0);
3440

3541
when(true.B) {
3642
printf(p"\t[Core]=====");

src/main/scala/main/Dispatcher.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class Dispatcher extends Module {
1212
val read_program_pointer = Output(UInt(8.W));
1313
val read_ready = Input(Bool());
1414
val read_opcode = Input(Operation());
15+
val read_immediate_l = Input(UInt(8.W));
16+
val read_immediate_u = Input(UInt(8.W));
1517

1618
val opcode_loaded = Output(Bool());
1719
val opcode = Output(Operation());
@@ -31,15 +33,17 @@ class Dispatcher extends Module {
3133
io.program_pointer := program_pointer;
3234

3335
when(io.thread_requesting_opcode) {
34-
// printf(p"\t[Dispatcher]=====");
35-
// printf(p"\n\t\tMarked read requested!\n\n");
36+
printf(p"\t[Dispatcher]=====");
37+
printf(p"\n\t\tMarked read requested!\n\n");
3638
read_program_pointer := io.thread_program_pointer;
3739
read_requested := true.B;
3840
}
3941

4042
when(io.read_ready) {
4143
printf(p"\t[Dispatcher]=====");
42-
printf(p"\n\t\tRead Complete ${io.read_opcode}\n\n");
44+
printf(p"\n\t\tRead Complete ${io.read_opcode}");
45+
printf(p"\n\t\tImmediate Lower ${io.read_immediate_l}");
46+
printf(p"\n\t\tImmediate Upper ${io.read_immediate_u}\n\n");
4347
opcode := io.read_opcode;
4448
opcode_loaded := true.B;
4549
program_pointer := io.read_program_pointer;

src/main/scala/main/Memory.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ import chisel3.util._
33
import _root_.circt.stage.ChiselStage
44

55
class Memory extends Module {
6-
val io = IO(new SRAMInterface(1024, UInt(8.W), 1, 1, 0));
6+
val io = IO(new SRAMInterface(1024, UInt(8.W), 3, 1, 0));
77

8-
val memory = SRAM(1024, UInt(8.W), 1, 1, 0);
8+
val memory = SRAM(1024, UInt(8.W), 3, 1, 0);
99

1010
io.readPorts(0) <> memory.readPorts(0);
11+
io.readPorts(1) <> memory.readPorts(1);
12+
io.readPorts(2) <> memory.readPorts(2);
13+
1114
io.writePorts(0) <> memory.writePorts(0);
1215
}

src/main/scala/main/Operation.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import chisel3.util._
33
import _root_.circt.stage.ChiselStage
44

55
object Operation extends ChiselEnum {
6-
val NoOp, Add, Sub, Mul, Div, JumpE, JumpNE, Compare, End, Load, Write = Value
6+
val NoOp, MoveImmediate, MoveRegister, Load, Add, Sub, Mul, Div, JumpE, JumpNE, Compare, End, Write = Value
77
}

src/main/scala/main/Thread.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class Thread extends Module {
2020
val end_of_program = RegInit(false.B);
2121
val idle = RegInit(true.B);
2222

23+
val register_a = RegInit(0.U(16.W));
24+
val register_b = RegInit(0.U(16.W));
25+
2326
val alu = Module(new Alu())
2427
alu.io.execute := false.B;
2528
alu.io.operation := Operation.NoOp;

0 commit comments

Comments
 (0)