ComSquare
Public Member Functions | List of all members
ComSquare::Memory::IMemoryBus Class Referenceabstract

The memory bus is the component responsible of mapping addresses to components address and transmitting the data. More...

#include <IMemoryBus.hpp>

Inheritance diagram for ComSquare::Memory::IMemoryBus:
Collaboration diagram for ComSquare::Memory::IMemoryBus:

Public Member Functions

virtual ~IMemoryBus ()=default
 A virtual default destructor. More...
 
virtual uint8_t read (uint24_t addr)=0
 Read data at a global address. This form allow read to be silenced. More...
 
virtual std::optional< uint8_t > peek (uint24_t addr)=0
 This as the same purpose as a read but it does not change the open bus and won't throw an exception. More...
 
virtual uint8_t peek_v (uint24_t addr)=0
 This as the same purpose as a read but it does not change the open bus and won't throw an exception. More...
 
virtual void write (uint24_t addr, uint8_t data)=0
 Write a data to a global address. More...
 
virtual IMemorygetAccessor (uint24_t addr)=0
 Helper function to get the components that is responsible of read/write at an address. More...
 

Detailed Description

The memory bus is the component responsible of mapping addresses to components address and transmitting the data.

Constructor & Destructor Documentation

◆ ~IMemoryBus()

virtual ComSquare::Memory::IMemoryBus::~IMemoryBus ( )
virtualdefault

A virtual default destructor.

Member Function Documentation

◆ getAccessor()

virtual IMemory* ComSquare::Memory::IMemoryBus::getAccessor ( uint24_t  addr)
pure virtual

Helper function to get the components that is responsible of read/write at an address.

Parameters
addrThe address you want to look for.
Returns
The components responsible for the address param or nullptr if none was found.

Implemented in ComSquare::Debugger::MemoryBusDebug, and ComSquare::Memory::MemoryBus.

◆ peek()

virtual std::optional<uint8_t> ComSquare::Memory::IMemoryBus::peek ( uint24_t  addr)
pure virtual

This as the same purpose as a read but it does not change the open bus and won't throw an exception.

Parameters
addrThe address to read from.
Returns
The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register.

Implemented in ComSquare::Debugger::MemoryBusDebug, and ComSquare::Memory::MemoryBus.

◆ peek_v()

virtual uint8_t ComSquare::Memory::IMemoryBus::peek_v ( uint24_t  addr)
pure virtual

This as the same purpose as a read but it does not change the open bus and won't throw an exception.

Parameters
addrThe address to read from.
Returns
The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register.
Note
If the value address is not mapped, 0 is returned instead of nullopt.

Implemented in ComSquare::Debugger::MemoryBusDebug, and ComSquare::Memory::MemoryBus.

◆ read()

virtual uint8_t ComSquare::Memory::IMemoryBus::read ( uint24_t  addr)
pure virtual

Read data at a global address. This form allow read to be silenced.

Parameters
addrThe address to read from.
Exceptions
InvalidAddressIf the address is not mapped to the bus, this exception is thrown.
Returns
The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register.

Implemented in ComSquare::Debugger::MemoryBusDebug, and ComSquare::Memory::MemoryBus.

◆ write()

virtual void ComSquare::Memory::IMemoryBus::write ( uint24_t  addr,
uint8_t  data 
)
pure virtual

Write a data to a global address.

Parameters
addrThe address to write to.
dataThe data to write.

Implemented in ComSquare::Debugger::MemoryBusDebug, and ComSquare::Memory::MemoryBus.


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