11#include "sparta/memory/AddressTypes.hpp"
13#include "sparta/memory/DMIBlockingMemoryIF.hpp"
14#include "sparta/functional/ArchData.hpp"
15#include "sparta/utils/Utils.hpp"
72 uint16_t fill_val_size=1) :
73 ArchData(owner_node, block_size, fill, fill_val_size)
77 throw SpartaException(
"Cannot construct a Memoryobject with a block size of 0. Must be a power of 2 and greater than 0");
81 throw SpartaException(
"Cannot construct a Memoryobject with a total size of 0. Must be a multiple of block_size and greater than 0");
84 if(total_size % block_size != 0){
85 throw SpartaException(
"Cannot construct a MemoryObject with total_size = ")
86 << total_size <<
" which is not an even muliple of block_size (" << block_size <<
")";
101 virtual std::string
stringize(
bool pretty=
false)
const {
103 std::stringstream ss;
104 ss <<
"<MemoryObject size:0x" << std::hex <<
getSize() <<
" bytes, "
126 uint8_t *buf)
const {
151 const uint8_t *buf) {
170 uint8_t *buf)
const {
182 uint8_t *buf)
const {
201 addr_t getBlockSize()
const {
253 const std::string& name,
254 const std::string& group,
256 const std::string& desc,
277 const std::string& name,
278 const std::string& desc,
322 if(
auto it = dmi_ifs_.find(aligned_addr); it != dmi_ifs_.end()) {
323 return it->second.get();
326 auto & line = binding_.
getLine(aligned_addr);
327 dmi_ifs_.insert({aligned_addr,
328 std::unique_ptr<DMIBlockingMemoryIF>
331 line.getLayoutSize()))});
332 return dmi_ifs_[aligned_addr].get();
342 for (
auto & dmi_if : dmi_ifs_) {
343 dmi_if.second->clearValid();
351 uint8_t *buf)
const override {
352 binding_.
read(addr,size,buf);
359 const uint8_t *buf)
override {
360 binding_.
write(addr,size,buf);
369 virtual bool tryRead_(
addr_t addr,
372 const void *in_supplement,
373 void *out_supplement)
override {
374 (void) in_supplement;
375 (void) out_supplement;
376 binding_.
read(addr, size, buf);
383 virtual bool tryWrite_(
addr_t addr,
386 const void *in_supplement,
387 void *out_supplement)
override {
388 (void) in_supplement;
389 (void) out_supplement;
390 binding_.
write(addr, size, buf);
394 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...