public final class MemoryAllocator
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
MemoryAllocator(MemoryDevice memory,
int addressableUnitBitSize,
java.math.BigInteger baseAddress)
Constructs a memory allocator object with the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
static java.math.BigInteger |
alignAddress(java.math.BigInteger address,
int alignment)
Aligns the specified address by the specified length and returns the resulting aligned address.
|
ru.ispras.fortress.util.Pair<java.math.BigInteger,java.math.BigInteger> |
allocate(java.math.BigInteger currentAddress,
ru.ispras.fortress.data.types.bitvector.BitVector... data)
Allocates memory in the memory storage to hold data elements provided as arguments
and return the address (in addressable units) of the first element.
|
ru.ispras.fortress.util.Pair<java.math.BigInteger,java.math.BigInteger> |
allocate(java.math.BigInteger currentAddress,
ru.ispras.fortress.data.types.bitvector.BitVector data)
Allocates memory in the memory storage to hold the specified data and returns its address (in
addressable units).
|
ru.ispras.fortress.util.Pair<java.math.BigInteger,java.math.BigInteger> |
allocate(java.math.BigInteger currentAddress,
ru.ispras.fortress.data.types.bitvector.BitVector data,
boolean align)
Allocates memory in the memory storage to hold the specified data and returns its address (in
addressable units).
|
ru.ispras.fortress.util.Pair<java.math.BigInteger,java.math.BigInteger> |
allocate(java.math.BigInteger currentAddress,
ru.ispras.fortress.data.types.bitvector.BitVector data,
int count)
Allocates memory in the memory storage to hold the specified number of the specified data and
returns the address (in addressable units) of the first element.
|
ru.ispras.fortress.util.Pair<java.math.BigInteger,java.math.BigInteger> |
allocate(java.math.BigInteger currentAddress,
java.util.List<ru.ispras.fortress.data.types.bitvector.BitVector> data)
Allocates memory in the memory storage to hold data elements in the specified list
and return the address (in addressable units) of the first element.
|
void |
allocateAt(java.math.BigInteger address,
ru.ispras.fortress.data.types.bitvector.BitVector data) |
ru.ispras.fortress.util.Pair<java.math.BigInteger,java.math.BigInteger> |
allocateString(java.math.BigInteger currentAddress,
java.lang.String string,
boolean zeroTerm)
Allocates memory in the memory storage to store the specified string converted to the ASCII
encoding and returns the address of string.
|
int |
bitsToAddressableUnits(int bitSize)
Returns the minimal number of addressable units required to store data of the specified size
(in bits).
|
int |
getAddressableUnitBitSize()
Returns the size of an addressable unit.
|
int |
getAddressableUnitsInRegion()
Returns the number of addressable units in a memory region.
|
int |
getAddressBitSize() |
java.math.BigInteger |
getBaseAddress() |
int |
getRegionBitSize()
Returns the size of memory regions stored in the memory storage.
|
void |
reset() |
void |
setBaseAddress(java.math.BigInteger value) |
java.lang.String |
toString() |
protected MemoryAllocator(MemoryDevice memory, int addressableUnitBitSize, java.math.BigInteger baseAddress)
memory
- Memory storage to store the data.addressableUnitBitSize
- Size of an addressable unit in bits.baseAddress
- Address where allocation starts.java.lang.IllegalArgumentException
- if the memory
parameter is null
;
if the specified size of an addressable unit is negative or is not a divisor
of memory region size.public static java.math.BigInteger alignAddress(java.math.BigInteger address, int alignment)
address
- Address to be aligned.alignment
- Alignment length.java.lang.IllegalArgumentException
- if any of the parameters is negative.public java.math.BigInteger getBaseAddress()
public void setBaseAddress(java.math.BigInteger value)
public void reset()
public int getAddressableUnitBitSize()
public int getRegionBitSize()
public int getAddressableUnitsInRegion()
public int getAddressBitSize()
public ru.ispras.fortress.util.Pair<java.math.BigInteger,java.math.BigInteger> allocate(java.math.BigInteger currentAddress, ru.ispras.fortress.data.types.bitvector.BitVector data)
currentAddress
- Current address.data
- Data to be stored in the memory storage.java.lang.IllegalArgumentException
- if the parameter is null
.public ru.ispras.fortress.util.Pair<java.math.BigInteger,java.math.BigInteger> allocate(java.math.BigInteger currentAddress, ru.ispras.fortress.data.types.bitvector.BitVector data, boolean align)
currentAddress
- Current address.data
- Data to be stored in the memory storage.align
- Alignment flag.java.lang.IllegalArgumentException
- if the parameter is null
.public ru.ispras.fortress.util.Pair<java.math.BigInteger,java.math.BigInteger> allocate(java.math.BigInteger currentAddress, ru.ispras.fortress.data.types.bitvector.BitVector data, int count)
currentAddress
- Current address.data
- Data to be placed in the memory storage.count
- Number of copies to be placed in the memory storage.java.lang.IllegalArgumentException
- if the parameter is null
.public ru.ispras.fortress.util.Pair<java.math.BigInteger,java.math.BigInteger> allocate(java.math.BigInteger currentAddress, ru.ispras.fortress.data.types.bitvector.BitVector... data)
currentAddress
- Current address.data
- Collection of data elements to be stored in the memory storage.java.lang.IllegalArgumentException
- if the list is empty or it list elements have
different sizes.public ru.ispras.fortress.util.Pair<java.math.BigInteger,java.math.BigInteger> allocate(java.math.BigInteger currentAddress, java.util.List<ru.ispras.fortress.data.types.bitvector.BitVector> data)
currentAddress
- Current address.data
- Collection of data elements to be stored in the memory storage.java.lang.IllegalArgumentException
- if the parameter is null
;
if the list is empty or it list elements have different sizes.public void allocateAt(java.math.BigInteger address, ru.ispras.fortress.data.types.bitvector.BitVector data)
public ru.ispras.fortress.util.Pair<java.math.BigInteger,java.math.BigInteger> allocateString(java.math.BigInteger currentAddress, java.lang.String string, boolean zeroTerm)
currentAddress
- Current address.string
- String to be placed in the memory.zeroTerm
- Specifies whether the string must be terminated with zero.java.lang.IllegalArgumentException
- if the string
parameter equals null
;
if failed to convert the string to the "US-ASCII" encoding.public int bitsToAddressableUnits(int bitSize)
bitSize
- Size in bits.java.lang.IllegalArgumentException
- if the bitSize
argument is 0 or negative.public java.lang.String toString()
toString
in class java.lang.Object