public final class AddressAllocationEngine
extends java.lang.Object
AddressAllocationEngine
allocates a part (tag, index, etc.) of an address of a given
type (the rest of the address is assumed to be known).
Address is represented as a set of disjoint fields (elements). For each element, a finite domain is provided.
An address part is a subset of the address elements. Given the values of the rest elements, allocation is a construction of a unique combination of values for the part elements.
To avoid possible conflicts, the allocator works as follows. The elements are ordered.
Provided that elements E[1], ..., E[k]
are defined, it chooses a new value for the
the element E[k+1]
.
Constructor and Description |
---|
AddressAllocationEngine(MmuAddressInstance addressType,
java.util.Collection<MmuExpression> expressions,
long mask,
java.util.Collection<? extends Range<java.lang.Long>> regions)
Constructs an address allocator.
|
Modifier and Type | Method and Description |
---|---|
long |
allocate(long partialAddress,
Range<java.lang.Long> region,
boolean peek,
java.util.Set<java.lang.Long> exclude)
Allocates an address for the given partial address and the region.
|
long |
allocate(MmuExpression expression,
long partialAddress,
Range<java.lang.Long> region,
boolean peek,
java.util.Set<java.lang.Long> exclude)
Allocates an address field for the given partial address and the region.
|
java.util.Collection<java.lang.Long> |
getAllAddresses(Range<java.lang.Long> region) |
void |
reset() |
public AddressAllocationEngine(MmuAddressInstance addressType, java.util.Collection<MmuExpression> expressions, long mask, java.util.Collection<? extends Range<java.lang.Long>> regions)
addressType
- the address type.expressions
- the set of all expressions over addresses used in memory buffers.mask
- the mask to reset insignificant address bits (e.g., offset).regions
- the memory regions or null
.public long allocate(long partialAddress, Range<java.lang.Long> region, boolean peek, java.util.Set<java.lang.Long> exclude)
partialAddress
- the partial address.region
- the memory region.peek
- if peek == true
, peek address without allocation.exclude
- the set of addresses whose fields to be excluded.public long allocate(MmuExpression expression, long partialAddress, Range<java.lang.Long> region, boolean peek, java.util.Set<java.lang.Long> exclude)
expression
- the expression defining the field to be allocated.partialAddress
- the partial address.region
- the memory region.peek
- if peek == true
, peek address without allocation.exclude
- the set of addresses whose fields to be excluded.public void reset()
public java.util.Collection<java.lang.Long> getAllAddresses(Range<java.lang.Long> region)