OpenASIP
2.0
|
#include <PagedArray.hh>
Public Types | |
typedef ValueType * | ValueTable |
Type for a set of values in a basic array type. More... | |
typedef std::vector< ValueType > | ValueVector |
Type for a set of values in a std::vector container. More... | |
Public Member Functions | |
PagedArray (std::size_t size) | |
virtual | ~PagedArray () |
void | write (IndexType index, const ValueTable data, std::size_t size) |
void | writeData (IndexType index, const ValueType &data) |
ValueType | readData (IndexType index) |
void | read (IndexType index, ValueVector &data, size_t size) |
void | read (IndexType index, ValueVector &data) |
void | read (IndexType index, ValueTable data, size_t size) |
size_t | allocatedMemory () const |
void | clear () |
Private Member Functions | |
void | deletePages () |
PagedArray (const PagedArray &) | |
Copying not allowed. More... | |
PagedArray & | operator= (const PagedArray &) |
Assignment not allowed. More... | |
Private Attributes | |
ValueType ** | pageTable_ |
Storage for the data pages. Created pages are stored in table from which they are found with address / size_of_page. More... | |
std::size_t | pageTableSize_ |
Size of the page table. More... | |
Models the data contained in array.
The array space is divided into pages which are allocated on-demand, that is, the first time an index in that page is accessed for a write operation. Pages are stored in a table from which they are retrieved using (address / page_size) as index. The offset within the selected page is given by (address % chunk_size). This should result in O(1) access.
This allows modeling large arrays without reserving the memory for the array if it's not accessed. The idea behind this implementation is borrowed from common (paged) virtual memory implementations of operating systems.
Please note that this container does not perform any checking for the validity of the indices due to efficiency reasons.
Definition at line 69 of file PagedArray.hh.
typedef ValueType* PagedArray< ValueType, PageSize, DefaultValue >::ValueTable |
Type for a set of values in a basic array type.
Definition at line 73 of file PagedArray.hh.
typedef std::vector<ValueType> PagedArray< ValueType, PageSize, DefaultValue >::ValueVector |
Type for a set of values in a std::vector container.
Definition at line 76 of file PagedArray.hh.
PagedArray< ValueType, PageSize, DefaultValue >::PagedArray | ( | std::size_t | size | ) |
|
virtual |
|
private |
Copying not allowed.
size_t PagedArray< ValueType, PageSize, DefaultValue >::allocatedMemory | ( | ) | const |
void PagedArray< ValueType, PageSize, DefaultValue >::clear | ( | ) |
Referenced by IdealSRAM::fillWithZeros(), and DirectAccessMemory::fillWithZeros().
|
private |
|
private |
Assignment not allowed.
void PagedArray< ValueType, PageSize, DefaultValue >::read | ( | IndexType | index, |
ValueTable | data, | ||
size_t | size | ||
) |
void PagedArray< ValueType, PageSize, DefaultValue >::read | ( | IndexType | index, |
ValueVector & | data | ||
) |
void PagedArray< ValueType, PageSize, DefaultValue >::read | ( | IndexType | index, |
ValueVector & | data, | ||
size_t | size | ||
) |
ValueType PagedArray< ValueType, PageSize, DefaultValue >::readData | ( | IndexType | index | ) |
void PagedArray< ValueType, PageSize, DefaultValue >::write | ( | IndexType | index, |
const ValueTable | data, | ||
std::size_t | size | ||
) |
void PagedArray< ValueType, PageSize, DefaultValue >::writeData | ( | IndexType | index, |
const ValueType & | data | ||
) |
|
private |
Storage for the data pages. Created pages are stored in table from which they are found with address / size_of_page.
Definition at line 101 of file PagedArray.hh.
|
private |
Size of the page table.
Definition at line 103 of file PagedArray.hh.