Cleans up control unit

This commit is contained in:
2025-11-12 11:58:49 +01:00
parent 992cf37b92
commit 8ac17f20fe
7 changed files with 22 additions and 19 deletions

View File

@@ -142,8 +142,9 @@ class ControlUnit() extends Module {
val funct7 = io.instruction(31, 25);
switch(opcode) {
// ~~~ Single instruction OpCodes ~~
// U instructions
// ~ U instructions ~
is(OpCode.LUI) {
io.reg_file_we := true.B // Write to regfile
io.mux_alu_imm := false.B // Send immy directly to refile
@@ -157,19 +158,7 @@ class ControlUnit() extends Module {
io.optype := OpType.U
}
// OpImm instructions
is(OpCode.OpImm) {
io.reg_file_we := true.B // Write to regfile
OpImm.opImm(io)
}
// OpR instructions
is(OpCode.OpR) {
io.reg_file_we := true.B // Write to regfile
OpR.opR(io);
}
// J instructions
// ~ J instructions ~
is(OpCode.JAL) {
io.alu_opcode := AluOpCode.Add // ALU is unused
@@ -201,24 +190,27 @@ class ControlUnit() extends Module {
io.optype := OpType.I
}
is(OpCode.OpImm) {
OpImm.opImm(io)
}
is(OpCode.OpR) {
OpR.opR(io);
}
is(OpCode.OpBranch) {
io.optype := OpType.B;
OpBranch.opBranch(io);
}
is(OpCode.OpStore) {
io.optype := OpType.S
OpStore.opStore(io);
}
is(OpCode.OpLoad) {
io.optype := OpType.I
OpLoad.opLoad(io);
}
is(OpCode.OpImmW) {
io.reg_file_we := true.B // Write to regfile
io.optype := OpType.I
OpImmW.opImmW(io);
}
}