Cleans up control unit
This commit is contained in:
@@ -142,8 +142,9 @@ class ControlUnit() extends Module {
|
|||||||
val funct7 = io.instruction(31, 25);
|
val funct7 = io.instruction(31, 25);
|
||||||
|
|
||||||
switch(opcode) {
|
switch(opcode) {
|
||||||
|
// ~~~ Single instruction OpCodes ~~
|
||||||
|
|
||||||
// U instructions
|
// ~ U instructions ~
|
||||||
is(OpCode.LUI) {
|
is(OpCode.LUI) {
|
||||||
io.reg_file_we := true.B // Write to regfile
|
io.reg_file_we := true.B // Write to regfile
|
||||||
io.mux_alu_imm := false.B // Send immy directly to refile
|
io.mux_alu_imm := false.B // Send immy directly to refile
|
||||||
@@ -157,19 +158,7 @@ class ControlUnit() extends Module {
|
|||||||
io.optype := OpType.U
|
io.optype := OpType.U
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpImm instructions
|
// ~ J 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
|
|
||||||
is(OpCode.JAL) {
|
is(OpCode.JAL) {
|
||||||
io.alu_opcode := AluOpCode.Add // ALU is unused
|
io.alu_opcode := AluOpCode.Add // ALU is unused
|
||||||
|
|
||||||
@@ -201,24 +190,27 @@ class ControlUnit() extends Module {
|
|||||||
io.optype := OpType.I
|
io.optype := OpType.I
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is(OpCode.OpImm) {
|
||||||
|
OpImm.opImm(io)
|
||||||
|
}
|
||||||
|
|
||||||
|
is(OpCode.OpR) {
|
||||||
|
OpR.opR(io);
|
||||||
|
}
|
||||||
|
|
||||||
is(OpCode.OpBranch) {
|
is(OpCode.OpBranch) {
|
||||||
io.optype := OpType.B;
|
|
||||||
OpBranch.opBranch(io);
|
OpBranch.opBranch(io);
|
||||||
}
|
}
|
||||||
|
|
||||||
is(OpCode.OpStore) {
|
is(OpCode.OpStore) {
|
||||||
io.optype := OpType.S
|
|
||||||
OpStore.opStore(io);
|
OpStore.opStore(io);
|
||||||
}
|
}
|
||||||
|
|
||||||
is(OpCode.OpLoad) {
|
is(OpCode.OpLoad) {
|
||||||
io.optype := OpType.I
|
|
||||||
OpLoad.opLoad(io);
|
OpLoad.opLoad(io);
|
||||||
}
|
}
|
||||||
|
|
||||||
is(OpCode.OpImmW) {
|
is(OpCode.OpImmW) {
|
||||||
io.reg_file_we := true.B // Write to regfile
|
|
||||||
io.optype := OpType.I
|
|
||||||
OpImmW.opImmW(io);
|
OpImmW.opImmW(io);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import chisel3.util.switch
|
|||||||
import projet.CUInterface
|
import projet.CUInterface
|
||||||
import projet.AluOpCode
|
import projet.AluOpCode
|
||||||
import chisel3.util.is
|
import chisel3.util.is
|
||||||
|
import projet.OpType
|
||||||
|
|
||||||
object OpBranch {
|
object OpBranch {
|
||||||
// Implements functions for all instruction of the branch kind
|
// Implements functions for all instruction of the branch kind
|
||||||
@@ -21,6 +22,7 @@ object OpBranch {
|
|||||||
val BGEU = "b111".U
|
val BGEU = "b111".U
|
||||||
}
|
}
|
||||||
|
|
||||||
|
io.optype := OpType.B
|
||||||
val branch = WireInit(false.B);
|
val branch = WireInit(false.B);
|
||||||
switch(funct3) {
|
switch(funct3) {
|
||||||
is(Funct3.BEQ) {
|
is(Funct3.BEQ) {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ object OpImm {
|
|||||||
val ShiftRight = "b101".U
|
val ShiftRight = "b101".U
|
||||||
}
|
}
|
||||||
|
|
||||||
|
io.reg_file_we := true.B // Write to regfile
|
||||||
io.mux_regb_imm := false.B; // OpImm are operations with imm, so send imm to ALU
|
io.mux_regb_imm := false.B; // OpImm are operations with imm, so send imm to ALU
|
||||||
io.mux_alu_imm := true.B;
|
io.mux_alu_imm := true.B;
|
||||||
io.mux_rega_pc := true.B;
|
io.mux_rega_pc := true.B;
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ object OpImmW {
|
|||||||
val SRLIW_SRAIW = "b101".U // Right shifts
|
val SRLIW_SRAIW = "b101".U // Right shifts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
io.optype := OpType.I;
|
||||||
|
io.reg_file_we := true.B // Write to regfile
|
||||||
io.mux_regb_imm := false.B; // OpImm are operations with imm, so send imm to ALU
|
io.mux_regb_imm := false.B; // OpImm are operations with imm, so send imm to ALU
|
||||||
io.mux_alu_imm := true.B;
|
io.mux_alu_imm := true.B;
|
||||||
io.mux_rega_pc := true.B;
|
io.mux_rega_pc := true.B;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import projet.CUInterface
|
|||||||
import projet.AluOpCode
|
import projet.AluOpCode
|
||||||
import chisel3.util.is
|
import chisel3.util.is
|
||||||
import projet.DMemSize
|
import projet.DMemSize
|
||||||
|
import projet.OpType
|
||||||
|
|
||||||
object OpLoad {
|
object OpLoad {
|
||||||
// Implements functions for all instruction of the OpLoad kind
|
// Implements functions for all instruction of the OpLoad kind
|
||||||
@@ -21,6 +22,7 @@ object OpLoad {
|
|||||||
val LHU = "b101".U
|
val LHU = "b101".U
|
||||||
}
|
}
|
||||||
|
|
||||||
|
io.optype := OpType.I
|
||||||
io.alu_opcode := AluOpCode.Add
|
io.alu_opcode := AluOpCode.Add
|
||||||
io.mux_alu_imm := true.B
|
io.mux_alu_imm := true.B
|
||||||
io.mux_rega_pc := true.B
|
io.mux_rega_pc := true.B
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import chisel3.util.switch
|
|||||||
import projet.CUInterface
|
import projet.CUInterface
|
||||||
import projet.AluOpCode
|
import projet.AluOpCode
|
||||||
import chisel3.util.is
|
import chisel3.util.is
|
||||||
|
import projet.OpType
|
||||||
|
|
||||||
object OpR {
|
object OpR {
|
||||||
// implements functions for all instruction of the opr kind
|
// implements functions for all instruction of the opr kind
|
||||||
@@ -37,6 +38,7 @@ object OpR {
|
|||||||
val SUB = "b0100000".U
|
val SUB = "b0100000".U
|
||||||
}
|
}
|
||||||
|
|
||||||
|
io.reg_file_we := true.B // Write to regfile
|
||||||
io.mux_regb_imm := true.B; // OpImm are operations with imm, so send imm to ALU
|
io.mux_regb_imm := true.B; // OpImm are operations with imm, so send imm to ALU
|
||||||
io.mux_rega_pc := true.B;
|
io.mux_rega_pc := true.B;
|
||||||
io.mux_alu_imm := true.B;
|
io.mux_alu_imm := true.B;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import projet.CUInterface
|
|||||||
import projet.AluOpCode
|
import projet.AluOpCode
|
||||||
import chisel3.util.is
|
import chisel3.util.is
|
||||||
import projet.DMemSize
|
import projet.DMemSize
|
||||||
|
import projet.OpType
|
||||||
|
|
||||||
object OpStore {
|
object OpStore {
|
||||||
// Implements functions for all instruction of the OpStore kind
|
// Implements functions for all instruction of the OpStore kind
|
||||||
@@ -19,6 +20,7 @@ object OpStore {
|
|||||||
val SW = "b010".U
|
val SW = "b010".U
|
||||||
}
|
}
|
||||||
|
|
||||||
|
io.optype := OpType.S
|
||||||
io.alu_opcode := AluOpCode.Add
|
io.alu_opcode := AluOpCode.Add
|
||||||
io.mux_alu_imm := true.B
|
io.mux_alu_imm := true.B
|
||||||
io.mux_rega_pc := true.B
|
io.mux_rega_pc := true.B
|
||||||
|
|||||||
Reference in New Issue
Block a user