mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-09 20:59:06 +00:00
Finishing to clean tests and adding the start of the bus logger
This commit is contained in:
+9
-2
@@ -3,13 +3,15 @@
|
||||
//
|
||||
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
#include "Ram.hpp"
|
||||
#include "../Exceptions/InvalidAddress.hpp"
|
||||
|
||||
namespace ComSquare::Ram
|
||||
{
|
||||
Ram::Ram(size_t size)
|
||||
: _size(size)
|
||||
Ram::Ram(size_t size, std::string ramName)
|
||||
: _size(size),
|
||||
_ramName(std::move(ramName))
|
||||
{
|
||||
if (size == 0)
|
||||
this->_data = nullptr;
|
||||
@@ -51,4 +53,9 @@ namespace ComSquare::Ram
|
||||
{
|
||||
return this->_size;
|
||||
}
|
||||
|
||||
std::string Ram::getName()
|
||||
{
|
||||
return this->_ramName;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-4
@@ -5,25 +5,27 @@
|
||||
#ifndef COMSQUARE_RAM_HPP
|
||||
#define COMSQUARE_RAM_HPP
|
||||
|
||||
#include "../Memory/IRectangleMemory.hpp"
|
||||
#include "../Memory/ARectangleMemory.hpp"
|
||||
|
||||
namespace ComSquare::Ram
|
||||
{
|
||||
class Ram : public Memory::IRectangleMemory {
|
||||
class Ram : public Memory::ARectangleMemory {
|
||||
protected:
|
||||
//! @brief The ram. (Can be used for WRam, SRam, VRam etc)
|
||||
uint8_t *_data;
|
||||
//! @brief The size of the ram (iny bytes).
|
||||
size_t _size;
|
||||
//! @brief The name of this ram.
|
||||
std::string _ramName;
|
||||
public:
|
||||
//! @brief Create a ram of a given size in bytes.
|
||||
explicit Ram(size_t size);
|
||||
explicit Ram(size_t size, std::string ramName);
|
||||
//! @brief The ram can't be copied.
|
||||
Ram(const Ram &) = delete;
|
||||
//! @brief The ram can't be assigned.
|
||||
Ram &operator=(Ram &) = delete;
|
||||
//! @brief Destructor that free the ram.
|
||||
~Ram();
|
||||
~Ram() override;
|
||||
//! @brief Read from the ram.
|
||||
//! @param addr The address to read from. The address 0x0 should refer to the first byte of this ram.
|
||||
//! @throw InvalidAddress will be thrown if the address is more than the size of the ram.
|
||||
@@ -41,6 +43,9 @@ namespace ComSquare::Ram
|
||||
//! @param value replace value
|
||||
void memset(uint24_t start, uint24_t end, uint8_t value);
|
||||
|
||||
//! @brief Get the name of this accessor (used for debug purpose)
|
||||
std::string getName() override;
|
||||
|
||||
//! @brief Get the size of the ram in bytes.
|
||||
size_t getSize();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user