diplomacy: add legalize method to AddressSet
This commit is contained in:
parent
3af40bff8b
commit
5f3a4ada1b
@ -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)
|
||||
|
@ -136,8 +136,8 @@ class TLFuzzer(
|
||||
val log_op = noiseMaker(2, inc, 0)
|
||||
val amo_size = UInt(2) + noiseMaker(1, inc, 0) // word or dword
|
||||
val size = noiseMaker(sizeBits, inc, 0)
|
||||
val addrMask = overrideAddress.map(_.max.U).getOrElse(~UInt(0, addressBits))
|
||||
val addr = noiseMaker(addressBits, inc, 2) & ~UIntToOH1(size, addressBits) & addrMask
|
||||
val rawAddr = noiseMaker(addressBits, inc, 2)
|
||||
val addr = overrideAddress.map(_.legalize(rawAddr)).getOrElse(rawAddr) & ~UIntToOH1(size, addressBits)
|
||||
val mask = noiseMaker(beatBytes, inc_beat, 2) & edge.mask(addr, size)
|
||||
val data = noiseMaker(dataBits, inc_beat, 2)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user