The Sparta Modeling Framework
|
Line object which composes part of an entire ArchData. More...
#include <ArchData.hpp>
Public Member Functions | |
Line (line_idx_type idx, offset_type offset, offset_type size, uint64_t initial, uint32_t initial_val_size, uint8_t *pool_ptr=0) | |
Line constructor. | |
Line (const Line &)=delete | |
Disallow copies, moves, and assignments. | |
Line (Line &&)=delete | |
Line & | operator= (const Line &)=delete |
void | updateFrom (const Line &other) |
void | flagDirty () |
Allows caller to explicitly flag this line as dirty. | |
void | fillWithInitial (uint64_t initial, uint32_t initial_val_size) |
Fills the line's data with the initial value. | |
template<typename StorageT > | |
void | restore (StorageT &in) |
Restore data from input buffer. | |
template<typename StorageT > | |
void | save (StorageT &out) |
Store data to output buffer. | |
line_idx_type | getIdx () const |
Index of this line (typically offset/line_size) | |
offset_type | getOffset () const |
Offset into the owning ArchData. | |
offset_type | getLayoutSize () const |
Size of this line's data including padding. Accessing bytes from this line with an offset greater than or equal to this value is invalid. | |
bool | isDirty () const |
Has this line been modified since the last save or restore. Immediately after construction, this will be true. | |
const uint8_t * | getDataPointer (offset_type offset) const |
Gets a pointer to data within this line for direct read access. | |
uint8_t * | getRawDataPtr (const offset_type offset) |
return the raw data pointer for this line for direct read and write. No error checking is performed. Should be used with care. | |
Reading and Writing | |
template<typename T , ByteOrder BO> | |
T | read (offset_type offset, uint32_t idx=0) const |
Read from this line, reordering bytes based on byte order if required. | |
void | read (offset_type offset, offset_type size, uint8_t *data) const |
Read a number of contiguous bytes from this line. | |
template<typename T , ByteOrder BO> | |
void | write (offset_type offset, const T &t, uint32_t idx=0) |
Write to this line, reordering bytes based on byte order if required. | |
void | write (offset_type offset, offset_type size, const uint8_t *data) const |
Write a number of contiguous bytes to this line. | |
Static Public Attributes | |
static constexpr char | QUICK_CHECKPOINT_PREFIX [] = "<L>" |
Prefix for Line checkpoint entries. | |
static const uint32_t | QUICK_CHECKPOINT_OFFSET_SIZE = 7 |
Size of offset and size entries in quick checkpoint. | |
Line object which composes part of an entire ArchData.
Data of line is always allocated when line is constructed unless a pool_ptr is given at construction.
Allocated line is dirty by default. An ArchData should not allocate a line being read if the initial value is known.
Definition at line 157 of file ArchData.hpp.
|
inline |
Line constructor.
idx | Index of this line |
offset | Effective address offset of this line from the starting memory range of the owning ArchData. |
size | bytes contained in this line. Assumes this is a power of 2 and greather than 0. |
initial | Inital value to fill all data in this line with. The data is set regardless of whether memory comes from a pool or is allocated here. |
initial_val_size | Size of initial value in bytes |
pool_ptr | optional pointer into pool data which contains <size> number of bytes reserved exclusively for this Line. ArchData can allocate one pool for each line and assign each line a position within that pool to improve data locality. |
A newly-constructed line is always flagged as dirty and all bytes set to <initial>.
Definition at line 183 of file ArchData.hpp.
|
inline |
Fills the line's data with the initial value.
initial | Value to write to this Line's memory |
initial_val_size | Bytes to use of initial value |
Definition at line 235 of file ArchData.hpp.
|
inline |
Allows caller to explicitly flag this line as dirty.
The only way to clear a dirty flag is to save this ArchData.
Definition at line 226 of file ArchData.hpp.
|
inline |
Gets a pointer to data within this line for direct read access.
offset | Offset into this line in bytes |
Definition at line 395 of file ArchData.hpp.
|
inline |
Index of this line (typically offset/line_size)
Definition at line 272 of file ArchData.hpp.
|
inline |
Size of this line's data including padding. Accessing bytes from this line with an offset greater than or equal to this value is invalid.
Definition at line 288 of file ArchData.hpp.
|
inline |
Offset into the owning ArchData.
Definition at line 279 of file ArchData.hpp.
|
inline |
return the raw data pointer for this line for direct read and write. No error checking is performed. Should be used with care.
Definition at line 403 of file ArchData.hpp.
|
inline |
Has this line been modified since the last save or restore. Immediately after construction, this will be true.
Definition at line 296 of file ArchData.hpp.
|
inline |
Read a number of contiguous bytes from this line.
offset | Offset in bytes into this line |
size | Size of the read in bytes |
data | Buffer to populate with size bytes copied from this ArchData |
Definition at line 335 of file ArchData.hpp.
|
inline |
Read from this line, reordering bytes based on byte order if required.
T | type of variable to read (e.g. uint32_t). This dictates access size |
BO | Byte-order of access when read from memory |
offset | Offset in bytes into this line |
idx | Index into this line as a multiple of sizeof(T) bytes |
Definition at line 316 of file ArchData.hpp.
|
inline |
Restore data from input buffer.
in | Input buffer. Must contain bytes equal to the size of the Line. All bytes will be read |
SpartaException | if in could not be read as expected. |
Definition at line 249 of file ArchData.hpp.
|
inline |
Store data to output buffer.
out | Output buffer. Must allow writing a number of bytes equal to the size of this Line. All bytes will be written |
SpartaException | if out could not be written as expected. |
Definition at line 264 of file ArchData.hpp.
|
inline |
Definition at line 214 of file ArchData.hpp.
|
inline |
Write to this line, reordering bytes based on byte order if required.
T | type of variable to write (e.g. uint32_t). This dictates access size |
BO | Byte-order of access when written to memory |
offset | Offset in bytes into this line |
idx | Index into this line as a multiple of sizeof(T) bytes |
Definition at line 354 of file ArchData.hpp.
|
inline |
Write a number of contiguous bytes to this line.
offset | Offset in bytes into this line |
size | Size of the write in bytes |
data | Buffer containing size bytes to copy to this object |
Definition at line 375 of file ArchData.hpp.
|
static |
Size of offset and size entries in quick checkpoint.
Definition at line 162 of file ArchData.hpp.
|
staticconstexpr |
Prefix for Line checkpoint entries.
Definition at line 161 of file ArchData.hpp.