xref: /XiangShan/src/main/scala/xiangshan/cache/mmu/Repeater.scala (revision fa9f96900103bd6a73978d25636da628b54245a9)
16d5ddbceSLemover/***************************************************************************************
26d5ddbceSLemover* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
3f320e0f0SYinan Xu* Copyright (c) 2020-2021 Peng Cheng Laboratory
46d5ddbceSLemover*
56d5ddbceSLemover* XiangShan is licensed under Mulan PSL v2.
66d5ddbceSLemover* You can use this software according to the terms and conditions of the Mulan PSL v2.
76d5ddbceSLemover* You may obtain a copy of Mulan PSL v2 at:
86d5ddbceSLemover*          http://license.coscl.org.cn/MulanPSL2
96d5ddbceSLemover*
106d5ddbceSLemover* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
116d5ddbceSLemover* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
126d5ddbceSLemover* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
136d5ddbceSLemover*
146d5ddbceSLemover* See the Mulan PSL v2 for more details.
156d5ddbceSLemover***************************************************************************************/
166d5ddbceSLemover
176d5ddbceSLemoverpackage xiangshan.cache.mmu
186d5ddbceSLemover
196d5ddbceSLemoverimport chipsalliance.rocketchip.config.Parameters
206d5ddbceSLemoverimport chisel3._
216d5ddbceSLemoverimport chisel3.util._
226d5ddbceSLemoverimport xiangshan._
236d5ddbceSLemoverimport xiangshan.cache.{HasDCacheParameters, MemoryOpConstants}
246d5ddbceSLemoverimport utils._
256d5ddbceSLemoverimport freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
266d5ddbceSLemoverimport freechips.rocketchip.tilelink._
276d5ddbceSLemover
2845f497a4Shappy-lxclass PTWReapterIO(Width: Int)(implicit p: Parameters) extends MMUIOBaseBundle {
296d5ddbceSLemover  val tlb = Flipped(new TlbPtwIO(Width))
306d5ddbceSLemover  val ptw = new TlbPtwIO
3145f497a4Shappy-lx
3235d6335eSZhangZifei  def apply(tlb: TlbPtwIO, ptw: TlbPtwIO, sfence: SfenceBundle, csr: TlbCsrBundle): Unit = {
3335d6335eSZhangZifei    this.tlb <> tlb
3435d6335eSZhangZifei    this.ptw <> ptw
3535d6335eSZhangZifei    this.sfence <> sfence
3635d6335eSZhangZifei    this.csr <> csr
3735d6335eSZhangZifei  }
3835d6335eSZhangZifei
3935d6335eSZhangZifei  def apply(tlb: TlbPtwIO, sfence: SfenceBundle, csr: TlbCsrBundle): Unit = {
4035d6335eSZhangZifei    this.tlb <> tlb
4135d6335eSZhangZifei    this.sfence <> sfence
4235d6335eSZhangZifei    this.csr <> csr
4335d6335eSZhangZifei  }
4435d6335eSZhangZifei
4545f497a4Shappy-lx}
4645f497a4Shappy-lx
4745f497a4Shappy-lxclass PTWRepeater(Width: Int = 1)(implicit p: Parameters) extends XSModule with HasPtwConst {
4845f497a4Shappy-lx  val io = IO(new PTWReapterIO(Width))
4945f497a4Shappy-lx
506d5ddbceSLemover  val req_in = if (Width == 1) {
516d5ddbceSLemover    io.tlb.req(0)
526d5ddbceSLemover  } else {
536d5ddbceSLemover    val arb = Module(new RRArbiter(io.tlb.req(0).bits.cloneType, Width))
546d5ddbceSLemover    arb.io.in <> io.tlb.req
556d5ddbceSLemover    arb.io.out
566d5ddbceSLemover  }
576f688dacSYinan Xu  val (tlb, ptw, flush) = (io.tlb, io.ptw, DelayN(io.sfence.valid || io.csr.satp.changed, 2))
586d5ddbceSLemover  val req = RegEnable(req_in.bits, req_in.fire())
596d5ddbceSLemover  val resp = RegEnable(ptw.resp.bits, ptw.resp.fire())
6045f497a4Shappy-lx  val haveOne = BoolStopWatch(req_in.fire(), tlb.resp.fire() || flush)
6145f497a4Shappy-lx  val sent = BoolStopWatch(ptw.req(0).fire(), req_in.fire() || flush)
6245f497a4Shappy-lx  val recv = BoolStopWatch(ptw.resp.fire(), req_in.fire() || flush)
636d5ddbceSLemover
646d5ddbceSLemover  req_in.ready := !haveOne
656d5ddbceSLemover  ptw.req(0).valid := haveOne && !sent
666d5ddbceSLemover  ptw.req(0).bits := req
676d5ddbceSLemover
686d5ddbceSLemover  tlb.resp.bits := resp
696d5ddbceSLemover  tlb.resp.valid := haveOne && recv
706d5ddbceSLemover  ptw.resp.ready := !recv
716d5ddbceSLemover
726d5ddbceSLemover  XSPerfAccumulate("req_count", ptw.req(0).fire())
7345f497a4Shappy-lx  XSPerfAccumulate("tlb_req_cycle", BoolStopWatch(req_in.fire(), tlb.resp.fire() || flush))
7445f497a4Shappy-lx  XSPerfAccumulate("ptw_req_cycle", BoolStopWatch(ptw.req(0).fire(), ptw.resp.fire() || flush))
756d5ddbceSLemover
7645f497a4Shappy-lx  XSDebug(haveOne, p"haveOne:${haveOne} sent:${sent} recv:${recv} sfence:${flush} req:${req} resp:${resp}")
776d5ddbceSLemover  XSDebug(req_in.valid || io.tlb.resp.valid, p"tlb: ${tlb}\n")
786d5ddbceSLemover  XSDebug(io.ptw.req(0).valid || io.ptw.resp.valid, p"ptw: ${ptw}\n")
796d5ddbceSLemover  assert(!RegNext(recv && io.ptw.resp.valid, init = false.B), "re-receive ptw.resp")
809bd9cdfaSLemover  TimeOutAssert(sent && !recv, timeOutThreshold, "Repeater doesn't recv resp in time")
816d5ddbceSLemover}
826d5ddbceSLemover
836d5ddbceSLemover/* dtlb
846d5ddbceSLemover *
856d5ddbceSLemover */
8635d6335eSZhangZifei
8735d6335eSZhangZifeiclass PTWRepeaterNB(Width: Int = 1, passReady: Boolean = false)(implicit p: Parameters) extends XSModule with HasPtwConst {
8835d6335eSZhangZifei  val io = IO(new PTWReapterIO(Width))
8935d6335eSZhangZifei
9035d6335eSZhangZifei  val req_in = if (Width == 1) {
9135d6335eSZhangZifei    io.tlb.req(0)
9235d6335eSZhangZifei  } else {
9335d6335eSZhangZifei    val arb = Module(new RRArbiter(io.tlb.req(0).bits.cloneType, Width))
9435d6335eSZhangZifei    arb.io.in <> io.tlb.req
9535d6335eSZhangZifei    arb.io.out
9635d6335eSZhangZifei  }
976f688dacSYinan Xu  val (tlb, ptw, flush) = (io.tlb, io.ptw, DelayN(io.sfence.valid || io.csr.satp.changed, 2))
9835d6335eSZhangZifei  /* sent: tlb -> repeater -> ptw
9935d6335eSZhangZifei   * recv: ptw -> repeater -> tlb
10035d6335eSZhangZifei   * different from PTWRepeater
10135d6335eSZhangZifei   */
10235d6335eSZhangZifei
10335d6335eSZhangZifei  // tlb -> repeater -> ptw
10435d6335eSZhangZifei  val req = RegEnable(req_in.bits, req_in.fire())
10535d6335eSZhangZifei  val sent = BoolStopWatch(req_in.fire(), ptw.req(0).fire() || flush)
10635d6335eSZhangZifei  req_in.ready := !sent || { if (passReady) ptw.req(0).ready else false.B }
10735d6335eSZhangZifei  ptw.req(0).valid := sent
10835d6335eSZhangZifei  ptw.req(0).bits := req
10935d6335eSZhangZifei
11035d6335eSZhangZifei  // ptw -> repeater -> tlb
11135d6335eSZhangZifei  val resp = RegEnable(ptw.resp.bits, ptw.resp.fire())
11235d6335eSZhangZifei  val recv = BoolStopWatch(ptw.resp.fire(), tlb.resp.fire() || flush)
11335d6335eSZhangZifei  ptw.resp.ready := !recv || { if (passReady) tlb.resp.ready else false.B }
11435d6335eSZhangZifei  tlb.resp.valid := recv
11535d6335eSZhangZifei  tlb.resp.bits := resp
11635d6335eSZhangZifei
11735d6335eSZhangZifei  XSPerfAccumulate("req", req_in.fire())
11835d6335eSZhangZifei  XSPerfAccumulate("resp", tlb.resp.fire())
11935d6335eSZhangZifei  if (!passReady) {
12035d6335eSZhangZifei    XSPerfAccumulate("req_blank", req_in.valid && sent && ptw.req(0).ready)
12135d6335eSZhangZifei    XSPerfAccumulate("resp_blank", ptw.resp.valid && recv && tlb.resp.ready)
12235d6335eSZhangZifei    XSPerfAccumulate("req_blank_ignore_ready", req_in.valid && sent)
12335d6335eSZhangZifei    XSPerfAccumulate("resp_blank_ignore_ready", ptw.resp.valid && recv)
12435d6335eSZhangZifei  }
12535d6335eSZhangZifei  XSDebug(req_in.valid || io.tlb.resp.valid, p"tlb: ${tlb}\n")
12635d6335eSZhangZifei  XSDebug(io.ptw.req(0).valid || io.ptw.resp.valid, p"ptw: ${ptw}\n")
12735d6335eSZhangZifei}
12835d6335eSZhangZifei
12945f497a4Shappy-lxclass PTWFilterIO(Width: Int)(implicit p: Parameters) extends MMUIOBaseBundle {
130a0301c0dSLemover  val tlb = Flipped(new BTlbPtwIO(Width))
131a0301c0dSLemover  val ptw = new TlbPtwIO()
1326d5ddbceSLemover
13335d6335eSZhangZifei  def apply(tlb: BTlbPtwIO, ptw: TlbPtwIO, sfence: SfenceBundle, csr: TlbCsrBundle): Unit = {
13435d6335eSZhangZifei    this.tlb <> tlb
13535d6335eSZhangZifei    this.ptw <> ptw
13635d6335eSZhangZifei    this.sfence <> sfence
13735d6335eSZhangZifei    this.csr <> csr
13835d6335eSZhangZifei  }
13935d6335eSZhangZifei
14035d6335eSZhangZifei  def apply(tlb: BTlbPtwIO, sfence: SfenceBundle, csr: TlbCsrBundle): Unit = {
14135d6335eSZhangZifei    this.tlb <> tlb
14235d6335eSZhangZifei    this.sfence <> sfence
14335d6335eSZhangZifei    this.csr <> csr
14435d6335eSZhangZifei  }
14535d6335eSZhangZifei
14645f497a4Shappy-lx}
14745f497a4Shappy-lx
14845f497a4Shappy-lxclass PTWFilter(Width: Int, Size: Int)(implicit p: Parameters) extends XSModule with HasPtwConst {
1496d5ddbceSLemover  require(Size >= Width)
1506d5ddbceSLemover
15145f497a4Shappy-lx  val io = IO(new PTWFilterIO(Width))
15245f497a4Shappy-lx
1536d5ddbceSLemover  val v = RegInit(VecInit(Seq.fill(Size)(false.B)))
154a0301c0dSLemover  val ports = Reg(Vec(Size, Vec(Width, Bool()))) // record which port(s) the entry come from, may not able to cover all the ports
1556d5ddbceSLemover  val vpn = Reg(Vec(Size, UInt(vpnLen.W)))
1566d5ddbceSLemover  val enqPtr = RegInit(0.U(log2Up(Size).W)) // Enq
1576d5ddbceSLemover  val issPtr = RegInit(0.U(log2Up(Size).W)) // Iss to Ptw
1586d5ddbceSLemover  val deqPtr = RegInit(0.U(log2Up(Size).W)) // Deq
1596d5ddbceSLemover  val mayFullDeq = RegInit(false.B)
1606d5ddbceSLemover  val mayFullIss = RegInit(false.B)
1616d5ddbceSLemover  val counter = RegInit(0.U(log2Up(Size+1).W))
1626d5ddbceSLemover
1636f688dacSYinan Xu  val flush = DelayN(io.sfence.valid || io.csr.satp.changed, 2)
164cccfc98dSLemover  val tlb_req = WireInit(io.tlb.req)
165cccfc98dSLemover  tlb_req.suggestName("tlb_req")
166cccfc98dSLemover
167*fa9f9690SLemover  val inflight_counter = RegInit(0.U(log2Up(Size + 1).W))
168*fa9f9690SLemover  val inflight_full = inflight_counter === Size.U
169*fa9f9690SLemover  when (io.ptw.req(0).fire() =/= io.ptw.resp.fire()) {
170*fa9f9690SLemover    inflight_counter := Mux(io.ptw.req(0).fire(), inflight_counter + 1.U, inflight_counter - 1.U)
171*fa9f9690SLemover  }
172*fa9f9690SLemover
1736d5ddbceSLemover  val ptwResp = RegEnable(io.ptw.resp.bits, io.ptw.resp.fire())
174cccfc98dSLemover  val ptwResp_OldMatchVec = vpn.zip(v).map{ case (pi, vi) =>
175cccfc98dSLemover    vi && io.ptw.resp.bits.entry.hit(pi, io.csr.satp.asid, true, true)}
176cccfc98dSLemover  val ptwResp_valid = RegNext(io.ptw.resp.fire() && Cat(ptwResp_OldMatchVec).orR, init = false.B)
177cccfc98dSLemover  val oldMatchVec_early = io.tlb.req.map(a => vpn.zip(v).map{ case (pi, vi) => vi && pi === a.bits.vpn})
178cccfc98dSLemover  val lastReqMatchVec_early = io.tlb.req.map(a => tlb_req.map{ b => b.valid && b.bits.vpn === a.bits.vpn})
179cccfc98dSLemover  val newMatchVec_early = io.tlb.req.map(a => io.tlb.req.map(b => a.bits.vpn === b.bits.vpn))
180cccfc98dSLemover
181cccfc98dSLemover  (0 until Width) foreach { i =>
182cccfc98dSLemover    tlb_req(i).valid := RegNext(io.tlb.req(i).valid &&
183cccfc98dSLemover      !(ptwResp_valid && ptwResp.entry.hit(io.tlb.req(i).bits.vpn, 0.U, true, true)) &&
184cccfc98dSLemover      !Cat(lastReqMatchVec_early(i)).orR,
185cccfc98dSLemover      init = false.B)
186cccfc98dSLemover    tlb_req(i).bits := RegEnable(io.tlb.req(i).bits, io.tlb.req(i).valid)
187cccfc98dSLemover  }
188cccfc98dSLemover
189cccfc98dSLemover  val oldMatchVec = oldMatchVec_early.map(a => RegNext(Cat(a).orR))
190cccfc98dSLemover  val newMatchVec = (0 until Width).map(i => (0 until Width).map(j =>
191cccfc98dSLemover    RegNext(newMatchVec_early(i)(j)) && tlb_req(j).valid
192cccfc98dSLemover  ))
193cccfc98dSLemover  val ptwResp_newMatchVec = tlb_req.map(a =>
194cccfc98dSLemover    ptwResp_valid && ptwResp.entry.hit(a.bits.vpn, 0.U, allType = true, true))
195cccfc98dSLemover
196cccfc98dSLemover  val oldMatchVec2 = (0 until Width).map(i => oldMatchVec_early(i).map(RegNext(_)).map(_ & tlb_req(i).valid))
197cccfc98dSLemover  val update_ports = v.indices.map(i => oldMatchVec2.map(j => j(i)))
198a0301c0dSLemover  val ports_init = (0 until Width).map(i => (1 << i).U(Width.W))
199a0301c0dSLemover  val filter_ports = (0 until Width).map(i => ParallelMux(newMatchVec(i).zip(ports_init).drop(i)))
200cccfc98dSLemover  val resp_vector = RegEnable(ParallelMux(ptwResp_OldMatchVec zip ports), io.ptw.resp.fire())
2016d5ddbceSLemover
202a0301c0dSLemover  def canMerge(index: Int) : Bool = {
203cccfc98dSLemover    ptwResp_newMatchVec(index) || oldMatchVec(index) ||
204a0301c0dSLemover    Cat(newMatchVec(index).take(index)).orR
205a0301c0dSLemover  }
206a0301c0dSLemover
207a0301c0dSLemover  def filter_req() = {
208a0301c0dSLemover    val reqs =  tlb_req.indices.map{ i =>
209a0301c0dSLemover      val req = Wire(ValidIO(new PtwReq()))
210a0301c0dSLemover      val merge = canMerge(i)
211a0301c0dSLemover      req.bits := tlb_req(i).bits
212a0301c0dSLemover      req.valid := !merge && tlb_req(i).valid
213a0301c0dSLemover      req
214a0301c0dSLemover    }
215a0301c0dSLemover    reqs
216a0301c0dSLemover  }
217a0301c0dSLemover
218a0301c0dSLemover  val reqs = filter_req()
219a0301c0dSLemover  val req_ports = filter_ports
2206d5ddbceSLemover  val isFull = enqPtr === deqPtr && mayFullDeq
2216d5ddbceSLemover  val isEmptyDeq = enqPtr === deqPtr && !mayFullDeq
2226d5ddbceSLemover  val isEmptyIss = enqPtr === issPtr && !mayFullIss
2236d5ddbceSLemover  val accumEnqNum = (0 until Width).map(i => PopCount(reqs.take(i).map(_.valid)))
224cccfc98dSLemover  val enqPtrVecInit = VecInit((0 until Width).map(i => enqPtr + i.U))
225cccfc98dSLemover  val enqPtrVec = VecInit((0 until Width).map(i => enqPtrVecInit(accumEnqNum(i))))
2266d5ddbceSLemover  val enqNum = PopCount(reqs.map(_.valid))
2276d5ddbceSLemover  val canEnqueue = counter +& enqNum <= Size.U
2286d5ddbceSLemover
2296d5ddbceSLemover  io.tlb.req.map(_.ready := true.B) // NOTE: just drop un-fire reqs
230cccfc98dSLemover  io.tlb.resp.valid := ptwResp_valid
231a0301c0dSLemover  io.tlb.resp.bits.data := ptwResp
232a0301c0dSLemover  io.tlb.resp.bits.vector := resp_vector
2332c2c1588SLemover
234*fa9f9690SLemover  val issue_valid = v(issPtr) && !isEmptyIss && !inflight_full
2352c2c1588SLemover  val issue_filtered = ptwResp_valid && ptwResp.entry.hit(io.ptw.req(0).bits.vpn, io.csr.satp.asid, allType=true, ignoreAsid=true)
2362c2c1588SLemover  val issue_fire_fake = issue_valid && (io.ptw.req(0).ready || (issue_filtered && false.B /*timing-opt*/))
2372c2c1588SLemover  io.ptw.req(0).valid := issue_valid && !issue_filtered
2386d5ddbceSLemover  io.ptw.req(0).bits.vpn := vpn(issPtr)
2396d5ddbceSLemover  io.ptw.resp.ready := true.B
2406d5ddbceSLemover
2416d5ddbceSLemover  reqs.zipWithIndex.map{
2426d5ddbceSLemover    case (req, i) =>
2436d5ddbceSLemover      when (req.valid && canEnqueue) {
2446d5ddbceSLemover        v(enqPtrVec(i)) := true.B
2456d5ddbceSLemover        vpn(enqPtrVec(i)) := req.bits.vpn
246a0301c0dSLemover        ports(enqPtrVec(i)) := req_ports(i).asBools
247a0301c0dSLemover      }
248a0301c0dSLemover  }
249a0301c0dSLemover  for (i <- ports.indices) {
250a0301c0dSLemover    when (v(i)) {
251a0301c0dSLemover      ports(i) := ports(i).zip(update_ports(i)).map(a => a._1 || a._2)
2526d5ddbceSLemover    }
2536d5ddbceSLemover  }
2546d5ddbceSLemover
2556d5ddbceSLemover  val do_enq = canEnqueue && Cat(reqs.map(_.valid)).orR
2566d5ddbceSLemover  val do_deq = (!v(deqPtr) && !isEmptyDeq)
2572c2c1588SLemover  val do_iss = issue_fire_fake || (!v(issPtr) && !isEmptyIss)
2586d5ddbceSLemover  when (do_enq) {
2596d5ddbceSLemover    enqPtr := enqPtr + enqNum
2606d5ddbceSLemover  }
2616d5ddbceSLemover  when (do_deq) {
2626d5ddbceSLemover    deqPtr := deqPtr + 1.U
2636d5ddbceSLemover  }
2646d5ddbceSLemover  when (do_iss) {
2656d5ddbceSLemover    issPtr := issPtr + 1.U
2666d5ddbceSLemover  }
2672c2c1588SLemover  when (issue_fire_fake && issue_filtered) { // issued but is filtered
2682c2c1588SLemover    v(issPtr) := false.B
2692c2c1588SLemover  }
2706d5ddbceSLemover  when (do_enq =/= do_deq) {
2716d5ddbceSLemover    mayFullDeq := do_enq
2726d5ddbceSLemover  }
2736d5ddbceSLemover  when (do_enq =/= do_iss) {
2746d5ddbceSLemover    mayFullIss := do_enq
2756d5ddbceSLemover  }
2766d5ddbceSLemover
277cccfc98dSLemover  when (io.ptw.resp.fire()) {
278cccfc98dSLemover    v.zip(ptwResp_OldMatchVec).map{ case (vi, mi) => when (mi) { vi := false.B }}
2796d5ddbceSLemover  }
2806d5ddbceSLemover
2816d5ddbceSLemover  counter := counter - do_deq + Mux(do_enq, enqNum, 0.U)
282*fa9f9690SLemover  assert(counter <= Size.U, "counter should be no more than Size")
283*fa9f9690SLemover  assert(inflight_counter <= Size.U, "inflight should be no more than Size")
2846d5ddbceSLemover  when (counter === 0.U) {
2856d5ddbceSLemover    assert(!io.ptw.req(0).fire(), "when counter is 0, should not req")
2866d5ddbceSLemover    assert(isEmptyDeq && isEmptyIss, "when counter is 0, should be empty")
2876d5ddbceSLemover  }
2886d5ddbceSLemover  when (counter === Size.U) {
2896d5ddbceSLemover    assert(mayFullDeq, "when counter is Size, should be full")
2906d5ddbceSLemover  }
2916d5ddbceSLemover
29245f497a4Shappy-lx  when (flush) {
2936d5ddbceSLemover    v.map(_ := false.B)
2946d5ddbceSLemover    deqPtr := 0.U
2956d5ddbceSLemover    enqPtr := 0.U
2966d5ddbceSLemover    issPtr := 0.U
2976d5ddbceSLemover    ptwResp_valid := false.B
2986d5ddbceSLemover    mayFullDeq := false.B
2996d5ddbceSLemover    mayFullIss := false.B
3006d5ddbceSLemover    counter := 0.U
301*fa9f9690SLemover    inflight_counter := 0.U
3026d5ddbceSLemover  }
3036d5ddbceSLemover
3046d5ddbceSLemover  // perf
3056d5ddbceSLemover  XSPerfAccumulate("tlb_req_count", PopCount(Cat(io.tlb.req.map(_.valid))))
3066d5ddbceSLemover  XSPerfAccumulate("tlb_req_count_filtered", Mux(do_enq, accumEnqNum(Width - 1), 0.U))
3076d5ddbceSLemover  XSPerfAccumulate("ptw_req_count", io.ptw.req(0).fire())
3086d5ddbceSLemover  XSPerfAccumulate("ptw_req_cycle", inflight_counter)
3096d5ddbceSLemover  XSPerfAccumulate("tlb_resp_count", io.tlb.resp.fire())
3106d5ddbceSLemover  XSPerfAccumulate("ptw_resp_count", io.ptw.resp.fire())
3116d5ddbceSLemover  XSPerfAccumulate("inflight_cycle", !isEmptyDeq)
3126d5ddbceSLemover  for (i <- 0 until Size + 1) {
3136d5ddbceSLemover    XSPerfAccumulate(s"counter${i}", counter === i.U)
3146d5ddbceSLemover  }
3159bd9cdfaSLemover
3169bd9cdfaSLemover  for (i <- 0 until Size) {
3179bd9cdfaSLemover    TimeOutAssert(v(i), timeOutThreshold, s"Filter ${i} doesn't recv resp in time")
3189bd9cdfaSLemover  }
3196d5ddbceSLemover}
32038ba1efdSLemover
32138ba1efdSLemoverobject PTWRepeater {
32238ba1efdSLemover  def apply(
32338ba1efdSLemover    tlb: TlbPtwIO,
32438ba1efdSLemover    sfence: SfenceBundle,
32538ba1efdSLemover    csr: TlbCsrBundle
32638ba1efdSLemover  )(implicit p: Parameters) = {
32738ba1efdSLemover    val width = tlb.req.size
32838ba1efdSLemover    val repeater = Module(new PTWRepeater(width))
32935d6335eSZhangZifei    repeater.io.apply(tlb, sfence, csr)
33038ba1efdSLemover    repeater
33138ba1efdSLemover  }
33238ba1efdSLemover
33338ba1efdSLemover  def apply(
33438ba1efdSLemover    tlb: TlbPtwIO,
33538ba1efdSLemover    ptw: TlbPtwIO,
33638ba1efdSLemover    sfence: SfenceBundle,
33738ba1efdSLemover    csr: TlbCsrBundle
33838ba1efdSLemover  )(implicit p: Parameters) = {
33938ba1efdSLemover    val width = tlb.req.size
34038ba1efdSLemover    val repeater = Module(new PTWRepeater(width))
34135d6335eSZhangZifei    repeater.io.apply(tlb, ptw, sfence, csr)
34235d6335eSZhangZifei    repeater
34335d6335eSZhangZifei  }
34435d6335eSZhangZifei}
34538ba1efdSLemover
34635d6335eSZhangZifeiobject PTWRepeaterNB {
34735d6335eSZhangZifei  def apply(passReady: Boolean,
34835d6335eSZhangZifei    tlb: TlbPtwIO,
34935d6335eSZhangZifei    sfence: SfenceBundle,
35035d6335eSZhangZifei    csr: TlbCsrBundle
35135d6335eSZhangZifei  )(implicit p: Parameters) = {
35235d6335eSZhangZifei    val width = tlb.req.size
35335d6335eSZhangZifei    val repeater = Module(new PTWRepeaterNB(width, passReady))
35435d6335eSZhangZifei    repeater.io.apply(tlb, sfence, csr)
35535d6335eSZhangZifei    repeater
35635d6335eSZhangZifei  }
35735d6335eSZhangZifei
35835d6335eSZhangZifei  def apply(passReady: Boolean,
35935d6335eSZhangZifei    tlb: TlbPtwIO,
36035d6335eSZhangZifei    ptw: TlbPtwIO,
36135d6335eSZhangZifei    sfence: SfenceBundle,
36235d6335eSZhangZifei    csr: TlbCsrBundle
36335d6335eSZhangZifei  )(implicit p: Parameters) = {
36435d6335eSZhangZifei    val width = tlb.req.size
36535d6335eSZhangZifei    val repeater = Module(new PTWRepeaterNB(width, passReady))
36635d6335eSZhangZifei    repeater.io.apply(tlb, ptw, sfence, csr)
36738ba1efdSLemover    repeater
36838ba1efdSLemover  }
36938ba1efdSLemover}
37038ba1efdSLemover
37138ba1efdSLemoverobject PTWFilter {
37238ba1efdSLemover  def apply(
37338ba1efdSLemover    tlb: BTlbPtwIO,
37438ba1efdSLemover    ptw: TlbPtwIO,
37538ba1efdSLemover    sfence: SfenceBundle,
37638ba1efdSLemover    csr: TlbCsrBundle,
37738ba1efdSLemover    size: Int
37838ba1efdSLemover  )(implicit p: Parameters) = {
37938ba1efdSLemover    val width = tlb.req.size
38038ba1efdSLemover    val filter = Module(new PTWFilter(width, size))
38135d6335eSZhangZifei    filter.io.apply(tlb, ptw, sfence, csr)
38238ba1efdSLemover    filter
38338ba1efdSLemover  }
38435d6335eSZhangZifei
38535d6335eSZhangZifei  def apply(
38635d6335eSZhangZifei    tlb: BTlbPtwIO,
38735d6335eSZhangZifei    sfence: SfenceBundle,
38835d6335eSZhangZifei    csr: TlbCsrBundle,
38935d6335eSZhangZifei    size: Int
39035d6335eSZhangZifei  )(implicit p: Parameters) = {
39135d6335eSZhangZifei    val width = tlb.req.size
39235d6335eSZhangZifei    val filter = Module(new PTWFilter(width, size))
39335d6335eSZhangZifei    filter.io.apply(tlb, sfence, csr)
39435d6335eSZhangZifei    filter
39535d6335eSZhangZifei  }
39635d6335eSZhangZifei
39738ba1efdSLemover}
398