1
0

Express PMP mask generation with incrementer, not adder

DC apparently doesn't always pick up the ((x + 1) ^ x) idiom.
Use (x + ~(x + 1)) instead.
This commit is contained in:
Andrew Waterman 2017-04-27 14:31:50 -07:00
parent e99fa057ac
commit 8c10caeef9

View File

@ -42,7 +42,7 @@ class PMP(implicit p: Parameters) extends PMPReg {
val mask = UInt(width = paddrBits) val mask = UInt(width = paddrBits)
import PMP._ import PMP._
def computeMask = Cat((Cat(addr, cfg.a(0)) + 1) ^ Cat(addr, cfg.a(0)), UInt((BigInt(1) << (lgAlign-1)) - 1, lgAlign-1)) def computeMask = Cat(Cat(addr, cfg.a(0)) & ~(Cat(addr, cfg.a(0)) + 1), UInt((BigInt(1) << lgAlign) - 1, lgAlign))
private def comparand = addr << lgAlign private def comparand = addr << lgAlign
private def pow2Match(x: UInt, lgSize: UInt, lgMaxSize: Int) = { private def pow2Match(x: UInt, lgSize: UInt, lgMaxSize: Int) = {