#pragma once #include #include "VVortex.h" #include "VVortex__Syms.h" #ifdef VCD_OUTPUT #include #endif #include #include "ram.h" #include #include #include #include #include #ifndef MEMORY_BANKS #ifdef PLATFORM_PARAM_LOCAL_MEMORY_BANKS #define MEMORY_BANKS PLATFORM_PARAM_LOCAL_MEMORY_BANKS #else #define MEMORY_BANKS 2 #endif #endif class Simulator { public: Simulator(); virtual ~Simulator(); void attach_ram(RAM* ram); void load_bin(const char* program_file); void load_ihex(const char* program_file); bool is_busy() const; void reset(); void step(); void wait(uint32_t cycles); int run(); void print_stats(std::ostream& out); private: typedef struct { int cycles_left; std::array block; uint64_t addr; uint64_t tag; } mem_req_t; std::unordered_map print_bufs_; void eval(); void eval_mem_bus(); int get_last_wb_value(int reg) const; bool get_ebreak() const; std::list mem_rsp_vec_ [MEMORY_BANKS]; uint32_t last_mem_rsp_bank_; bool mem_rsp_active_; bool mem_rsp_ready_; RAM *ram_; VVortex *vortex_; #ifdef VCD_OUTPUT VerilatedVcdC *trace_; #endif };