Only use powers of two masks, for now

This commit is contained in:
Edward Wang
2017-07-21 10:33:29 -07:00
committed by edwardcwang
parent cf0d40f658
commit bb2783994a
2 changed files with 6 additions and 0 deletions

View File

@@ -178,6 +178,9 @@ class MacroCompilerPass(mems: Option[Seq[Macro]],
} else {
require(libPort.src.effectiveMaskGran == 1, "only single-bit mask supported for now")
require(isPowerOfTwo(memPort.src.effectiveMaskGran), "only powers of two masks supported for now")
require(isPowerOfTwo(libPort.src.effectiveMaskGran), "only powers of two masks supported for now")
cat(((low to high) map (i => bits(WRef(mem), i / memPort.src.effectiveMaskGran))).reverse)
}
case None =>

View File

@@ -93,4 +93,7 @@ object Utils {
case Some(ActiveLow) | Some(NegativeEdge) => not(exp)
case _ => exp
}
// Check if a number is a power of two
def isPowerOfTwo(x: Int): Boolean = (x & (x - 1)) == 0
}