diplomacy: add legalize method to AddressSet

This commit is contained in:
Henry Cook committed 2017-05-10 12:54:24 -07:00
1 parent 3af40bff8b
commit 5f3a4ada1b
2 files changed
+5 -2

No files matched your search

@@ -126,6 +126,9 @@ case class AddressSet(base: BigInt, mask: BigInt) extends Ordered[AddressSet]
def contains(x: BigInt) = ((x ^ base) & ~mask) == 0
def contains(x: UInt) = ((x ^ UInt(base)).zext() & SInt(~mask)) === SInt(0)
// turn x into an address contained in this set
def legalize(x: UInt): UInt = base.U | (mask.U & x)
// overlap iff bitwise: both care (~mask0 & ~mask1) => both equal (base0=base1)
def overlaps(x: AddressSet) = (~(mask | x.mask) & (base ^ x.base)) == 0
// contains iff bitwise: x.mask => mask && contains(x.base)