11#include "sparta/memory/AddressTypes.hpp"
13#include "sparta/memory/DMIBlockingMemoryIF.hpp"
14#include "sparta/functional/ArchData.hpp"
15#include "sparta/utils/Utils.hpp"
80 uint16_t fill_val_size=1) :
81 ArchData(owner_node, block_size, fill, fill_val_size)
85 throw SpartaException(
"Cannot construct a Memoryobject with a block size of 0. Must be a power of 2 and greater than 0");
89 throw SpartaException(
"Cannot construct a Memoryobject with a total size of 0. Must be a multiple of block_size and greater than 0");
92 if(total_size % block_size != 0){
93 throw SpartaException(
"Cannot construct a MemoryObject with total_size = ")
94 << total_size <<
" which is not an even muliple of block_size (" << block_size <<
")";
109 virtual std::string
stringize(
bool pretty=
false)
const {
111 std::stringstream ss;
112 ss <<
"<MemoryObject size:0x" << std::hex <<
getSize() <<
" bytes, "
134 uint8_t *buf)
const {
159 const uint8_t *buf) {
178 uint8_t *buf)
const {
190 uint8_t *buf)
const {
209 addr_t getBlockSize()
const {
261 const std::string& name,
262 const std::string& group,
264 const std::string& desc,
285 const std::string& name,
286 const std::string& desc,
330 if(
auto it = dmi_ifs_.find(aligned_addr); it != dmi_ifs_.end()) {
331 return it->second.get();
334 auto & line = binding_.
getLine(aligned_addr);
335 dmi_ifs_.insert({aligned_addr,
336 std::unique_ptr<DMIBlockingMemoryIF>
339 line.getLayoutSize()))});
340 return dmi_ifs_[aligned_addr].get();
350 for (
auto & dmi_if : dmi_ifs_) {
351 dmi_if.second->clearValid();
359 uint8_t *buf)
const override {
360 binding_.
read(addr,size,buf);
367 const uint8_t *buf)
override {
368 binding_.
write(addr,size,buf);
377 virtual bool tryRead_(
addr_t addr,
380 const void *in_supplement,
381 void *out_supplement)
override {
382 (void) in_supplement;
383 (void) out_supplement;
384 binding_.
read(addr, size, buf);
391 virtual bool tryWrite_(
addr_t addr,
394 const void *in_supplement,
395 void *out_supplement)
override {
396 (void) in_supplement;
397 (void) out_supplement;
398 binding_.
write(addr, size, buf);
402 std::map<addr_t, std::unique_ptr<DMIBlockingMemoryIF>> dmi_ifs_;
File that contains BlockingMemoryIFNode.
File that contains some exception types related to memory interfaces.
std::ostream & operator<<(std::ostream &out, const sparta::memory::MemoryObject &mo)
MemoryObject stream operator.
Exception class for all of Sparta.
Line object which composes part of an entire ArchData.
void write(offset_type offset, const T &t, uint32_t idx=0)
Write to this line, reordering bytes based on byte order if required.
T read(offset_type offset, uint32_t idx=0) const
Read from this line, reordering bytes based on byte order if required.
offset_type getOffset() const
Offset into the owning ArchData.
Contains a set of contiguous line of architectural data which can be referred to by any architected o...
uint64_t getInitial() const
Gets the value used to initialize unwritten memory.
line_idx_type getNumAllocatedLines() const
Gets the number of lines with allocated data;.
uint32_t getInitialValSize() const
Gets the size of the initial value.
line_idx_type getLineIndex(offset_type offset) const
Gets Index of a line containing the specified offset.
void layoutRange(offset_type size)
Lays out the archdata to contain a range of addresses without specifying any segments.
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.
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 o...
const Line * tryGetLine(offset_type offset) const
Gets the line associated with this offset only if it already exists.
offset_type getLineSize() const
Gets the size of a line within this ArchData instance.
offset_type getSize() const
Gets the current size of the layout for this ArchData.
Line & getLine(offset_type offset)
Gets the line associated with this offset, allocating a new line if necessary.
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Node in a composite tree representing a sparta Tree item.
static const group_idx_type GROUP_IDX_NONE
GroupIndex indicating that a node has no group index because it belongs to no group.
static constexpr char GROUP_NAME_NONE[]
Group name indicating that a node belongs to no group.
uint32_t group_idx_type
Index within a group.
Pure-virtual memory interface that builds on the BlockingMemoryIF, acting as a TreeNode in the SPARTA...
BlockingMemoryIFNode implementation with binding to a MemoryObject instantiated separately and specif...
MemoryObject * getMemObj()
BlockingMemoryObjectIFNode(sparta::TreeNode *parent, const std::string &name, const std::string &group, sparta::TreeNode::group_idx_type group_idx, const std::string &desc, TranslationIF *transif, MemoryObject &binding)
Constructs a BlockingMemoryIFNode bound to a MemoryObject.
void invalidateAllDMI() override
Invalidate all DMI pointers.
virtual bool tryPoke_(addr_t addr, addr_t size, const uint8_t *buf) override
Override of DebugMemoryIF::tryPoke_.
DMIBlockingMemoryIF * getDMI(addr_t addr, addr_t size) override
Return a DMIBlockingMemoryIF for the given address and size.
BlockingMemoryObjectIFNode(sparta::TreeNode *parent, const std::string &name, const std::string &desc, TranslationIF *transif, MemoryObject &binding)
Constructor for single window without TreeNode group information.
virtual bool tryPeek_(addr_t addr, addr_t size, uint8_t *buf) const override
Override of DebugMemoryIF::tryPeek_.
Class that provides a BlockingMemoryIF over a raw pointer.
Memory interface which represents a simple, immediately accessible (blocking) address-space with supp...
bool doesAccessSpan(addr_t addr, addr_t size) const noexcept
Determines if the given address spans block boundaries defined for this interface....
addr_t block_mask_
Mask applied to an address to get only bits representing the block ID.
addr_t getBlockSize() const
Returns the block size of memory represented by this interface. Read and write accesses must not span...
Memory object with sparse storage for large memory representations. Has direct read/write interface w...
void write(addr_t addr, addr_t size, const uint8_t *buf)
Writes memory.
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.
void _lookupAndValidate(addr_t addr, addr_t size, uint8_t *buf) const
virtual std::string stringize(bool pretty=false) const
Render description of this MemoryObject as a string.
uint16_t getFillPatternSize() const
Get the number of bytes in the fill pattern.
void _canAccess(addr_t addr, addr_t size, uint8_t *buf) const
uint64_t getFill() const
Get the fill pattern. Fewer than 8 bytes may be used. See getFillPatternSize.
addr_t getNumBlocks() const
Returns the number of blocks in this memory object.
void read(addr_t addr, addr_t size, uint8_t *buf) const
Reads memory.
Blocking translation interface with 1:1 translation unless subclassed.
uint64_t addr_t
Type for generic address representation in generic interfaces, errors and printouts within SPARTA.
Macros for handling exponential backoff.
Defines an access window within this interface. Accesses through a memory interface are constrained t...