#pragma once #include #include #include "io/model.h" #include "isa/isa.h" struct funcmem { static constexpr unsigned int PAGE_BYTES_LOG2 = 20; static constexpr unsigned int PAGE_BYTES = 1 << PAGE_BYTES_LOG2; static constexpr unsigned int PAGE_BYTE_OFFSET_MASK = PAGE_BYTES - 1; typedef std::array page; std::map image; unsigned int fetch(unsigned int address) const { auto page_address = address >> PAGE_BYTES_LOG2; auto page_offset = address & PAGE_BYTE_OFFSET_MASK; if (auto p = image.find(page_address); p != image.end()) { const auto &page = p->second; return page[page_offset]; } return 0; } void store(unsigned int address, unsigned int value) { auto page_address = address >> PAGE_BYTES_LOG2; auto page_offset = address & PAGE_BYTE_OFFSET_MASK; auto [p, emplaced] = image.try_emplace(page_address); auto &page = p->second; if (emplaced) page.fill(0); page[page_offset] = value; } }; struct checker { unsigned int acc = 0; unsigned int link = 0; unsigned int mq = 0; unsigned int pc = 00200; std::array ctlregs; iomodel &system; instruction_context inst; funcmem mem; checker(iomodel &system) : system(system) { ctlregs.fill(0); } void execute(); };