From d0c6b50fdefcdbe121e9788433ea51f7efaf1d32 Mon Sep 17 00:00:00 2001 From: John Ingalls <43973001+ingallsj@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:09:41 -0700 Subject: [PATCH] VM disabled: support larger physical addresses (#3682) --- src/main/scala/rocket/CSR.scala | 2 +- src/main/scala/rocket/PTW.scala | 2 +- src/main/scala/rocket/TLB.scala | 2 +- src/main/scala/tile/BaseTile.scala | 6 +++++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/scala/rocket/CSR.scala b/src/main/scala/rocket/CSR.scala index 407b1e988be..1003838ffa4 100644 --- a/src/main/scala/rocket/CSR.scala +++ b/src/main/scala/rocket/CSR.scala @@ -149,7 +149,7 @@ class PTBR(implicit p: Parameters) extends CoreBundle()(p) { case 32 => (1, 9) case 64 => (4, 16) } - require(modeBits + maxASIdBits + maxPAddrBits - pgIdxBits == xLen) + require(!usingVM || modeBits + maxASIdBits + maxPAddrBits - pgIdxBits == xLen) val mode = UInt(modeBits.W) val asid = UInt(maxASIdBits.W) diff --git a/src/main/scala/rocket/PTW.scala b/src/main/scala/rocket/PTW.scala index 872b143e24c..04dd994efe3 100644 --- a/src/main/scala/rocket/PTW.scala +++ b/src/main/scala/rocket/PTW.scala @@ -303,7 +303,7 @@ class PTW(n: Int)(implicit edge: TLEdgeOut, p: Parameters) extends CoreModule()( val (pte, invalid_paddr, invalid_gpa) = { val tmp = mem_resp_data.asTypeOf(new PTE()) val res = WireDefault(tmp) - res.ppn := Mux(do_both_stages && !stage2, tmp.ppn(vpnBits.min(tmp.ppn.getWidth)-1, 0), tmp.ppn(ppnBits-1, 0)) + res.ppn := Mux(do_both_stages && !stage2, tmp.ppn(vpnBits.min(tmp.ppn.getWidth)-1, 0), tmp.ppn(ppnBits.min(tmp.ppn.getWidth)-1, 0)) when (tmp.r || tmp.w || tmp.x) { // for superpage mappings, make sure PPN LSBs are zero for (i <- 0 until pgLevels-1) diff --git a/src/main/scala/rocket/TLB.scala b/src/main/scala/rocket/TLB.scala index 8cc4a2c67c9..4f2d09c9e45 100644 --- a/src/main/scala/rocket/TLB.scala +++ b/src/main/scala/rocket/TLB.scala @@ -403,7 +403,7 @@ class TLB(instruction: Boolean, lgMaxSize: Int, cfg: TLBConfig)(implicit edge: T val vsatp_mode_mismatch = priv_v && (vstage1_en =/= v_entries_use_stage1) && !io.req.bits.passthrough // share a single physical memory attribute checker (unshare if critical path) - val refill_ppn = io.ptw.resp.bits.pte.ppn(ppnBits-1, 0) + val refill_ppn = if (usingVM) io.ptw.resp.bits.pte.ppn(ppnBits-1, 0) else 0.U /** refill signal */ val do_refill = usingVM.B && io.ptw.resp.valid /** sfence invalidate refill */ diff --git a/src/main/scala/tile/BaseTile.scala b/src/main/scala/tile/BaseTile.scala index 263b73c69a8..21d04607e9c 100644 --- a/src/main/scala/tile/BaseTile.scala +++ b/src/main/scala/tile/BaseTile.scala @@ -83,7 +83,11 @@ trait HasNonDiplomaticTileParameters { def vmIdBits: Int = p(VMIdBits) lazy val maxPAddrBits: Int = { require(xLen == 32 || xLen == 64, s"Only XLENs of 32 or 64 are supported, but got $xLen") - xLen match { case 32 => 34; case 64 => 56 } + ((xLen, usingVM): @unchecked) match { + case (_, false) => xLen + case (32, true) => 34 + case (64, true) => 56 + } } def tileId: Int = tileParams.tileId