Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Svpbmt): support WMO memory access and outstanding of NC #3900

Merged
merged 9 commits into from
Dec 4, 2024
3 changes: 3 additions & 0 deletions src/main/scala/xiangshan/Bundle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,12 @@ class ResetPregStateReq(implicit p: Parameters) extends XSBundle {

class DebugBundle(implicit p: Parameters) extends XSBundle {
val isMMIO = Bool()
val isNC = Bool()
val isPerfCnt = Bool()
val paddr = UInt(PAddrBits.W)
val vaddr = UInt(VAddrBits.W)

def isSkipDiff: Bool = isMMIO || isNC || isPerfCnt
/* add L/S inst info in EXU */
// val L1toL2TlbLatency = UInt(XLEN.W)
// val levelTlbHit = UInt(2.W)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/xiangshan/XSCore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class XSCoreImp(outer: XSCoreBase) extends LazyModuleImp(outer)
memBlock.io.ooo_to_mem.tlbCsr := backend.io.mem.tlbCsr
memBlock.io.ooo_to_mem.lsqio.lcommit := backend.io.mem.robLsqIO.lcommit
memBlock.io.ooo_to_mem.lsqio.scommit := backend.io.mem.robLsqIO.scommit
memBlock.io.ooo_to_mem.lsqio.pendingUncacheld := backend.io.mem.robLsqIO.pendingUncacheld
memBlock.io.ooo_to_mem.lsqio.pendingMMIOld := backend.io.mem.robLsqIO.pendingMMIOld
memBlock.io.ooo_to_mem.lsqio.pendingld := backend.io.mem.robLsqIO.pendingld
memBlock.io.ooo_to_mem.lsqio.pendingst := backend.io.mem.robLsqIO.pendingst
memBlock.io.ooo_to_mem.lsqio.pendingVst := backend.io.mem.robLsqIO.pendingVst
Expand Down
19 changes: 12 additions & 7 deletions src/main/scala/xiangshan/backend/MemBlock.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ trait HasMemBlockParameters extends HasXSParameter {
val AtomicWBPort = 0
val MisalignWBPort = 1
val UncacheWBPort = 2
val NCWBPorts = Seq(1, 2)
}

abstract class MemBlockBundle(implicit val p: Parameters) extends Bundle with HasMemBlockParameters
Expand All @@ -89,7 +90,7 @@ class ooo_to_mem(implicit p: Parameters) extends MemBlockBundle {
val lsqio = new Bundle {
val lcommit = Input(UInt(log2Up(CommitWidth + 1).W))
val scommit = Input(UInt(log2Up(CommitWidth + 1).W))
val pendingUncacheld = Input(Bool())
val pendingMMIOld = Input(Bool())
val pendingld = Input(Bool())
val pendingst = Input(Bool())
val pendingVst = Input(Bool())
Expand Down Expand Up @@ -820,6 +821,7 @@ class MemBlockInlinedImp(outer: MemBlockInlined) extends LazyModuleImp(outer)
// forward
loadUnits(i).io.lsq.forward <> lsq.io.forward(i)
loadUnits(i).io.sbuffer <> sbuffer.io.forward(i)
loadUnits(i).io.ubuffer <> uncache.io.forward(i)
loadUnits(i).io.tl_d_channel := dcache.io.lsu.forward_D(i)
loadUnits(i).io.forward_mshr <> dcache.io.lsu.forward_mshr(i)
// ld-ld violation check
Expand Down Expand Up @@ -905,6 +907,7 @@ class MemBlockInlinedImp(outer: MemBlockInlined) extends LazyModuleImp(outer)
loadUnits(i).io.lsq.uncache.bits := DontCare
}
lsq.io.ld_raw_data(i) <> loadUnits(i).io.lsq.ld_raw_data
lsq.io.ncOut(i) <> loadUnits(i).io.lsq.nc_ldin
lsq.io.l2_hint.valid := l2_hint.valid
lsq.io.l2_hint.bits.sourceId := l2_hint.bits.sourceId
lsq.io.l2_hint.bits.isKeyword := l2_hint.bits.isKeyword
Expand Down Expand Up @@ -962,6 +965,7 @@ class MemBlockInlinedImp(outer: MemBlockInlined) extends LazyModuleImp(outer)
hybridUnits(i).io.ldu_io.lsq.forward <> lsq.io.forward(LduCnt + i)
// forward
hybridUnits(i).io.ldu_io.sbuffer <> sbuffer.io.forward(LduCnt + i)
hybridUnits(i).io.ldu_io.ubuffer <> uncache.io.forward(LduCnt + i)
// hybridUnits(i).io.ldu_io.vec_forward <> vsFlowQueue.io.forward(LduCnt + i)
hybridUnits(i).io.ldu_io.vec_forward := DontCare
hybridUnits(i).io.ldu_io.tl_d_channel := dcache.io.lsu.forward_D(LduCnt + i)
Expand Down Expand Up @@ -1035,6 +1039,8 @@ class MemBlockInlinedImp(outer: MemBlockInlined) extends LazyModuleImp(outer)


// passdown to lsq (load s2)
hybridUnits(i).io.ldu_io.lsq.nc_ldin.valid := false.B
hybridUnits(i).io.ldu_io.lsq.nc_ldin.bits := DontCare
lsq.io.ldu.ldin(LduCnt + i) <> hybridUnits(i).io.ldu_io.lsq.ldin
// Lsq to sta unit
lsq.io.sta.storeMaskIn(StaCnt + i) <> hybridUnits(i).io.stu_io.st_mask_out
Expand Down Expand Up @@ -1074,7 +1080,7 @@ class MemBlockInlinedImp(outer: MemBlockInlined) extends LazyModuleImp(outer)
loadMisalignBuffer.io.redirect <> redirect
loadMisalignBuffer.io.rob.lcommit := io.ooo_to_mem.lsqio.lcommit
loadMisalignBuffer.io.rob.scommit := io.ooo_to_mem.lsqio.scommit
loadMisalignBuffer.io.rob.pendingUncacheld := io.ooo_to_mem.lsqio.pendingUncacheld
loadMisalignBuffer.io.rob.pendingMMIOld := io.ooo_to_mem.lsqio.pendingMMIOld
loadMisalignBuffer.io.rob.pendingld := io.ooo_to_mem.lsqio.pendingld
loadMisalignBuffer.io.rob.pendingst := io.ooo_to_mem.lsqio.pendingst
loadMisalignBuffer.io.rob.pendingVst := io.ooo_to_mem.lsqio.pendingVst
Expand All @@ -1087,7 +1093,7 @@ class MemBlockInlinedImp(outer: MemBlockInlined) extends LazyModuleImp(outer)
storeMisalignBuffer.io.redirect <> redirect
storeMisalignBuffer.io.rob.lcommit := io.ooo_to_mem.lsqio.lcommit
storeMisalignBuffer.io.rob.scommit := io.ooo_to_mem.lsqio.scommit
storeMisalignBuffer.io.rob.pendingUncacheld := io.ooo_to_mem.lsqio.pendingUncacheld
storeMisalignBuffer.io.rob.pendingMMIOld := io.ooo_to_mem.lsqio.pendingMMIOld
storeMisalignBuffer.io.rob.pendingld := io.ooo_to_mem.lsqio.pendingld
storeMisalignBuffer.io.rob.pendingst := io.ooo_to_mem.lsqio.pendingst
storeMisalignBuffer.io.rob.pendingVst := io.ooo_to_mem.lsqio.pendingVst
Expand Down Expand Up @@ -1276,7 +1282,7 @@ class MemBlockInlinedImp(outer: MemBlockInlined) extends LazyModuleImp(outer)
io.mem_to_ooo.lsqio.uop := lsq.io.rob.uop
lsq.io.rob.lcommit := io.ooo_to_mem.lsqio.lcommit
lsq.io.rob.scommit := io.ooo_to_mem.lsqio.scommit
lsq.io.rob.pendingUncacheld := io.ooo_to_mem.lsqio.pendingUncacheld
lsq.io.rob.pendingMMIOld := io.ooo_to_mem.lsqio.pendingMMIOld
lsq.io.rob.pendingld := io.ooo_to_mem.lsqio.pendingld
lsq.io.rob.pendingst := io.ooo_to_mem.lsqio.pendingst
lsq.io.rob.pendingVst := io.ooo_to_mem.lsqio.pendingVst
Expand All @@ -1298,7 +1304,7 @@ class MemBlockInlinedImp(outer: MemBlockInlined) extends LazyModuleImp(outer)
)).andR))
resultOnehot
}
val allRedirect = loadUnits.map(_.io.rollback) ++ hybridUnits.map(_.io.ldu_io.rollback) ++ Seq(lsq.io.nack_rollback) ++ lsq.io.nuke_rollback
val allRedirect = loadUnits.map(_.io.rollback) ++ hybridUnits.map(_.io.ldu_io.rollback) ++ lsq.io.nack_rollback ++ lsq.io.nuke_rollback
val oldestOneHot = selectOldestRedirect(allRedirect)
val oldestRedirect = WireDefault(Mux1H(oldestOneHot, allRedirect))
// memory replay would not cause IAF/IPF/IGPF
Expand Down Expand Up @@ -1329,8 +1335,7 @@ class MemBlockInlinedImp(outer: MemBlockInlined) extends LazyModuleImp(outer)
is (s_idle) {
when (uncacheReq.fire) {
when (lsq.io.uncache.req.valid) {
val isStore = lsq.io.uncache.req.bits.cmd === MemoryOpConstants.M_XWR
when (!isStore || !io.ooo_to_mem.csrCtrl.uncache_write_outstanding_enable) {
when (!lsq.io.uncache.req.bits.nc || !io.ooo_to_mem.csrCtrl.uncache_write_outstanding_enable) {
uncacheState := s_scalar_uncache
}
}.otherwise {
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/xiangshan/backend/rob/Rob.scala
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ class RobImp(override val wrapper: Rob)(implicit p: Parameters, params: BackendP
XSInfo(true.B,
p"writebacked pc 0x${Hexadecimal(debug_Uop.pc)} wen ${debug_Uop.rfWen} " +
p"data 0x${Hexadecimal(wb.bits.data(0))} ldst ${debug_Uop.ldest} pdst ${debug_Uop.pdest} " +
p"skip ${wb.bits.debug.isMMIO} robIdx: ${wb.bits.robIdx}\n"
p"skip ${wb.bits.debug.isSkipDiff} robIdx: ${wb.bits.robIdx}\n"
)
}
}
Expand Down Expand Up @@ -799,7 +799,7 @@ class RobImp(override val wrapper: Rob)(implicit p: Parameters, params: BackendP
io.lsq.lcommit := RegNext(Mux(io.commits.isCommit, PopCount(ldCommitVec), 0.U))
io.lsq.scommit := RegNext(Mux(io.commits.isCommit, PopCount(stCommitVec), 0.U))
// indicate a pending load or store
io.lsq.pendingUncacheld := RegNext(io.commits.isCommit && io.commits.info(0).commitType === CommitType.LOAD && robEntries(deqPtr.value).valid && robEntries(deqPtr.value).mmio)
io.lsq.pendingMMIOld := RegNext(io.commits.isCommit && io.commits.info(0).commitType === CommitType.LOAD && robEntries(deqPtr.value).valid && robEntries(deqPtr.value).mmio)
io.lsq.pendingld := RegNext(io.commits.isCommit && io.commits.info(0).commitType === CommitType.LOAD && robEntries(deqPtr.value).valid)
// TODO: Check if need deassert pendingst when it is vst
io.lsq.pendingst := RegNext(io.commits.isCommit && io.commits.info(0).commitType === CommitType.STORE && robEntries(deqPtr.value).valid)
Expand Down Expand Up @@ -1436,7 +1436,7 @@ class RobImp(override val wrapper: Rob)(implicit p: Parameters, params: BackendP
val isRVC = dt_isRVC(ptr)

val difftest = DifftestModule(new DiffInstrCommit(MaxPhyRegs), delay = 3, dontCare = true)
val dt_skip = Mux(eliminatedMove, false.B, exuOut.isMMIO || exuOut.isPerfCnt)
val dt_skip = Mux(eliminatedMove, false.B, exuOut.isSkipDiff)
difftest.coreid := io.hartId
difftest.index := i.U
difftest.valid := io.commits.commitValid(i) && io.commits.isCommit
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/xiangshan/backend/rob/RobBundles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class RobCSRIO(implicit p: Parameters) extends XSBundle {
class RobLsqIO(implicit p: Parameters) extends XSBundle {
val lcommit = Output(UInt(log2Up(CommitWidth + 1).W))
val scommit = Output(UInt(log2Up(CommitWidth + 1).W))
val pendingUncacheld = Output(Bool())
val pendingMMIOld = Output(Bool())
val pendingld = Output(Bool())
val pendingst = Output(Bool())
// set when vector store at the head of ROB
Expand Down
6 changes: 5 additions & 1 deletion src/main/scala/xiangshan/cache/dcache/DCacheWrapper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,13 @@ class UncacheWordReq(implicit p: Parameters) extends DCacheBundle
{
val cmd = UInt(M_SZ.W)
val addr = UInt(PAddrBits.W)
val vaddr = UInt(VAddrBits.W) // for uncache buffer forwarding
val data = UInt(XLEN.W)
val mask = UInt((XLEN/8).W)
val id = UInt(uncacheIdxBits.W)
val instrtype = UInt(sourceTypeWidth.W)
val atomic = Bool()
val nc = Bool()
val isFirstIssue = Bool()
val replayCarry = new ReplayCarry(nWays)

Expand All @@ -533,7 +535,9 @@ class UncacheWordResp(implicit p: Parameters) extends DCacheBundle
{
val data = UInt(XLEN.W)
val data_delayed = UInt(XLEN.W)
val id = UInt(uncacheIdxBits.W)
val id = UInt(uncacheIdxBits.W) // resp identified signals
val nc = Bool() // resp identified signals
val is2lq = Bool() // resp identified signals
val miss = Bool()
val replay = Bool()
val tag_error = Bool()
Expand Down
Loading
Loading