4#include "core/memory/ram.hpp"
15 data = std::vector<uint8_t>(size, 0xca);
29 if(offset >=
data.size())
32 ss <<
"Size exceeded for read32_cpu (RAM): 0x" << std::hex << offset;
33 throw std::runtime_error(ss.str());
38 ss <<
"Unaligned read32_cpu (RAM): 0x" << std::hex << offset;
39 throw std::runtime_error(ss.str());
41 return *(uint32_t*)&
data[offset];
55 if(offset >= this->data.size())
58 ss <<
"Size exceeded for write32_cpu (RAM): 0x" << std::hex << offset;
59 throw std::runtime_error(ss.str());
64 ss <<
"Unaligned write32_cpu (RAM): 0x" << std::hex << offset;
65 throw std::runtime_error(ss.str());
67 *(uint32_t*)&this->data[offset] =
data;
80 if(offset >=
data.size())
83 ss <<
"Size exceeded for read8_cpu (RAM): 0x" << std::hex << offset;
84 throw std::runtime_error(ss.str());
99 if(offset >= this->data.size())
101 std::stringstream ss;
102 ss <<
"Size exceeded for write8_cpu (RAM): 0x" << std::hex << offset;
103 throw std::runtime_error(ss.str());
105 this->data[offset] =
data;
119 if(offset >=
data.size())
121 std::stringstream ss;
122 ss <<
"Size exceeded for read16_cpu (RAM): 0x" << std::hex << offset;
123 throw std::runtime_error(ss.str());
127 std::stringstream ss;
128 ss <<
"Unaligned read16_cpu (RAM): 0x" << std::hex << offset;
129 throw std::runtime_error(ss.str());
131 return *(uint16_t*)&
data[offset];
145 if(offset >= this->data.size())
147 std::stringstream ss;
148 ss <<
"Size exceeded for write16_cpu (RAM): 0x" << std::hex << offset;
149 throw std::runtime_error(ss.str());
153 std::stringstream ss;
154 ss <<
"Unaligned write16_cpu (RAM): 0x" << std::hex << offset;
155 throw std::runtime_error(ss.str());
157 *(uint16_t*)&this->data[offset] =
data;
void write8_cpu(uint32_t offset, uint8_t data)
Writes a byte to the RAM.
std::vector< uint8_t > data
Data of the RAM.
void write32_cpu(uint32_t offset, uint32_t data)
Writes a 32-bit word to the RAM.
RAM(uint32_t size)
Construct a new RAM:: RAM object.
void write16_cpu(uint32_t offset, uint16_t data)
Writes a 16-bit word to the RAM.
uint32_t read32_cpu(uint32_t offset)
Reads a 32-bit word from the RAM.
uint16_t read16_cpu(uint32_t offset)
Reads a 16-bit word from the RAM.
uint8_t read8_cpu(uint32_t offset)
Reads a byte from the RAM.