The Sparta Modeling Framework
|
Memory object with sparse storage for large memory representations. Has direct read/write interface within blocks. Checkpointable. More...
#include <MemoryObject.hpp>
Public Member Functions | |
Construction | |
MemoryObject (TreeNode *owner_node, addr_t block_size, addr_t total_size, uint64_t fill=0xcc, uint16_t fill_val_size=1) | |
Construct a Memory object with sparse storage. | |
virtual std::string | stringize (bool pretty=false) const |
Render description of this MemoryObject as a string. | |
Memory Access | |
void | read (addr_t addr, addr_t size, uint8_t *buf) const |
Reads memory. | |
void | write (addr_t addr, addr_t size, const uint8_t *buf) |
Writes memory. | |
Analysis/Testing Methods | |
void | _lookupAndValidate (addr_t addr, addr_t size, uint8_t *buf) const |
void | _canAccess (addr_t addr, addr_t size, uint8_t *buf) const |
General Attributes | |
addr_t | getNumBlocks () const |
Returns the number of blocks in this memory object. | |
addr_t | getBlockSize () const |
uint64_t | getFill () const |
Get the fill pattern. Fewer than 8 bytes may be used. See getFillPatternSize. | |
uint16_t | getFillPatternSize () const |
Get the number of bytes in the fill pattern. | |
Public Member Functions inherited from sparta::ArchData | |
ArchData (TreeNode *owner_node=nullptr, offset_type line_size=DEFAULT_LINE_SIZE, uint64_t initial=DEFAULT_INITIAL_FILL, uint16_t initial_val_size=DEFAULT_INITIAL_FILL_SIZE, bool can_free_lines=true) | |
Constructor. | |
void | registerSegment (ArchDataSegment *seg) |
All constructed segments must register themselves through this method to be laid out within the ArchData object. | |
const SegmentList | getSegments () const |
Gets the list of segments within this ArchData. | |
uint32_t | getNumSegments () const |
Gets number of segments in this ArchData. | |
void | layout () |
Organizes the Segments into overlapping regions as needed, eventually calling ArchDataSegment::place on each segment with its location inside this ArchData. | |
void | layoutRange (offset_type size) |
Lays out the archdata to contain a range of addresses without specifying any segments. | |
Line & | getLine (offset_type offset) |
Gets the line associated with this offset, allocating a new line if necessary. | |
const Line * | tryGetLine (offset_type offset) const |
Gets the line associated with this offset only if it already exists. | |
const LineMap & | getLineMap () const |
Only const access is allowed to internal map. | |
void | clean () |
Deletes (if possible) data held within the ArchData, restoring it to a 'clean-state'. This is not a 're-initialize' state, but rather all data is cleared to the fill-value specified at ArchData construction. Depending in whether canFreeLines returns true, Lines may actually be deleted and reclaimed. | |
void | reset () |
Cleans the ArchData (see clean) then applies all initial values through ArchDataSegment::writeInitial(). | |
offset_type | getLineSize () const |
Gets the size of a line within this ArchData instance. | |
line_idx_type | getNumAllocatedLines () const |
Gets the number of lines with allocated data;. | |
line_idx_type | getLineIndex (offset_type offset) const |
Gets Index of a line containing the specified offset. | |
offset_type | getLineOffset (line_idx_type idx) const |
Gets offset associated with a particular line that exists in this ArchData. | |
bool | canFreeLines () const |
Indicates whether this ArchData can free its lines after allocating them. Otherwise, any allocated line must exist for the lifetime of this ArchData. | |
void | checkCanAccess (offset_type offset, offset_type bytes) const |
Determines if an access of size 'bytes' can be performed at the given offset based only on the size of the ArchData and Line span. Validity checking matches that of ArchData::Line::read. | |
bool | containsAddress (offset_type offset) const noexcept |
Determines if this ArchData contains a byte for the specified address. | |
void | checkDataSize (offset_type size) const |
Checks to see that the size of the data is a valid access size. | |
void | checkSegment (offset_type offset, offset_type size) const |
Checks that a segment is valid within this archdata by its given offset and size. | |
void | checkInSingleLine (offset_type offset, offset_type size) const |
Determines whether the access defined by offset and size spans multiple ArchData Lines. | |
virtual void | updateFrom (const ArchData &other) |
template<typename StorageT > | |
void | save (StorageT &out) |
Writes checkpointing data from this ArchData to a stream. | |
template<typename StorageT > | |
void | saveAll (StorageT &out) |
Writes snapshot checkpointing data (all lines) from this ArchData to a stream regardless of dirtiness. | |
template<typename StorageT > | |
void | restore (StorageT &in) |
Restores a delta checkpoint (not a full snapshot). This contains only additive changes. | |
template<typename StorageT > | |
void | restoreAll (StorageT &in) |
Restores a full checkpoint snapshot (not a delta). This removes all lines NOT found in the snapshot data. | |
const TreeNode * | getOwnerNode () const |
Returns the owner TreeNode. | |
void | setOwnerNode (TreeNode *node) |
Set the owner tree node. | |
bool | isLaidOut () const |
Has this ArchData been laid out yet. | |
offset_type | getSize () const |
Gets the current size of the layout for this ArchData. | |
uint64_t | getInitial () const |
Gets the value used to initialize unwritten memory. | |
uint32_t | getInitialValSize () const |
Gets the size of the initial value. | |
uint32_t | getTotalWaste () const |
Number of bytes wasted total during layout for any reason. | |
uint32_t | getPaddingWaste () const |
Number of bytes wasted during layout because of optimal word-alignment. | |
uint32_t | getLineWaste () const |
Number of bytes wasted during layout because of line-ending alignment. | |
void | dumpLayout (std::ostream &o) const |
Prints content of each ArchData Line in order. | |
std::vector< std::string > | getLineStates () const |
Gets state information for each line in this ArchData. | |
uint64_t | getNumTiers () const |
Additional Inherited Members | |
Public Types inherited from sparta::ArchData | |
typedef ArchDataSegment::offset_type | offset_type |
typedef offset_type | line_idx_type |
Represents offsets into this ArchData. | |
typedef std::vector< ArchDataSegment * > | SegmentList |
ArchData line index. | |
typedef std::list< Line * > | LineList |
List of ArchDataSegment. | |
typedef TieredMap< line_idx_type, Line * > | LineMap |
List of Line pointers. | |
typedef std::unordered_map< ArchDataSegment::ident_type, ArchDataSegment * > | LayoutHelperMap |
Helper map for quick lookup from ArchDataSegment::ident_type to an ArchDataSegment*. | |
typedef std::vector< ArchDataSegment * > | LayoutHelperVector |
Vector of ArchDataSegment pointers. | |
Static Public Member Functions inherited from sparta::ArchData | |
static void | fillValue (uint8_t *buf, uint32_t size, uint64_t fill, uint16_t fill_val_size, uint16_t fill_pattern_offset=0) |
Fill a buffer with a fill pattern. | |
static const std::vector< const ArchData * > | getAllArchDatas () |
Static method to return a const vector of all ArchVectors that currently exist. | |
static bool | compareSegmentOffsets (const ArchDataSegment *s1, const ArchDataSegment *s2) |
Comparison functions for sorting by segment. | |
Static Public Attributes inherited from sparta::ArchData | |
static const offset_type | DEFAULT_LINE_SIZE = 512 |
static const offset_type | MAX_LINE_SIZE = 0x80000000 |
ArchData construction line size maximum in bytes. | |
static const uint64_t | DEFAULT_INITIAL_FILL = 0xcc |
Default initial fill value for an ArchData when allocated. | |
static const uint16_t | DEFAULT_INITIAL_FILL_SIZE = 1 |
Number of of bytes from DEFAULT_INITIAL_FILL to use as a default. | |
static const line_idx_type | INVALID_LINE_IDX = std::numeric_limits<line_idx_type>::max() |
Invalid line index. | |
Memory object with sparse storage for large memory representations. Has direct read/write interface within blocks. Checkpointable.
Addresses begin at 0. Has basic bounds checking and a trival, nonvirtual interface.
This interface does not support non-blocking accesses or access attributes.
A binding class BlockingMemoryObjectIF is provided for placing a BlockingMemoryIF on top of this MemoryObject.
For checkpointing support, the owner_node construct argument must be used
Definition at line 38 of file MemoryObject.hpp.
|
inline |
Construct a Memory object with sparse storage.
owner_node | Node owning this ArchData. Can be nullptr if checkpointing support is not needed, Should typically have a node. This is the only means by which memory objects are associated with a TreeNode in order to be found by a sparta::serialization::checkpoint::Checkpointer support. Multiple memory objects can be associated with the same node. |
block_size | Size of an individual block in this object. Must be a power of 2. |
total_size | Size of the memory object. Must be a multiple of block_size. Address 0 refers to first byte. Any address offsetting must be performed externally this functionality is omitted for performance) |
fill | Value with which to populate newly-accessed memory. Bytes beyond fill_val_size must be 0 |
fill_val_size | Number of bytes from Value to use for repeating fill. This must be a power of 2 between 1 and 8 inclusive. |
Definition at line 68 of file MemoryObject.hpp.
|
inlinevirtual |
Definition at line 93 of file MemoryObject.hpp.
|
inline |
Determines if memory with the given address and size can be accessed. Performs the same level of validation on addr and size that read and write will.150
Definition at line 180 of file MemoryObject.hpp.
|
inline |
Gets the line associated with this access. Performs the same level of validatio non addr and size that read and write will.
Definition at line 168 of file MemoryObject.hpp.
|
inline |
Definition at line 201 of file MemoryObject.hpp.
|
inline |
Get the fill pattern. Fewer than 8 bytes may be used. See getFillPatternSize.
Definition at line 209 of file MemoryObject.hpp.
|
inline |
Get the number of bytes in the fill pattern.
Definition at line 216 of file MemoryObject.hpp.
|
inline |
Returns the number of blocks in this memory object.
Definition at line 197 of file MemoryObject.hpp.
Reads memory.
addr | Address to read from where 0 is start of this memory object. |
SpartaException | if access of addr and size is not possible in this storage object. Caller should validate |
Definition at line 124 of file MemoryObject.hpp.
|
inlinevirtual |
Render description of this MemoryObject as a string.
Definition at line 101 of file MemoryObject.hpp.
Writes memory.
addr | Address to write to where 0 is start of this memory object. |
SpartaException | if access of addr and size is not possible in this storage object. Caller should validate |
Definition at line 149 of file MemoryObject.hpp.