summaryrefslogtreecommitdiff
path: root/tb/mem.cpp
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2022-11-14 21:10:40 -0600
committerAlejandro Soto <alejandro@34project.org>2022-11-14 21:10:40 -0600
commit6fb3849e73b797d4610a2b782127f927dec0c9c9 (patch)
tree9d17de8907d860b795761e0644f17d0fd33106de /tb/mem.cpp
parentcad870295dfb741d5c24c25016c5bba878bc37e5 (diff)
Implement VGA simulation
Diffstat (limited to 'tb/mem.cpp')
-rw-r--r--tb/mem.cpp55
1 files changed, 0 insertions, 55 deletions
diff --git a/tb/mem.cpp b/tb/mem.cpp
deleted file mode 100644
index 6eeb7df..0000000
--- a/tb/mem.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#include <cassert>
-#include <cstdint>
-#include <memory>
-
-#include "mem.hpp"
-
-namespace taller::avalon
-{
- mem::mem(std::uint32_t base, std::uint32_t size)
- : base(base), mask(~(size - 1)),
- block(std::make_unique<std::uint32_t[]>(size >> 2))
- {
- assert(!(size & 0b11) && !((size - 1) & size));
- }
-
- bool mem::read(std::uint32_t addr, std::uint32_t &data)
- {
- data = block[addr];
- return ready();
- }
-
- bool mem::write(std::uint32_t addr, std::uint32_t data, unsigned byte_enable)
- {
- std::uint32_t bytes = 0;
-
- if(byte_enable & 0b1000)
- {
- bytes |= 0xff << 24;
- }
-
- if(byte_enable & 0b0100)
- {
- bytes |= 0xff << 16;
- }
-
- if(byte_enable & 0b0010)
- {
- bytes |= 0xff << 8;
- }
-
- if(byte_enable & 0b0001)
- {
- bytes |= 0xff;
- }
-
- block[addr] = (data & bytes) | (block[addr] & ~bytes);
- return ready();
- }
-
- bool mem::ready() noexcept
- {
- count = count > 0 ? count - 1 : 2;
- return count == 0;
- }
-}