summaryrefslogtreecommitdiff
path: root/tb/avalon.hpp
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2022-09-18 00:39:21 -0600
committerAlejandro Soto <alejandro@34project.org>2022-09-18 00:39:21 -0600
commitd743c48b821bad11943b77bdc9a5d9d975fd8cb0 (patch)
tree2097ce1618b876cc85172ea85c3165462e052c5e /tb/avalon.hpp
parentb0cb20496d88cd017c4c51243d16ac3b060cc1d6 (diff)
Add Avalon-MM emulator
Diffstat (limited to 'tb/avalon.hpp')
-rw-r--r--tb/avalon.hpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/tb/avalon.hpp b/tb/avalon.hpp
new file mode 100644
index 0000000..38c8792
--- /dev/null
+++ b/tb/avalon.hpp
@@ -0,0 +1,46 @@
+#ifndef AVALON_HPP
+#define AVALON_HPP
+
+#include <cstdint>
+#include <vector>
+
+namespace taller::avalon
+{
+ class slave
+ {
+ public:
+ virtual std::uint32_t base_address() = 0;
+ virtual std::uint32_t address_mask() = 0;
+
+ virtual bool read(std::uint32_t addr, std::uint32_t &data) = 0;
+ virtual bool write(std::uint32_t addr, std::uint32_t data, unsigned byte_enable) = 0;
+ };
+
+ template<class Platform>
+ class interconnect
+ {
+ public:
+ inline interconnect(Platform &plat) noexcept
+ : plat(plat)
+ {}
+
+ void tick();
+ void attach(slave &dev);
+
+ private:
+ struct binding
+ {
+ std::uint32_t base;
+ std::uint32_t mask;
+ slave &dev;
+ };
+
+ Platform &plat;
+ slave* active = nullptr;
+ std::vector<binding> devices;
+ };
+}
+
+#include "avalon.impl.hpp"
+
+#endif