From: Luke Kenneth Casson Leighton Date: Sun, 28 Oct 2018 00:06:22 +0000 (+0100) Subject: move mmu macros to cc file X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0609a28294e711df0a8395ae686ee2fe4e053096;p=riscv-isa-sim.git move mmu macros to cc file --- diff --git a/riscv/riscv.mk.in b/riscv/riscv.mk.in index 6916d07..719f56b 100644 --- a/riscv/riscv.mk.in +++ b/riscv/riscv.mk.in @@ -56,6 +56,7 @@ riscv_srcs = \ debug_module.cc \ remote_bitbang.cc \ sv.cc \ + sv_mmu.cc \ sv_insn_redirect.cc \ jtag_dtm.cc \ $(riscv_gen_srcs) \ diff --git a/riscv/sv_mmu.cc b/riscv/sv_mmu.cc new file mode 100644 index 0000000..4205397 --- /dev/null +++ b/riscv/sv_mmu.cc @@ -0,0 +1,64 @@ +#include "sv_mmu.h" + +#define sv_load_func(type) \ +sv_reg_t sv_mmu_t::load_##type(reg_t const& 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 sv_mmu_t::store_##type(sv_reg_t const& addr, type##_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) + +#if 0 +#define sv_amo_func(type) \ +template \ +sv_reg_t sv_mmu_t::amo_##type(sv_reg_t const& addr, sv_reg_t const& 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) +#endif + +void sv_mmu_t::store_float128(sv_reg_t const& addr, float128_t val) +{ + mmu_t::store_float128(addr, val); +} + +sv_float128_t sv_mmu_t::load_float128(sv_reg_t const& addr) +{ + return mmu_t::load_float128(addr); +} + +void sv_mmu_t::acquire_load_reservation(sv_reg_t const& vaddr) +{ + mmu_t::acquire_load_reservation(vaddr); +} + +bool sv_mmu_t::check_load_reservation(sv_reg_t const& vaddr) +{ + return mmu_t::check_load_reservation(vaddr); +} + + diff --git a/riscv/sv_mmu.h b/riscv/sv_mmu.h index 011564f..7101ba4 100644 --- a/riscv/sv_mmu.h +++ b/riscv/sv_mmu.h @@ -12,38 +12,29 @@ 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 const& 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); - //} + #define sv_load_func_decl(type) \ + sv_reg_t load_##type(reg_t const& addr); // 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) + sv_load_func_decl(uint8) + sv_load_func_decl(uint16) + sv_load_func_decl(uint32) + sv_load_func_decl(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) + sv_load_func_decl(int8) + sv_load_func_decl(int16) + sv_load_func_decl(int32) + sv_load_func_decl(int64) - #define sv_store_func(type) \ - void store_##type(sv_reg_t const& addr, type##_t val) { \ - mmu_t::store_##type(addr, val); \ - } + #define sv_store_func_decl(type) \ + void store_##type(sv_reg_t const& addr, type##_t val); // store value to memory at aligned address - sv_store_func(uint8) - sv_store_func(uint16) - sv_store_func(uint32) - sv_store_func(uint64) + sv_store_func_decl(uint8) + sv_store_func_decl(uint16) + sv_store_func_decl(uint32) + sv_store_func_decl(uint64) #define sv_amo_func(type) \ template \ @@ -55,25 +46,11 @@ public: sv_amo_func(uint32) sv_amo_func(uint64) - void store_float128(sv_reg_t const& addr, float128_t val) - { - mmu_t::store_float128(addr, val); - } - - sv_float128_t load_float128(sv_reg_t const& addr) - { - return mmu_t::load_float128(addr); - } - - void acquire_load_reservation(sv_reg_t const& vaddr) - { - mmu_t::acquire_load_reservation(vaddr); - } + void store_float128(sv_reg_t const& addr, float128_t val); + sv_float128_t load_float128(sv_reg_t const& addr); - bool check_load_reservation(sv_reg_t const& vaddr) - { - return mmu_t::check_load_reservation(vaddr); - } + void acquire_load_reservation(sv_reg_t const& vaddr); + bool check_load_reservation(sv_reg_t const& vaddr); };