The Sparta Modeling Framework
|
Memory interface which represents a simple, immediately accessible (blocking) address-space with support for peek and poke acceeses having no side effects other than changing the desired memory. More...
#include <DebugMemoryIF.hpp>
Classes | |
struct | AccessWindow |
Defines an access window within this interface. Accesses through a memory interface are constrained to this window. More... | |
Public Member Functions | |
Construction | |
DebugMemoryIF ()=delete | |
Default constuctor. | |
DebugMemoryIF (const std::string &desc, addr_t block_size, const AccessWindow &window, TranslationIF *transif=nullptr) | |
Construct a DebugMemoryInterface. | |
virtual | ~DebugMemoryIF () |
Virutal destructor. | |
Translation Information | |
virtual const TranslationIF * | getTranslationIF () |
Gets the translation interface associated with this Debug memory interface (if any). | |
Interface Attributes | |
const std::string & | getDescription () |
Returns the description specified at construction. | |
addr_t | getBlockSize () const |
Returns the block size of memory represented by this interface. Read and write accesses must not span block boundaries (where addr % block_size == 0). | |
addr_t | getRange () const |
Gets the total span of this interface's valid address range. | |
addr_t | getLowEnd () const |
Gets the lowest address accessible. | |
addr_t | getHighEnd () const |
Gets the highest address accessible + 1. | |
addr_t | getAccessibleSize () const |
Gets the total accessible size of this interface's valid addresses within the total size (getRange) excluding holes between access windows. | |
const std::vector< AccessWindow > & | getWindows () const |
Gets the vector of windows representing this interface. | |
General Queries | |
bool | isAddressInWindows (addr_t addr) const noexcept |
Determines if the given address is in an access window 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. | |
bool | isInAccessWindows (addr_t addr, addr_t size) const |
Determines if the range [addr, addr+size) is within the access windows for this interface. | |
void | verifyNoBlockSpan (addr_t addr, addr_t size) const |
Verifies that the given address does not span block boundaries defined for this interface. | |
bool | doesAccessSpan (addr_t addr, addr_t size) const noexcept |
Determines if the given address spans block boundaries defined for this interface. Accesses which span blocks are illegal for read/write accesses, but allowed for peak/poke debug accesses. | |
Debug Memory Access | |
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 except that all bytes peeked are inside an access window for this interface. | |
void | peek (addr_t addr, addr_t size, uint8_t *buf) const |
Wrapper on tryPeek which throws a MemoryAccessError if the peek is not legal. | |
bool | tryPoke (addr_t addr, addr_t size, const uint8_t *buf) |
Attempts to 'poke' memory without having any side effects other than changing the bytes within the range [ addr , addr + size ). Poke has no size-limitations or alignment constraints except that all bytes peeked are inside an access window for this interface. | |
void | poke (addr_t addr, addr_t size, const uint8_t *buf) |
Wrapper on tryPoke which throws a MemoryAccessError if the poke is not legal. | |
Protected Attributes | |
const addr_t | block_size_ |
Size of a block accessed through this interface. | |
addr_t | block_mask_ |
Mask applied to an address to get only bits representing the block ID. | |
addr_t | block_idx_lsb_ |
rshift applied to an address to get the block ID | |
const std::vector< AccessWindow > | acc_windows_ |
Vector of access windows representing this memory. | |
TranslationIF * | trans_ |
Translation interface created for this interface. Externally owned. | |
const std::string *const | desc_ptr_ |
Description pointer. | |
addr_t | total_range_ |
Range of addresses from highest accessible to lowest. | |
addr_t | low_end_ |
Lowest accessible address. | |
addr_t | high_end_ |
Highest accessible address + 1. | |
addr_t | accessible_size_ |
Number of bytes accessible through this interface. | |
Memory interface which represents a simple, immediately accessible (blocking) address-space with support for peek and poke acceeses having no side effects other than changing the desired memory.
This interface does not support non-blocking accesses or access attributes.
This interface operates on post-translated addresses from the TranslationIF available through getTranslationIF
The object implementing this interface can perform any translation or logic to satisfy memory accesses.
Peek and Poke accesses within this interface are automatically chunked into block-constrained accesses and re-assembled.
This class is intended to be an innocuous interface to some kind of "memory" from the perspective of some simulation unit with which this interface is associated. For example, if attached to a core this interface would most appropriately present the software view of virtual memory. Note that data and instruction memory views from a core may need to use different debugging interfaces. It is possible different interfaces could even be provided for each address-space avaialable per data and instruction depending on that core's mmu.
Example
Definition at line 64 of file DebugMemoryIF.hpp.
|
inline |
Construct a DebugMemoryInterface.
desc | Description of this interface. What is this an interface for and what is the perspective? For example, "core virtual data memory". This exists so that errors generated by this code can indicate which interface the error came from |
block_size | Size of a block in this interface. Must be a power of 2 and greater than 0. |
window | AccessWindow defining valid range of addresses. Must be block-aligned. These are post-translated addresses ready to be used in access methods |
transif | Optional translation interface associated with this memory interface. This must be specified, is managed externally, and must exist for the lifetime of this interface |
SpartaException | if block_size or window is invalid |
Definition at line 163 of file DebugMemoryIF.hpp.
|
inlinevirtual |
Virutal destructor.
Definition at line 232 of file DebugMemoryIF.hpp.
|
inlinenoexcept |
Determines if the given address spans block boundaries defined for this interface. Accesses which span blocks are illegal for read/write accesses, but allowed for peak/poke debug accesses.
addr | Post-translated address to test (see getTranslationIF) |
size | Size of access to test |
Definition at line 394 of file DebugMemoryIF.hpp.
|
inline |
Gets the total accessible size of this interface's valid addresses within the total size (getRange) excluding holes between access windows.
Definition at line 300 of file DebugMemoryIF.hpp.
|
inline |
Returns the block size of memory represented by this interface. Read and write accesses must not span block boundaries (where addr % block_size == 0).
Definition at line 274 of file DebugMemoryIF.hpp.
|
inline |
Returns the description specified at construction.
Definition at line 267 of file DebugMemoryIF.hpp.
|
inline |
Gets the highest address accessible + 1.
Definition at line 293 of file DebugMemoryIF.hpp.
|
inline |
Gets the lowest address accessible.
Definition at line 288 of file DebugMemoryIF.hpp.
|
inline |
Gets the total span of this interface's valid address range.
This is: 1 + the highest accessible address - the lowest accessible address.
Definition at line 283 of file DebugMemoryIF.hpp.
|
inlinevirtual |
Gets the translation interface associated with this Debug memory interface (if any).
This translation interface, if not nullptr, is intended to be used by a client of this class to translate addresses from some external space into a space suitable for use in memory accesses through this interface.
The DebugMemoryIF does not use this translation interface. This association is present as a hint for toos and UIs.
Definition at line 253 of file DebugMemoryIF.hpp.
|
inline |
Gets the vector of windows representing this interface.
These windows define the post-translated access space for this interface
Definition at line 308 of file DebugMemoryIF.hpp.
|
inlinenoexcept |
Determines if the given address is in an access window defined for this interface.
Definition at line 326 of file DebugMemoryIF.hpp.
Determines if the range [addr, addr+size) is within the access windows for this interface.
addr | Post-translated address to test (see getTranslationIF) |
size | Size of access to test |
Definition at line 363 of file DebugMemoryIF.hpp.
Wrapper on tryPeek which throws a MemoryAccessError if the peek is not legal.
Definition at line 461 of file DebugMemoryIF.hpp.
Wrapper on tryPoke which throws a MemoryAccessError if the poke is not legal.
Definition at line 531 of file DebugMemoryIF.hpp.
|
inline |
Attempts to 'peek' memory without having any side effects, size-limitations, alignment constraints except that all bytes peeked are inside an access window for this interface.
addr | Post-translated address from which to peek (see getTranslationIF) |
size | Number of bytes to read from buf. Note that addr and size can span block boundaries in a peek/poke method |
buf | Buffer to which size peeked bytes will be copied if the peek was legal. Content of buf is undefined if peek is illegal |
Peeking is intended as a debugger/tool interface to the simulation
Definition at line 432 of file DebugMemoryIF.hpp.
|
inline |
Attempts to 'poke' memory without having any side effects other than changing the bytes within the range [ addr , addr + size ). Poke has no size-limitations or alignment constraints except that all bytes peeked are inside an access window for this interface.
addr | Post-translated address to which to poke (see getTranslationIF) |
size | Number of bytes to write from buf. Note that addr and size can span block boundaries in a peek/poke method |
buf | read-only buffer whose content should be written to memory. |
Poking is intended as a debugger/tool interface to the simulation
Definition at line 502 of file DebugMemoryIF.hpp.
Verifies that the range [addr, addr+size) is within the access windows for this interface.
addr | Post-translated address to which to test (see getTranslationIF) |
size | Size of access to test |
MemoryAccessError | if the access is not entirely contained in access windows. |
Definition at line 344 of file DebugMemoryIF.hpp.
Verifies that the given address does not span block boundaries defined for this interface.
addr | Post-translated address to test (see getTranslationIF) |
size | Size of access to test |
MemoryAccessError | if true if access spans a block boundary, false otherwise |
Definition at line 377 of file DebugMemoryIF.hpp.
|
protected |
Vector of access windows representing this memory.
Definition at line 564 of file DebugMemoryIF.hpp.
|
protected |
Number of bytes accessible through this interface.
Definition at line 595 of file DebugMemoryIF.hpp.
|
protected |
rshift applied to an address to get the block ID
Definition at line 559 of file DebugMemoryIF.hpp.
|
protected |
Mask applied to an address to get only bits representing the block ID.
Definition at line 554 of file DebugMemoryIF.hpp.
|
protected |
Size of a block accessed through this interface.
Definition at line 548 of file DebugMemoryIF.hpp.
|
protected |
Description pointer.
Definition at line 575 of file DebugMemoryIF.hpp.
|
protected |
Highest accessible address + 1.
Definition at line 590 of file DebugMemoryIF.hpp.
|
protected |
Lowest accessible address.
Definition at line 585 of file DebugMemoryIF.hpp.
|
protected |
Range of addresses from highest accessible to lowest.
Definition at line 580 of file DebugMemoryIF.hpp.
|
protected |
Translation interface created for this interface. Externally owned.
Definition at line 570 of file DebugMemoryIF.hpp.