11#include "sparta/statistics/Counter.hpp"
13#include "sparta/log/NotificationSource.hpp"
15#include "sparta/memory/AddressTypes.hpp"
185 const std::string& name,
186 const std::string& group,
188 const std::string& desc,
192 TreeNode(name, group, group_idx, desc),
196 post_write_noti_(this,
"post_write",
"Notification immediately after the memory interface has been written",
"post_write"),
198 post_read_noti_(this,
"post_read",
"Notification immediately after the memory interface has been read",
"post_read"),
202 throw SpartaException(
"BlockingMemoryIFNode must be constructed with a non-null parent");
225 const std::string& name,
226 const std::string& desc,
325 const void *in_supplement=
nullptr,
326 void *out_supplement=
nullptr)
override {
337 return tryRead_(addr, size, buf, in_supplement, out_supplement);
340 bool result =
tryRead_(addr, size, buf, in_supplement, out_supplement);
344 post_read_noti_data.addr = addr;
345 post_read_noti_data.size = size;
346 post_read_noti_data.data = buf;
347 post_read_noti_data.in_supplement = in_supplement;
375 const void *in_supplement=
nullptr,
376 void *out_supplement=
nullptr) {
377 if(!
tryRead(addr, size, buf, in_supplement, out_supplement)){
408 const void *in_supplement=
nullptr,
409 void *out_supplement=
nullptr)
override {
420 return tryWrite_(addr, size, buf, in_supplement, out_supplement);
428 bool result =
tryWrite_(addr, size, buf, in_supplement, out_supplement);
432 post_write_noti_data.addr = addr;
433 post_write_noti_data.size = size;
435 post_write_noti_data.tried = buf;
436 post_write_noti_data.in_supplement = in_supplement;
471 const void *in_supplement=
nullptr,
472 void *out_supplement=
nullptr) {
473 if(!
tryWrite(addr, size, buf, in_supplement, out_supplement)){
502 virtual std::string
stringize(
bool pretty=
false)
const override {
504 std::stringstream ss;
File that contains BlockingMemoryIF.
File that contains some exception types related to memory interfaces.
Exception class for all of Sparta.
File that defines the StatisticSet class.
Basic Node framework in sparta device tree composite pattern.
@ COUNT_NORMAL
Counter counts the number of times something happens like one would expect. This is a weakly monotoni...
Represents a counter of type counter_type (uint64_t). 2 and greater than 0 with a ceiling specified....
bool observed() const noexcept
Is this NotificationSourceBase being observed at this node or an ancestor of any distance.
A TreeNode that generates a specific type of notification which propagates up a tree of TreeNodes (us...
ReadAccess data_type
Type of notification data generated by this instance.
void postNotification(const NotificationDataT &data) const
Post with reference to data with parent as message origin.
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Set of StatisticDef and CounterBase-derived objects for visiblility through a sparta Tree.
CounterT & createCounter(_Args &&... __args)
Allocates a Counter which is owned by this StatisticSet and deleted at its destruction.
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.
std::string getLocation() const override final
static constexpr char GROUP_NAME_NONE[]
Group name indicating that a node belongs to no group.
void addChild(TreeNode *child, bool inherit_phase=true)
Adds a TreeNode to this node as a child.
uint32_t group_idx_type
Index within a group.
void setExpectedParent_(const TreeNode *parent)
Tracks a node as an expected parent without actually adding this node as a child. This is used almost...
Pure-virtual memory interface that builds on the BlockingMemoryIF, acting as a TreeNode in the SPARTA...
NotificationSource< ReadAccess > ReadNotiSrc
Notification type for memory read accesses.
PostWriteNotiSrc::data_type post_write_noti_data_
Data associated with a post-write notification.
void read(addr_t addr, addr_t size, uint8_t *buf, const void *in_supplement=nullptr, void *out_supplement=nullptr)
Attempts to read memory.
BlockingMemoryIFNode(sparta::TreeNode *parent, const std::string &name, const std::string &desc, addr_t block_size, const AccessWindow &window, TranslationIF *transif=nullptr)
Constructor for single window without TreeNode group information.
ReadNotiSrc post_read_noti_
NotificationSource for post-read notifications.
virtual bool tryRead(addr_t addr, addr_t size, uint8_t *buf, const void *in_supplement=nullptr, void *out_supplement=nullptr) override
Attempt to read memory of size size at address addr.
void write(addr_t addr, addr_t size, const uint8_t *buf, const void *in_supplement=nullptr, void *out_supplement=nullptr)
Attempts to write memory.
std::unique_ptr< uint8_t[]> prior_val_buffer_
Buffer for holding prior memory data during post-write notifications in order to avoid re-allocating ...
PostWriteNotiSrc post_write_noti_
NotificationSource for post-write notifications.
ReadNotiSrc::data_type post_read_noti_data_
Data associated with a post-read notification.
virtual bool tryWrite(addr_t addr, addr_t size, const uint8_t *buf, const void *in_supplement=nullptr, void *out_supplement=nullptr) override
Attempt to write memory of size size at address addr.
NotificationSource< PostWriteAccess > PostWriteNotiSrc
Notification type for memory write accesses.
PostWriteNotiSrc & getPostWriteNotificationSource()
Returns the post-write notification-source node for this memory interface which can be used to observ...
BlockingMemoryIFNode(sparta::TreeNode *parent, const std::string &name, const std::string &group, group_idx_type group_idx, const std::string &desc, addr_t block_size, const DebugMemoryIF::AccessWindow &window, TranslationIF *transif=nullptr)
Construct a blocking memory interface that is also a sparta::TreeNode subclass.
ReadNotiSrc & getReadNotificationSource()
Returns the read notification-source node for this memory interface which can be used to observe writ...
StatisticSet & getStatisticSet()
Returns the StatisticSet published by this Node.
virtual std::string stringize(bool pretty=false) const override
Render description of this BlockingMemoryIF as a string.
Pure-virtual memory interface which represents a simple, immediately accessible (blocking) address-sp...
virtual bool tryRead_(addr_t addr, addr_t size, uint8_t *buf, const void *in_supplement, void *out_supplement)=0
Implements tryRead.
virtual bool tryWrite_(addr_t addr, addr_t size, const uint8_t *buf, const void *in_supplement, void *out_supplement)=0
Implements tryWrite.
Memory interface which represents a simple, immediately accessible (blocking) address-space with supp...
bool tryPeek(addr_t addr, addr_t size, uint8_t *buf) const
Attempts to 'peek' memory without having any side effects, size-limitations, alignment constraints ex...
bool doesAccessSpan(addr_t addr, addr_t size) const noexcept
Determines if the given address spans block boundaries defined for this interface....
bool isInAccessWindows(addr_t addr, addr_t size) const
Determines if the range [addr, addr+size) is within the access windows for this interface.
addr_t total_range_
Range of addresses from highest accessible to lowest.
void verifyNoBlockSpan(addr_t addr, addr_t size) const
Verifies that the given address does not span block boundaries defined for this interface.
void verifyInAccessWindows(addr_t addr, addr_t size) const
Verifies that the range [addr, addr+size) is within the access windows for this interface.
Error while attempting to read some memory object or interface.
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.
Structure containing data for a Memory post-write notification.
void * out_supplement
Supplementary data-object associated with the memory transaction which caused this notification....
const void * in_supplement
Supplementary data-object associated with the memory transaction which caused this notification.
addr_t addr
Address of the access on this object.
const uint8_t * prior
Value which was written to mem. Size is size field.
addr_t size
Size in bytes of the access.
const uint8_t * tried
Value that the write access attempted to write. Size is size field.
DebugMemoryIF *const mem
Register on which the write access took place.
Structure containing data for a Memory pre- or post-read notification.
const void * in_supplement
Supplementary data-object associated with the memory transaction which caused this notification.
addr_t addr
Address of the access from the perspective of the memory interface.
DebugMemoryIF *const mem
Memory interface on which the access took place.
addr_t size
Size in bytes of the access.
const uint8_t * data
Data just read from mem. Size is size field.
void * out_supplement
Supplementary data-object associated with the memory transaction which caused this notification....
Defines an access window within this interface. Accesses through a memory interface are constrained t...