summaryrefslogtreecommitdiff
path: root/tb/mem.cpp
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2023-10-05 06:31:27 -0600
committerAlejandro Soto <alejandro@34project.org>2023-10-05 13:07:57 -0600
commite2d82e8e18ebddc78a0c187c4b7501b9f3aaa9c5 (patch)
treeeb72ed72e33f3a5ef3d9843ddcff624156177647 /tb/mem.cpp
parent59caca686d4d7798b617ee2a9f9d4c5d1d27b8ff (diff)
tb: move most C++ source files to tb/top/conspiracion
Diffstat (limited to 'tb/mem.cpp')
-rw-r--r--tb/mem.cpp50
1 files changed, 0 insertions, 50 deletions
diff --git a/tb/mem.cpp b/tb/mem.cpp
deleted file mode 100644
index a58eaa9..0000000
--- a/tb/mem.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#include <cassert>
-#include <cstdint>
-#include <memory>
-
-#include "avalon.hpp"
-#include "mem.hpp"
-
-namespace taller::avalon
-{
- mem::mem(std::uint32_t base, std::uint32_t size)
- : slave(base, size, 4),
- block(std::make_unique<line[]>(size >> 4))
- {}
-
- bool mem::read_line(std::uint32_t addr, line &data, unsigned byte_enable [[maybe_unused]])
- {
- data = block[addr];
- return true;/*ready();*/
- }
-
- bool mem::write_line(std::uint32_t addr, const line &data, unsigned byte_enable)
- {
- for (unsigned i = 0; i < 4; ++i) {
- 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;
-
- byte_enable >>= 4;
- block[addr].words[i] = (data.words[i] & bytes) | (block[addr].words[i] & ~bytes);
- }
-
- return true;/*ready();*/
- }
-
- bool mem::ready() noexcept
- {
- count = count > 0 ? count - 1 : 2;
- return count == 0;
- }
-}