xref: /XiangShan/src/main/scala/xiangshan/cache/mmu/Repeater.scala (revision 35d6335ec1a21b9e3a55b5fdafb28519bb98b7d8)
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
32*35d6335eSZhangZifei  def apply(tlb: TlbPtwIO, ptw: TlbPtwIO, sfence: SfenceBundle, csr: TlbCsrBundle): Unit = {
33*35d6335eSZhangZifei    this.tlb <> tlb
34*35d6335eSZhangZifei    this.ptw <> ptw
35*35d6335eSZhangZifei    this.sfence <> sfence
36*35d6335eSZhangZifei    this.csr <> csr
37*35d6335eSZhangZifei  }
38*35d6335eSZhangZifei
39*35d6335eSZhangZifei  def apply(tlb: TlbPtwIO, sfence: SfenceBundle, csr: TlbCsrBundle): Unit = {
40*35d6335eSZhangZifei    this.tlb <> tlb
41*35d6335eSZhangZifei    this.sfence <> sfence
42*35d6335eSZhangZifei    this.csr <> csr
43*35d6335eSZhangZifei  }
44*35d6335eSZhangZifei
4545f497a4Shappy-lx  override def cloneType: this.type = (new PTWReapterIO(Width)).asInstanceOf[this.type]
4645f497a4Shappy-lx}
4745f497a4Shappy-lx
4845f497a4Shappy-lxclass PTWRepeater(Width: Int = 1)(implicit p: Parameters) extends XSModule with HasPtwConst {
4945f497a4Shappy-lx  val io = IO(new PTWReapterIO(Width))
5045f497a4Shappy-lx
516d5ddbceSLemover  val req_in = if (Width == 1) {
526d5ddbceSLemover    io.tlb.req(0)
536d5ddbceSLemover  } else {
546d5ddbceSLemover    val arb = Module(new RRArbiter(io.tlb.req(0).bits.cloneType, Width))
556d5ddbceSLemover    arb.io.in <> io.tlb.req
566d5ddbceSLemover    arb.io.out
576d5ddbceSLemover  }
5845f497a4Shappy-lx  val (tlb, ptw, flush) = (io.tlb, io.ptw, RegNext(io.sfence.valid || io.csr.satp.changed))
596d5ddbceSLemover  val req = RegEnable(req_in.bits, req_in.fire())
606d5ddbceSLemover  val resp = RegEnable(ptw.resp.bits, ptw.resp.fire())
6145f497a4Shappy-lx  val haveOne = BoolStopWatch(req_in.fire(), tlb.resp.fire() || flush)
6245f497a4Shappy-lx  val sent = BoolStopWatch(ptw.req(0).fire(), req_in.fire() || flush)
6345f497a4Shappy-lx  val recv = BoolStopWatch(ptw.resp.fire(), req_in.fire() || flush)
646d5ddbceSLemover
656d5ddbceSLemover  req_in.ready := !haveOne
666d5ddbceSLemover  ptw.req(0).valid := haveOne && !sent
676d5ddbceSLemover  ptw.req(0).bits := req
686d5ddbceSLemover
696d5ddbceSLemover  tlb.resp.bits := resp
706d5ddbceSLemover  tlb.resp.valid := haveOne && recv
716d5ddbceSLemover  ptw.resp.ready := !recv
726d5ddbceSLemover
736d5ddbceSLemover  XSPerfAccumulate("req_count", ptw.req(0).fire())
7445f497a4Shappy-lx  XSPerfAccumulate("tlb_req_cycle", BoolStopWatch(req_in.fire(), tlb.resp.fire() || flush))
7545f497a4Shappy-lx  XSPerfAccumulate("ptw_req_cycle", BoolStopWatch(ptw.req(0).fire(), ptw.resp.fire() || flush))
766d5ddbceSLemover
7745f497a4Shappy-lx  XSDebug(haveOne, p"haveOne:${haveOne} sent:${sent} recv:${recv} sfence:${flush} req:${req} resp:${resp}")
786d5ddbceSLemover  XSDebug(req_in.valid || io.tlb.resp.valid, p"tlb: ${tlb}\n")
796d5ddbceSLemover  XSDebug(io.ptw.req(0).valid || io.ptw.resp.valid, p"ptw: ${ptw}\n")
806d5ddbceSLemover  assert(!RegNext(recv && io.ptw.resp.valid, init = false.B), "re-receive ptw.resp")
819bd9cdfaSLemover  TimeOutAssert(sent && !recv, timeOutThreshold, "Repeater doesn't recv resp in time")
826d5ddbceSLemover}
836d5ddbceSLemover
846d5ddbceSLemover/* dtlb
856d5ddbceSLemover *
866d5ddbceSLemover */
87*35d6335eSZhangZifei
88*35d6335eSZhangZifeiclass PTWRepeaterNB(Width: Int = 1, passReady: Boolean = false)(implicit p: Parameters) extends XSModule with HasPtwConst {
89*35d6335eSZhangZifei  val io = IO(new PTWReapterIO(Width))
90*35d6335eSZhangZifei
91*35d6335eSZhangZifei  val req_in = if (Width == 1) {
92*35d6335eSZhangZifei    io.tlb.req(0)
93*35d6335eSZhangZifei  } else {
94*35d6335eSZhangZifei    val arb = Module(new RRArbiter(io.tlb.req(0).bits.cloneType, Width))
95*35d6335eSZhangZifei    arb.io.in <> io.tlb.req
96*35d6335eSZhangZifei    arb.io.out
97*35d6335eSZhangZifei  }
98*35d6335eSZhangZifei  val (tlb, ptw, flush) = (io.tlb, io.ptw, RegNext(io.sfence.valid || io.csr.satp.changed))
99*35d6335eSZhangZifei  /* sent: tlb -> repeater -> ptw
100*35d6335eSZhangZifei   * recv: ptw -> repeater -> tlb
101*35d6335eSZhangZifei   * different from PTWRepeater
102*35d6335eSZhangZifei   */
103*35d6335eSZhangZifei
104*35d6335eSZhangZifei  // tlb -> repeater -> ptw
105*35d6335eSZhangZifei  val req = RegEnable(req_in.bits, req_in.fire())
106*35d6335eSZhangZifei  val sent = BoolStopWatch(req_in.fire(), ptw.req(0).fire() || flush)
107*35d6335eSZhangZifei  req_in.ready := !sent || { if (passReady) ptw.req(0).ready else false.B }
108*35d6335eSZhangZifei  ptw.req(0).valid := sent
109*35d6335eSZhangZifei  ptw.req(0).bits := req
110*35d6335eSZhangZifei
111*35d6335eSZhangZifei  // ptw -> repeater -> tlb
112*35d6335eSZhangZifei  val resp = RegEnable(ptw.resp.bits, ptw.resp.fire())
113*35d6335eSZhangZifei  val recv = BoolStopWatch(ptw.resp.fire(), tlb.resp.fire() || flush)
114*35d6335eSZhangZifei  ptw.resp.ready := !recv || { if (passReady) tlb.resp.ready else false.B }
115*35d6335eSZhangZifei  tlb.resp.valid := recv
116*35d6335eSZhangZifei  tlb.resp.bits := resp
117*35d6335eSZhangZifei
118*35d6335eSZhangZifei  XSPerfAccumulate("req", req_in.fire())
119*35d6335eSZhangZifei  XSPerfAccumulate("resp", tlb.resp.fire())
120*35d6335eSZhangZifei  if (!passReady) {
121*35d6335eSZhangZifei    XSPerfAccumulate("req_blank", req_in.valid && sent && ptw.req(0).ready)
122*35d6335eSZhangZifei    XSPerfAccumulate("resp_blank", ptw.resp.valid && recv && tlb.resp.ready)
123*35d6335eSZhangZifei    XSPerfAccumulate("req_blank_ignore_ready", req_in.valid && sent)
124*35d6335eSZhangZifei    XSPerfAccumulate("resp_blank_ignore_ready", ptw.resp.valid && recv)
125*35d6335eSZhangZifei  }
126*35d6335eSZhangZifei  XSDebug(req_in.valid || io.tlb.resp.valid, p"tlb: ${tlb}\n")
127*35d6335eSZhangZifei  XSDebug(io.ptw.req(0).valid || io.ptw.resp.valid, p"ptw: ${ptw}\n")
128*35d6335eSZhangZifei}
129*35d6335eSZhangZifei
13045f497a4Shappy-lxclass PTWFilterIO(Width: Int)(implicit p: Parameters) extends MMUIOBaseBundle {
131a0301c0dSLemover  val tlb = Flipped(new BTlbPtwIO(Width))
132a0301c0dSLemover  val ptw = new TlbPtwIO()
1336d5ddbceSLemover
134*35d6335eSZhangZifei  def apply(tlb: BTlbPtwIO, ptw: TlbPtwIO, sfence: SfenceBundle, csr: TlbCsrBundle): Unit = {
135*35d6335eSZhangZifei    this.tlb <> tlb
136*35d6335eSZhangZifei    this.ptw <> ptw
137*35d6335eSZhangZifei    this.sfence <> sfence
138*35d6335eSZhangZifei    this.csr <> csr
139*35d6335eSZhangZifei  }
140*35d6335eSZhangZifei
141*35d6335eSZhangZifei  def apply(tlb: BTlbPtwIO, sfence: SfenceBundle, csr: TlbCsrBundle): Unit = {
142*35d6335eSZhangZifei    this.tlb <> tlb
143*35d6335eSZhangZifei    this.sfence <> sfence
144*35d6335eSZhangZifei    this.csr <> csr
145*35d6335eSZhangZifei  }
146*35d6335eSZhangZifei
14745f497a4Shappy-lx  override def cloneType: this.type = (new PTWFilterIO(Width)).asInstanceOf[this.type]
14845f497a4Shappy-lx}
14945f497a4Shappy-lx
15045f497a4Shappy-lxclass PTWFilter(Width: Int, Size: Int)(implicit p: Parameters) extends XSModule with HasPtwConst {
1516d5ddbceSLemover  require(Size >= Width)
1526d5ddbceSLemover
15345f497a4Shappy-lx  val io = IO(new PTWFilterIO(Width))
15445f497a4Shappy-lx
1556d5ddbceSLemover  val v = RegInit(VecInit(Seq.fill(Size)(false.B)))
156a0301c0dSLemover  val ports = Reg(Vec(Size, Vec(Width, Bool()))) // record which port(s) the entry come from, may not able to cover all the ports
1576d5ddbceSLemover  val vpn = Reg(Vec(Size, UInt(vpnLen.W)))
1586d5ddbceSLemover  val enqPtr = RegInit(0.U(log2Up(Size).W)) // Enq
1596d5ddbceSLemover  val issPtr = RegInit(0.U(log2Up(Size).W)) // Iss to Ptw
1606d5ddbceSLemover  val deqPtr = RegInit(0.U(log2Up(Size).W)) // Deq
1616d5ddbceSLemover  val mayFullDeq = RegInit(false.B)
1626d5ddbceSLemover  val mayFullIss = RegInit(false.B)
1636d5ddbceSLemover  val counter = RegInit(0.U(log2Up(Size+1).W))
1646d5ddbceSLemover
16545f497a4Shappy-lx  val flush = RegNext(io.sfence.valid || io.csr.satp.changed)
1666d5ddbceSLemover  val ptwResp = RegEnable(io.ptw.resp.bits, io.ptw.resp.fire())
1676d5ddbceSLemover  val ptwResp_valid = RegNext(io.ptw.resp.valid, init = false.B)
168a0301c0dSLemover  val tlb_req = io.tlb.req
169a0301c0dSLemover  val oldMatchVec = tlb_req.map(a => vpn.zip(v).map{case (pi, vi) => vi && a.valid && pi === a.bits.vpn })
170a0301c0dSLemover  val newMatchVec = tlb_req.map(a => tlb_req.map(b => b.valid && a.valid && b.bits.vpn === a.bits.vpn ))
17145f497a4Shappy-lx  val ptwResp_newMatchVec = tlb_req.map(a => ptwResp_valid && ptwResp.entry.hit(a.bits.vpn, io.csr.satp.asid, allType = true) && a.valid) // TODO: may have long latency
17245f497a4Shappy-lx  val ptwResp_oldMatchVec = vpn.zip(v).map{ case (pi, vi) => vi && ptwResp.entry.hit(pi, io.csr.satp.asid, allType = true) }
173a0301c0dSLemover  val update_ports = v.indices.map(i => oldMatchVec.map(j => j(i)))
174a0301c0dSLemover  val ports_init = (0 until Width).map(i => (1 << i).U(Width.W))
175a0301c0dSLemover  val filter_ports = (0 until Width).map(i => ParallelMux(newMatchVec(i).zip(ports_init).drop(i)))
176a0301c0dSLemover  val resp_vector = ParallelMux(ptwResp_oldMatchVec zip ports)
177a0301c0dSLemover  val resp_still_valid = ParallelOR(ptwResp_oldMatchVec).asBool
1786d5ddbceSLemover
179a0301c0dSLemover  def canMerge(index: Int) : Bool = {
180a0301c0dSLemover    ptwResp_newMatchVec(index) ||
181a0301c0dSLemover    Cat(oldMatchVec(index)).orR ||
182a0301c0dSLemover    Cat(newMatchVec(index).take(index)).orR
183a0301c0dSLemover  }
184a0301c0dSLemover
185a0301c0dSLemover  def filter_req() = {
186a0301c0dSLemover    val reqs =  tlb_req.indices.map{ i =>
187a0301c0dSLemover      val req = Wire(ValidIO(new PtwReq()))
188a0301c0dSLemover      val merge = canMerge(i)
189a0301c0dSLemover      req.bits := tlb_req(i).bits
190a0301c0dSLemover      req.valid := !merge && tlb_req(i).valid
191a0301c0dSLemover      req
192a0301c0dSLemover    }
193a0301c0dSLemover    reqs
194a0301c0dSLemover  }
195a0301c0dSLemover
196a0301c0dSLemover  val reqs = filter_req()
197a0301c0dSLemover  val req_ports = filter_ports
1986d5ddbceSLemover  var enqPtr_next = WireInit(deqPtr)
1996d5ddbceSLemover  val isFull = enqPtr === deqPtr && mayFullDeq
2006d5ddbceSLemover  val isEmptyDeq = enqPtr === deqPtr && !mayFullDeq
2016d5ddbceSLemover  val isEmptyIss = enqPtr === issPtr && !mayFullIss
2026d5ddbceSLemover  val accumEnqNum = (0 until Width).map(i => PopCount(reqs.take(i).map(_.valid)))
2036d5ddbceSLemover  val enqPtrVec = VecInit((0 until Width).map(i => enqPtr + accumEnqNum(i)))
2046d5ddbceSLemover  val enqNum = PopCount(reqs.map(_.valid))
2056d5ddbceSLemover  val canEnqueue = counter +& enqNum <= Size.U
2066d5ddbceSLemover
2076d5ddbceSLemover  io.tlb.req.map(_.ready := true.B) // NOTE: just drop un-fire reqs
208a0301c0dSLemover  io.tlb.resp.valid := ptwResp_valid && resp_still_valid
209a0301c0dSLemover  io.tlb.resp.bits.data := ptwResp
210a0301c0dSLemover  io.tlb.resp.bits.vector := resp_vector
21145f497a4Shappy-lx  io.ptw.req(0).valid := v(issPtr) && !isEmptyIss && !(ptwResp_valid && ptwResp.entry.hit(io.ptw.req(0).bits.vpn, io.csr.satp.asid, ignoreAsid = true))
2126d5ddbceSLemover  io.ptw.req(0).bits.vpn := vpn(issPtr)
2136d5ddbceSLemover  io.ptw.resp.ready := true.B
2146d5ddbceSLemover
2156d5ddbceSLemover  reqs.zipWithIndex.map{
2166d5ddbceSLemover    case (req, i) =>
2176d5ddbceSLemover      when (req.valid && canEnqueue) {
2186d5ddbceSLemover        v(enqPtrVec(i)) := true.B
2196d5ddbceSLemover        vpn(enqPtrVec(i)) := req.bits.vpn
220a0301c0dSLemover        ports(enqPtrVec(i)) := req_ports(i).asBools
221a0301c0dSLemover      }
222a0301c0dSLemover  }
223a0301c0dSLemover  for (i <- ports.indices) {
224a0301c0dSLemover    when (v(i)) {
225a0301c0dSLemover      ports(i) := ports(i).zip(update_ports(i)).map(a => a._1 || a._2)
2266d5ddbceSLemover    }
2276d5ddbceSLemover  }
2286d5ddbceSLemover
2296d5ddbceSLemover  val do_enq = canEnqueue && Cat(reqs.map(_.valid)).orR
2306d5ddbceSLemover  val do_deq = (!v(deqPtr) && !isEmptyDeq)
2316d5ddbceSLemover  val do_iss = io.ptw.req(0).fire() || (!v(issPtr) && !isEmptyIss)
2326d5ddbceSLemover  when (do_enq) {
2336d5ddbceSLemover    enqPtr := enqPtr + enqNum
2346d5ddbceSLemover  }
2356d5ddbceSLemover  when (do_deq) {
2366d5ddbceSLemover    deqPtr := deqPtr + 1.U
2376d5ddbceSLemover  }
2386d5ddbceSLemover  when (do_iss) {
2396d5ddbceSLemover    issPtr := issPtr + 1.U
2406d5ddbceSLemover  }
2416d5ddbceSLemover  when (do_enq =/= do_deq) {
2426d5ddbceSLemover    mayFullDeq := do_enq
2436d5ddbceSLemover  }
2446d5ddbceSLemover  when (do_enq =/= do_iss) {
2456d5ddbceSLemover    mayFullIss := do_enq
2466d5ddbceSLemover  }
2476d5ddbceSLemover
2486d5ddbceSLemover  when (ptwResp_valid) {
249a0301c0dSLemover    v.zip(ptwResp_oldMatchVec).map{ case (vi, mi) => when (mi) { vi := false.B }}
2506d5ddbceSLemover  }
2516d5ddbceSLemover
2526d5ddbceSLemover  counter := counter - do_deq + Mux(do_enq, enqNum, 0.U)
2536d5ddbceSLemover  assert(counter <= Size.U, "counter should be less than Size")
2546d5ddbceSLemover  when (counter === 0.U) {
2556d5ddbceSLemover    assert(!io.ptw.req(0).fire(), "when counter is 0, should not req")
2566d5ddbceSLemover    assert(isEmptyDeq && isEmptyIss, "when counter is 0, should be empty")
2576d5ddbceSLemover  }
2586d5ddbceSLemover  when (counter === Size.U) {
2596d5ddbceSLemover    assert(mayFullDeq, "when counter is Size, should be full")
2606d5ddbceSLemover  }
2616d5ddbceSLemover
26245f497a4Shappy-lx  when (flush) {
2636d5ddbceSLemover    v.map(_ := false.B)
2646d5ddbceSLemover    deqPtr := 0.U
2656d5ddbceSLemover    enqPtr := 0.U
2666d5ddbceSLemover    issPtr := 0.U
2676d5ddbceSLemover    ptwResp_valid := false.B
2686d5ddbceSLemover    mayFullDeq := false.B
2696d5ddbceSLemover    mayFullIss := false.B
2706d5ddbceSLemover    counter := 0.U
2716d5ddbceSLemover  }
2726d5ddbceSLemover
2736d5ddbceSLemover  // perf
2746d5ddbceSLemover  val inflight_counter = RegInit(0.U(log2Up(Size + 1).W))
2756d5ddbceSLemover  when (io.ptw.req(0).fire() =/= io.ptw.resp.fire()) {
2766d5ddbceSLemover    inflight_counter := Mux(io.ptw.req(0).fire(), inflight_counter + 1.U, inflight_counter - 1.U)
2776d5ddbceSLemover  }
27845f497a4Shappy-lx  when (flush) {
2796d5ddbceSLemover    inflight_counter := 0.U
2806d5ddbceSLemover  }
2816d5ddbceSLemover  XSPerfAccumulate("tlb_req_count", PopCount(Cat(io.tlb.req.map(_.valid))))
2826d5ddbceSLemover  XSPerfAccumulate("tlb_req_count_filtered", Mux(do_enq, accumEnqNum(Width - 1), 0.U))
2836d5ddbceSLemover  XSPerfAccumulate("ptw_req_count", io.ptw.req(0).fire())
2846d5ddbceSLemover  XSPerfAccumulate("ptw_req_cycle", inflight_counter)
2856d5ddbceSLemover  XSPerfAccumulate("tlb_resp_count", io.tlb.resp.fire())
2866d5ddbceSLemover  XSPerfAccumulate("ptw_resp_count", io.ptw.resp.fire())
2876d5ddbceSLemover  XSPerfAccumulate("inflight_cycle", !isEmptyDeq)
2886d5ddbceSLemover  for (i <- 0 until Size + 1) {
2896d5ddbceSLemover    XSPerfAccumulate(s"counter${i}", counter === i.U)
2906d5ddbceSLemover  }
2919bd9cdfaSLemover
2929bd9cdfaSLemover  for (i <- 0 until Size) {
2939bd9cdfaSLemover    TimeOutAssert(v(i), timeOutThreshold, s"Filter ${i} doesn't recv resp in time")
2949bd9cdfaSLemover  }
2956d5ddbceSLemover}
29638ba1efdSLemover
29738ba1efdSLemoverobject PTWRepeater {
29838ba1efdSLemover  def apply(
29938ba1efdSLemover    tlb: TlbPtwIO,
30038ba1efdSLemover    sfence: SfenceBundle,
30138ba1efdSLemover    csr: TlbCsrBundle
30238ba1efdSLemover  )(implicit p: Parameters) = {
30338ba1efdSLemover    val width = tlb.req.size
30438ba1efdSLemover    val repeater = Module(new PTWRepeater(width))
305*35d6335eSZhangZifei    repeater.io.apply(tlb, sfence, csr)
30638ba1efdSLemover    repeater
30738ba1efdSLemover  }
30838ba1efdSLemover
30938ba1efdSLemover  def apply(
31038ba1efdSLemover    tlb: TlbPtwIO,
31138ba1efdSLemover    ptw: TlbPtwIO,
31238ba1efdSLemover    sfence: SfenceBundle,
31338ba1efdSLemover    csr: TlbCsrBundle
31438ba1efdSLemover  )(implicit p: Parameters) = {
31538ba1efdSLemover    val width = tlb.req.size
31638ba1efdSLemover    val repeater = Module(new PTWRepeater(width))
317*35d6335eSZhangZifei    repeater.io.apply(tlb, ptw, sfence, csr)
318*35d6335eSZhangZifei    repeater
319*35d6335eSZhangZifei  }
320*35d6335eSZhangZifei}
32138ba1efdSLemover
322*35d6335eSZhangZifeiobject PTWRepeaterNB {
323*35d6335eSZhangZifei  def apply(passReady: Boolean,
324*35d6335eSZhangZifei    tlb: TlbPtwIO,
325*35d6335eSZhangZifei    sfence: SfenceBundle,
326*35d6335eSZhangZifei    csr: TlbCsrBundle
327*35d6335eSZhangZifei  )(implicit p: Parameters) = {
328*35d6335eSZhangZifei    val width = tlb.req.size
329*35d6335eSZhangZifei    val repeater = Module(new PTWRepeaterNB(width, passReady))
330*35d6335eSZhangZifei    repeater.io.apply(tlb, sfence, csr)
331*35d6335eSZhangZifei    repeater
332*35d6335eSZhangZifei  }
333*35d6335eSZhangZifei
334*35d6335eSZhangZifei  def apply(passReady: Boolean,
335*35d6335eSZhangZifei    tlb: TlbPtwIO,
336*35d6335eSZhangZifei    ptw: TlbPtwIO,
337*35d6335eSZhangZifei    sfence: SfenceBundle,
338*35d6335eSZhangZifei    csr: TlbCsrBundle
339*35d6335eSZhangZifei  )(implicit p: Parameters) = {
340*35d6335eSZhangZifei    val width = tlb.req.size
341*35d6335eSZhangZifei    val repeater = Module(new PTWRepeaterNB(width, passReady))
342*35d6335eSZhangZifei    repeater.io.apply(tlb, ptw, sfence, csr)
34338ba1efdSLemover    repeater
34438ba1efdSLemover  }
34538ba1efdSLemover}
34638ba1efdSLemover
34738ba1efdSLemoverobject PTWFilter {
34838ba1efdSLemover  def apply(
34938ba1efdSLemover    tlb: BTlbPtwIO,
35038ba1efdSLemover    ptw: TlbPtwIO,
35138ba1efdSLemover    sfence: SfenceBundle,
35238ba1efdSLemover    csr: TlbCsrBundle,
35338ba1efdSLemover    size: Int
35438ba1efdSLemover  )(implicit p: Parameters) = {
35538ba1efdSLemover    val width = tlb.req.size
35638ba1efdSLemover    val filter = Module(new PTWFilter(width, size))
357*35d6335eSZhangZifei    filter.io.apply(tlb, ptw, sfence, csr)
35838ba1efdSLemover    filter
35938ba1efdSLemover  }
360*35d6335eSZhangZifei
361*35d6335eSZhangZifei  def apply(
362*35d6335eSZhangZifei    tlb: BTlbPtwIO,
363*35d6335eSZhangZifei    sfence: SfenceBundle,
364*35d6335eSZhangZifei    csr: TlbCsrBundle,
365*35d6335eSZhangZifei    size: Int
366*35d6335eSZhangZifei  )(implicit p: Parameters) = {
367*35d6335eSZhangZifei    val width = tlb.req.size
368*35d6335eSZhangZifei    val filter = Module(new PTWFilter(width, size))
369*35d6335eSZhangZifei    filter.io.apply(tlb, sfence, csr)
370*35d6335eSZhangZifei    filter
371*35d6335eSZhangZifei  }
372*35d6335eSZhangZifei
37338ba1efdSLemover}