Skip to content

Commit e4d09fa

Browse files
committed
feat: fetch inst two time to get right res
1 parent fbd4a99 commit e4d09fa

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

rtl/tc_l2/src/main/scala/core/inst/PCReg.scala

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ class PCReg() extends Module with AXI4Config {
1414
protected val hdShkDone: Bool = WireDefault(io.axi.ready && io.axi.valid)
1515
protected val pc: UInt = if (SoCEna) RegInit(PCFlashStartAddr.U(BusWidth.W)) else RegInit(PCLoadStartAddr.U(BusWidth.W))
1616
protected val dirty: Bool = RegInit(false.B)
17+
protected val socRdCnt: UInt = RegInit(0.U(1.W))
18+
protected val validctrl: Bool = RegInit(false.B)
1719

20+
// fix the ready sig is triggered when mem access bug
21+
when(!io.axi.valid && io.axi.ready) {
22+
validctrl := true.B
23+
}
1824
// now we dont handle this resp info to check if the read oper is right
1925
// tmp
2026
protected val tmpStall = if (SoCEna) RegNext(~io.ctrl2pc.maStall) else ~io.ctrl2pc.maStall
@@ -37,20 +43,28 @@ class PCReg() extends Module with AXI4Config {
3743
dirty := true.B
3844
}
3945

40-
when(hdShkDone) {
41-
when(!dirty) {
42-
pc := pc + 4.U(BusWidth.W)
43-
io.instEnaOut := true.B
44-
// printf("handshake done!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
45-
// printf(p"[pc]io.axi.rdata = 0x${Hexadecimal(io.axi.rdata)}\n")
46-
io.instDataOut := io.axi.rdata(31, 0)
46+
when(SoCEna.B && socRdCnt === 0.U && hdShkDone && pc >= "h8000_0000".U) {
47+
socRdCnt := socRdCnt + 1.U
48+
io.instEnaOut := false.B
49+
io.instDataOut := NopInst.U
50+
}.otherwise {
51+
when(hdShkDone || (io.axi.valid && validctrl)) {
52+
socRdCnt := 0.U
53+
when(!dirty) {
54+
pc := pc + 4.U(BusWidth.W)
55+
io.instEnaOut := true.B
56+
// printf("handshake done!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
57+
// printf(p"[pc]io.axi.rdata = 0x${Hexadecimal(io.axi.rdata)}\n")
58+
io.instDataOut := io.axi.rdata(31, 0)
59+
validctrl := false.B
60+
}.otherwise {
61+
dirty := false.B
62+
io.instEnaOut := false.B
63+
io.instDataOut := NopInst.U
64+
}
4765
}.otherwise {
48-
dirty := false.B
4966
io.instEnaOut := false.B
5067
io.instDataOut := NopInst.U
5168
}
52-
}.otherwise {
53-
io.instEnaOut := false.B
54-
io.instDataOut := NopInst.U
5569
}
5670
}

0 commit comments

Comments
 (0)