ComSquare
Public Member Functions | Protected Attributes | List of all members
ComSquare::Memory::AMemory Class Reference

Abstract class representing a continuous block of memory. More...

#include <AMemory.hpp>

Inheritance diagram for ComSquare::Memory::AMemory:
Collaboration diagram for ComSquare::Memory::AMemory:

Public Member Functions

uint24_t getRelativeAddress (uint24_t addr) const override
 Translate an absolute address to a relative address. More...
 
void setMemoryRegion (uint24_t start, uint24_t end)
 Change starting and ending points of this mapped memory. More...
 
bool hasMemoryAt (uint24_t addr) const override
 Return true if this component has mapped the address. More...
 
 ~AMemory () override=default
 A default destructor. More...
 
- Public Member Functions inherited from ComSquare::Memory::IMemory
virtual uint8_t read (uint24_t addr)=0
 Read data from the component. More...
 
virtual void write (uint24_t addr, uint8_t data)=0
 Write data to this component. More...
 
virtual uint24_t getSize () const =0
 Get the size of the data. This size can be lower than the mapped data. More...
 
virtual std::string getName () const =0
 Get the name of this accessor (used for debug purpose) More...
 
virtual Component getComponent () const =0
 Get the component of this accessor (used for debug purpose) More...
 
virtual std::string getValueName (uint24_t addr) const =0
 Get the name of the data at the address. More...
 
virtual ~IMemory ()=default
 A virtual default destructor. More...
 

Protected Attributes

uint24_t _start = 0
 The starting address mapped to this component. More...
 
uint24_t _end = 0
 The last continuous address mapped to this components. For shadows, see the MemoryShadow class. More...
 

Detailed Description

Abstract class representing a continuous block of memory.

Constructor & Destructor Documentation

◆ ~AMemory()

ComSquare::Memory::AMemory::~AMemory ( )
overridedefault

A default destructor.

Member Function Documentation

◆ getRelativeAddress()

uint24_t ComSquare::Memory::AMemory::getRelativeAddress ( uint24_t  addr) const
overridevirtual

Translate an absolute address to a relative address.

Parameters
addrThe absolute address (in the 24 bit bus)
Returns
The local address (0 refers to the first byte of this component).
Exceptions
InvalidAddressis thrown if the address is not mapped by this component.

Implements ComSquare::Memory::IMemory.

◆ hasMemoryAt()

bool ComSquare::Memory::AMemory::hasMemoryAt ( uint24_t  addr) const
overridevirtual

Return true if this component has mapped the address.

Parameters
addrThe address to check.
Returns
True if this address is mapped to the component. False otherwise.

Implements ComSquare::Memory::IMemory.

◆ setMemoryRegion()

void ComSquare::Memory::AMemory::setMemoryRegion ( uint24_t  start,
uint24_t  end 
)

Change starting and ending points of this mapped memory.

Parameters
startThe first address mapped to this component.
endThe last address mapped to this component.
Warning
The start/end address should be a continuous range. You can't map address 0x0 and 0x2 but not 0x1. To do that, use two AMemory.

Member Data Documentation

◆ _end

uint24_t ComSquare::Memory::AMemory::_end = 0
protected

The last continuous address mapped to this components. For shadows, see the MemoryShadow class.

◆ _start

uint24_t ComSquare::Memory::AMemory::_start = 0
protected

The starting address mapped to this component.


The documentation for this class was generated from the following files: