From: Luke Kenneth Casson Leighton Date: Fri, 19 Oct 2018 12:17:37 +0000 (+0100) Subject: add sv_mmu.h X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=58d95ca0ebaf71319a4eb28795a4a563bb76d494;p=riscv-isa-sim.git add sv_mmu.h --- diff --git a/riscv/sv_mmu.h b/riscv/sv_mmu.h new file mode 100644 index 0000000..9ef5208 --- /dev/null +++ b/riscv/sv_mmu.h @@ -0,0 +1,83 @@ +#ifndef _SV_MMU_H +#define _SV_MMU_H + +#include "mmu.h" +#include "processor.h" + +//typedef reg_t sv_reg_t; +//typedef sreg_t sv_sreg_t; + +class sv_mmu_t : public mmu_t +{ +public: + sv_mmu_t(simif_t* sim, processor_t* proc) : mmu_t(sim, proc) {} + + #define sv_load_func(type) \ + inline sv_reg_t load_##type(reg_t addr) { \ + type##_t v = mmu_t::load_##type(addr); \ + return sv_reg_t(v); \ + } + //inline sv_reg_t load_##type(sv_reg_t addr) { + // type##_t v = mmu_t::load_##type(addr); + // return sv_reg_t(v); + //} + + // load value from memory at aligned address; zero extend to register width + sv_load_func(uint8) + sv_load_func(uint16) + sv_load_func(uint32) + sv_load_func(uint64) + + // load value from memory at aligned address; sign extend to register width + sv_load_func(int8) + sv_load_func(int16) + sv_load_func(int32) + sv_load_func(int64) + + #define sv_store_func(type) \ + void store_##type(sv_reg_t addr, type##_t val) { \ + mmu_t::store_##type(addr, val); \ + } + //void store_##type(sv_reg_t addr, sv_reg_t val) { + // mmu_t::store_##type(addr, val); + //} + + // store value to memory at aligned address + sv_store_func(uint8) + sv_store_func(uint16) + sv_store_func(uint32) + sv_store_func(uint64) + + #define sv_amo_func(type) \ + template \ + sv_reg_t amo_##type(sv_reg_t addr, sv_reg_t rhs, _op f) { \ + type##_t v = mmu_t::amo_##type(addr, rhs, f); \ + return sv_reg_t(v); \ + } + + sv_amo_func(uint32) + sv_amo_func(uint64) + + void store_float128(sv_reg_t addr, float128_t val) + { + mmu_t::store_float128(addr /*.get_data()*/, val); + } + + float128_t load_float128(sv_reg_t addr) + { + return mmu_t::load_float128(addr/*.get_data()*/); + } + + void acquire_load_reservation(sv_reg_t vaddr) + { + mmu_t::acquire_load_reservation(vaddr/*.get_data()*/); + } + + bool check_load_reservation(sv_reg_t vaddr) + { + return mmu_t::check_load_reservation(vaddr/*.get_data()*/); + } + +}; + +#endif