Skip to content

Commit

Permalink
Start the restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
schoeberl committed Jul 25, 2024
1 parent 82448fe commit 13fe674
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/main/scala/leros/Decode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class DecodeOut extends Bundle {
val isLoadIndB = Bool()
val isLoadIndH = Bool()
val isDataAccess = Bool()
val isLoadAddr = Bool()
val isBranch = Bool()
val brType = UInt(4.W)
val exit = Bool()
Expand Down Expand Up @@ -52,7 +51,6 @@ object DecodeOut {
v.isLoadIndB := false.B
v.isLoadIndH := false.B
v.isDataAccess := false.B
v.isLoadAddr := false.B
v.isBranch := false.B
v.brType := 0.U
v.exit := false.B
Expand Down Expand Up @@ -189,7 +187,7 @@ class Decode() extends Module {
d.isStore := true.B
}
is (LDADDR.U) {
d.isLoadAddr := true.B
d.nextState := loadAddr
}
is (LDIND.U) {
d.isDataAccess := true.B
Expand Down
21 changes: 14 additions & 7 deletions src/main/scala/leros/Leros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,26 @@ class Leros(prog: String, size: Int = 32, memAddrWidth: Int = 8) extends LerosBa

val stateReg = RegInit(fetch)

when (stateReg =/= fetch) {
stateReg := fetch
pcReg := pcNext
alu.io.enaMask := decReg.enaMask
}

switch(stateReg) {
is (fetch) {
stateReg := decout.nextState
decReg := decout
}

// where is the "normal" ALU operation?

is (loadAddr) {
addrReg := dataRead
alu.io.enaMask := 0.U
}
is (execute) {
stateReg := fetch
pcReg := pcNext
alu.io.enaMask := decReg.enaMask
when(decReg.isLoadAddr) {
addrReg := dataRead
alu.io.enaMask := 0.U
}

when(decReg.isLoadInd) {
// nothing to be done here
}
Expand All @@ -110,6 +116,7 @@ class Leros(prog: String, size: Int = 32, memAddrWidth: Int = 8) extends LerosBa
outReg := accu
}
when(decReg.isStoreIndB) {
// wr and wrMask could be set in decode and registered
dataMem.io.wr := true.B
dataMem.io.wrMask := "b0001".U << effAddrOffReg
alu.io.enaMask := 0.U
Expand Down
5 changes: 4 additions & 1 deletion src/main/scala/leros/State.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ package leros

import chisel3.ChiselEnum
object State extends ChiselEnum {
val fetch, execute = Value
val fetch, execute,
loadAddr, loadInd, loadIndB, loadIndH,
store, storeInd, storeindB, storeIndH,
branch, jal = Value
}

0 comments on commit 13fe674

Please sign in to comment.