diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2016-04-29 13:48:56 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2016-04-29 13:48:56 -0700 |
commit | b593e6df7afc0d356fa0ca0a8c2c8d05f1b87bd8 (patch) | |
tree | 69fa3354e48322b2166b01bfa6a209b775381a99 /riscv/sim.h | |
parent | 9220fdfe955379af4c6cff00e7925a650b2180a5 (diff) | |
download | spike-b593e6df7afc0d356fa0ca0a8c2c8d05f1b87bd8.zip spike-b593e6df7afc0d356fa0ca0a8c2c8d05f1b87bd8.tar.gz spike-b593e6df7afc0d356fa0ca0a8c2c8d05f1b87bd8.tar.bz2 |
Move much closer to new platform-M memory map
Reset vector is at 0x1000; below that is reserved for debug
Memory is at 0x80000000
Diffstat (limited to 'riscv/sim.h')
-rw-r--r-- | riscv/sim.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/riscv/sim.h b/riscv/sim.h index d8f39e2..01025ed 100644 --- a/riscv/sim.h +++ b/riscv/sim.h @@ -7,10 +7,10 @@ #include <string> #include <memory> #include "processor.h" -#include "mmu.h" #include "devices.h" class htif_isasim_t; +class mmu_t; // this class encapsulates the processors and memory in a RISC-V machine. class sim_t @@ -29,7 +29,7 @@ public: void set_histogram(bool value); void set_procs_debug(bool value); htif_isasim_t* get_htif() { return htif.get(); } - const char* get_config_string() { return &config_string->contents()[0]; } + const char* get_config_string() { return config_string.c_str(); } // returns the number of processors in this simulator size_t num_cores() { return procs.size(); } @@ -44,7 +44,8 @@ private: size_t memsz; // memory size in bytes mmu_t* debug_mmu; // debug port into main memory std::vector<processor_t*> procs; - std::unique_ptr<rom_device_t> config_string; + std::string config_string; + std::unique_ptr<rom_device_t> boot_rom; std::unique_ptr<rtc_t> rtc; reg_t config_string_addr; bus_t bus; @@ -60,6 +61,11 @@ private: bool histogram_enabled; // provide a histogram of PCs // memory-mapped I/O routines + bool addr_is_mem(reg_t addr) { + return addr >= MEM_BASE && addr < MEM_BASE + memsz; + } + char* addr_to_mem(reg_t addr) { return mem + addr - MEM_BASE; } + reg_t mem_to_addr(char* x) { return x - mem + MEM_BASE; } bool mmio_load(reg_t addr, size_t len, uint8_t* bytes); bool mmio_store(reg_t addr, size_t len, const uint8_t* bytes); void make_config_string(); |