summaryrefslogtreecommitdiff
path: root/tb
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tb/jtag_uart.cpp55
-rw-r--r--tb/jtag_uart.hpp25
-rw-r--r--tb/top/conspiracion.cpp3
3 files changed, 83 insertions, 0 deletions
diff --git a/tb/jtag_uart.cpp b/tb/jtag_uart.cpp
new file mode 100644
index 0000000..78d438e
--- /dev/null
+++ b/tb/jtag_uart.cpp
@@ -0,0 +1,55 @@
+#include "avalon.hpp"
+#include "jtag_uart.hpp"
+
+namespace taller::avalon
+{
+ jtag_uart::jtag_uart(std::uint32_t base) noexcept
+ : slave(base, 8, 4)
+ {}
+
+ bool jtag_uart::read(std::uint32_t addr, std::uint32_t &data) noexcept
+ {
+ switch(addr)
+ {
+ case 0:
+ data = 0; //TODO
+ break;
+
+ case 1:
+ data =
+ static_cast<std::uint32_t>(ctrl_re) << 0
+ | static_cast<std::uint32_t>(ctrl_we) << 1
+ //TODO: varios bits
+ | static_cast<std::uint32_t>(ctrl_ac) << 10
+ //TODO: disponibilidad de tx fifo
+ | static_cast<std::uint32_t>(255) << 10;
+
+ break;
+ }
+
+ return true;
+ }
+
+ bool jtag_uart::write(std::uint32_t addr, std::uint32_t data, unsigned byte_enable) noexcept
+ {
+ switch(addr)
+ {
+ case 0:
+ putchar(data & 0xff);
+ ctrl_ac = 1;
+ break;
+
+ case 1:
+ ctrl_re = !!(data & (1 << 0));
+ ctrl_we = !!(data & (1 << 1));
+ if(!!(data & (1 << 10)))
+ {
+ ctrl_ac = 0;
+ }
+
+ break;
+ }
+
+ return true;
+ }
+}
diff --git a/tb/jtag_uart.hpp b/tb/jtag_uart.hpp
new file mode 100644
index 0000000..6db50f8
--- /dev/null
+++ b/tb/jtag_uart.hpp
@@ -0,0 +1,25 @@
+#ifndef TALLER_JTAG_UART_HPP
+#define TALLER_JTAG_UART_HPP
+
+#include <cstdint>
+
+#include "avalon.hpp"
+
+namespace taller::avalon
+{
+ class jtag_uart : public slave
+ {
+ public:
+ jtag_uart(std::uint32_t base) noexcept;
+
+ virtual bool read(std::uint32_t addr, std::uint32_t &data) noexcept final override;
+ virtual bool write(std::uint32_t addr, std::uint32_t data, unsigned byte_enable) noexcept final override;
+
+ private:
+ bool ctrl_re = false;
+ bool ctrl_we = false;
+ bool ctrl_ac = true;
+ };
+}
+
+#endif
diff --git a/tb/top/conspiracion.cpp b/tb/top/conspiracion.cpp
index 2840b15..789a0df 100644
--- a/tb/top/conspiracion.cpp
+++ b/tb/top/conspiracion.cpp
@@ -22,6 +22,7 @@
#include "../avalon.hpp"
#include "../mem.hpp"
+#include "../jtag_uart.hpp"
#include "../null.hpp"
#include "../window.hpp"
#include "../vga.hpp"
@@ -197,6 +198,7 @@ int main(int argc, char **argv)
interconnect<Vconspiracion_vga_domain> avl_vga(*top.conspiracion->plat->vga);
mem<std::uint32_t> hps_ddr3(0x0000'0000, 512 << 20);
+ jtag_uart ttyj0(0x3000'0000);
mem<std::uint16_t> vram(0x3800'0000, 64 << 20);
null vram_null(0x3800'0000, 64 << 20, 2);
window vram_window(vram, 0x0000'0000);
@@ -205,6 +207,7 @@ int main(int argc, char **argv)
bool enable_video = !headless;
avl.attach(hps_ddr3);
+ avl.attach(ttyj0);
if(enable_video)
{