Skip to content

Commit

Permalink
Hypervisor: encodeVirtualAddress extra MSB to canonicalize VS-disabled (
Browse files Browse the repository at this point in the history
  • Loading branch information
ingallsj authored Mar 21, 2023
1 parent 9b74c4a commit 0504a9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/main/scala/rocket/RocketCore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1092,9 +1092,10 @@ class Rocket(tile: RocketTile)(implicit p: Parameters) extends CoreModule()(p)
def encodeVirtualAddress(a0: UInt, ea: UInt) = if (vaddrBitsExtended == vaddrBits) ea else {
// efficient means to compress 64-bit VA into vaddrBits+1 bits
// (VA is bad if VA(vaddrBits) != VA(vaddrBits-1))
val a = a0.asSInt >> vaddrBits
val msb = Mux(a === 0.S || a === -1.S, ea(vaddrBits), !ea(vaddrBits-1))
Cat(msb, ea(vaddrBits-1,0))
val b = vaddrBitsExtended-1
val a = (a0 >> b).asSInt
val msb = Mux(a === 0.S || a === -1.S, ea(b), !ea(b-1))
Cat(msb, ea(b-1, 0))
}

class Scoreboard(n: Int, zero: Boolean = false)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/tile/BaseTile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ trait HasTileParameters extends HasNonDiplomaticTileParameters {
}
def vpnBits: Int = vaddrBits - pgIdxBits
def ppnBits: Int = paddrBits - pgIdxBits
def vpnBitsExtended: Int = vpnBits + (vaddrBits < xLen).toInt
def vpnBitsExtended: Int = vpnBits + (if (vaddrBits < xLen) 1 + usingHypervisor.toInt else 0)
def vaddrBitsExtended: Int = vpnBitsExtended + pgIdxBits
}

Expand Down

0 comments on commit 0504a9b

Please sign in to comment.