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 |
---|---|
void |
align(java.math.BigInteger value) |
java.math.BigInteger |
allocate(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.
|
java.math.BigInteger |
allocate(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).
|
java.math.BigInteger |
allocate(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.
|
java.math.BigInteger |
allocate(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.
|
java.math.BigInteger |
allocateAsciiString(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.
|
void |
allocateAt(ru.ispras.fortress.data.types.bitvector.BitVector data,
java.math.BigInteger address) |
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()
Returns the base address.
|
java.math.BigInteger |
getCurrentAddress()
Returns the current address.
|
int |
getRegionBitSize()
Returns the size of memory regions stored in the memory storage.
|
void |
resetCurrentAddress() |
void |
setCurrentAddress(java.math.BigInteger value) |
void |
setOrigin(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 java.math.BigInteger getBaseAddress()
public java.math.BigInteger getCurrentAddress()
public void setCurrentAddress(java.math.BigInteger value)
public void resetCurrentAddress()
public void setOrigin(java.math.BigInteger value)
public void align(java.math.BigInteger value)
public int getAddressableUnitBitSize()
public int getRegionBitSize()
public int getAddressableUnitsInRegion()
public int getAddressBitSize()
public java.math.BigInteger allocate(ru.ispras.fortress.data.types.bitvector.BitVector data)
data
- Data to be stored in the memory storage.java.lang.IllegalArgumentException
- if the parameter is null
.public void allocateAt(ru.ispras.fortress.data.types.bitvector.BitVector data, java.math.BigInteger address)
public java.math.BigInteger allocate(ru.ispras.fortress.data.types.bitvector.BitVector data, int count)
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 java.math.BigInteger allocate(ru.ispras.fortress.data.types.bitvector.BitVector... data)
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 java.math.BigInteger allocate(java.util.List<ru.ispras.fortress.data.types.bitvector.BitVector> data)
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 java.math.BigInteger allocateAsciiString(java.lang.String string, boolean zeroTerm)
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