Implements stage 5

This commit is contained in:
2025-11-05 20:01:41 +01:00
parent 5df85799ef
commit 1462563e39
6 changed files with 107 additions and 29 deletions

View File

@@ -0,0 +1,31 @@
package projet
import chisel3._
import chisel3.util.switch
import chisel3.util.is
import chisel3.util.Cat
import chisel3.util.Fill
class ImmediateDecoder extends Module {
import projet.OpType
val io = IO(new Bundle {
val op_type = Input(OpType())
val instruction = Input(UInt(32.W))
val immediate = Output(UInt(32.W))
})
io.immediate := 0.U
// Decode imm-u
val imm_u = Cat(io.instruction(31, 12), 0.U(12.W));
// Decode imm-i
val imm_i = Cat(Fill(20, io.instruction(31)), io.instruction(31, 20));
switch(io.op_type) {
is(OpType.U) {
io.immediate := imm_u
}
is(OpType.I) {
io.immediate := imm_i
}
}
}