fix: Fix FetchUnit PC initialization issue
This commit is contained in:
parent
9862402688
commit
ed586e41b6
|
@ -13,7 +13,20 @@ class FetchUnit extends Module {
|
|||
val instSram = new InstSram()
|
||||
})
|
||||
|
||||
val pc = RegEnable(io.instSram.addr, (PC_INIT - 4.U), io.decodeStage.data.valid)
|
||||
val boot :: send :: recieve :: Nil = Enum(3)
|
||||
val state = RegInit(boot)
|
||||
|
||||
switch(state) {
|
||||
is(boot) {
|
||||
state := send
|
||||
}
|
||||
is(send) {
|
||||
state := recieve
|
||||
}
|
||||
is(recieve) {}
|
||||
}
|
||||
|
||||
val pc = RegEnable(io.instSram.addr, (PC_INIT - 4.U), state =/= boot)
|
||||
|
||||
io.instSram.addr := MuxCase(
|
||||
pc + 4.U,
|
||||
|
@ -23,7 +36,7 @@ class FetchUnit extends Module {
|
|||
)
|
||||
)
|
||||
|
||||
io.decodeStage.data.valid := RegNext(!reset.asBool, false.B) & !reset.asBool
|
||||
io.decodeStage.data.valid := state === recieve
|
||||
io.decodeStage.data.pc := pc
|
||||
io.decodeStage.data.inst := io.instSram.rdata
|
||||
io.decodeStage.data.addr_misaligned := pc(1, 0) =/= 0.U
|
||||
|
|
Loading…
Reference in New Issue