From 6fb3849e73b797d4610a2b782127f927dec0c9c9 Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Mon, 14 Nov 2022 21:10:40 -0600 Subject: Implement VGA simulation --- tb/mem.hpp | 42 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) (limited to 'tb/mem.hpp') diff --git a/tb/mem.hpp b/tb/mem.hpp index a76780d..0943530 100644 --- a/tb/mem.hpp +++ b/tb/mem.hpp @@ -1,5 +1,5 @@ -#ifndef MEM_HPP -#define MEM_HPP +#ifndef TALLER_MEM_HPP +#define TALLER_MEM_HPP #include #include @@ -8,54 +8,30 @@ namespace taller::avalon { + template class mem : public slave { public: mem(std::uint32_t base, std::uint32_t size); - virtual inline std::uint32_t base_address() noexcept final override - { - return base; - } - - virtual inline std::uint32_t address_mask() noexcept final override - { - return mask; - } - virtual bool read(std::uint32_t addr, std::uint32_t &data) final override; + virtual bool write ( std::uint32_t addr, std::uint32_t data, unsigned byte_enable = 0b1111 ) final override; template - void load(F loader, std::size_t addr = 0); + void load(F loader, std::size_t offset = 0); private: - std::unique_ptr block; - std::uint32_t base; - std::uint32_t mask; - unsigned count = 0; + std::unique_ptr block; + unsigned count = 0; bool ready() noexcept; }; - - template - void mem::load(F loader, std::size_t addr) - { - std::size_t size = mask + 1; - while(addr < size) - { - std::size_t read = loader(&block[base + addr], size - addr); - if(read == 0) - { - break; - } - - addr += read; - } - } } +#include "mem.impl.hpp" + #endif -- cgit v1.2.3