Skip to content

Commit

Permalink
fix CALCULATE_IMM op bug (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
longfangsong authored May 24, 2022
1 parent a913040 commit aea8496
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/scala/CPU.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CPU extends Module {

val io = IO(new CPUBundle)

// inherit from BSD*.
// start up address here are from BSD's CPU
val pc = RegInit("h80000000".U(32.W))
pc := pc + 4.U
io.programROMBundle.address := pc
Expand Down Expand Up @@ -144,7 +144,11 @@ class CPU extends Module {
regFile.io.writeEnable := true.B
alu.io.A := regFile.io.outputA
alu.io.B := immGen.io.result.asUInt()
alu.io.op := Cat(instruction(30), instruction(14, 12))
when(instruction(14, 12) === "b001".U || instruction(14, 12) === "b101".U) {
alu.io.op := Cat(instruction(30), instruction(14, 12))
}.otherwise {
alu.io.op := Cat(0.U(1.W), instruction(14, 12))
}
regFile.io.input := alu.io.result
}
is(CALCULATE_REG) {
Expand Down

0 comments on commit aea8496

Please sign in to comment.