From c64dee965fa00a4b7e3c3705da5e226ea56082ed Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Wed, 16 Nov 2022 19:55:25 -0600 Subject: Implement JTAG-UART tx emulation --- tb/jtag_uart.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tb/jtag_uart.cpp (limited to 'tb/jtag_uart.cpp') 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(ctrl_re) << 0 + | static_cast(ctrl_we) << 1 + //TODO: varios bits + | static_cast(ctrl_ac) << 10 + //TODO: disponibilidad de tx fifo + | static_cast(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; + } +} -- cgit v1.2.3