RISC-V Emulator part 5: Implementing RVA
This will be a brief post about some design details specific to RVA: Avoiding implementation repetition A lot of instruct instruction do the same thing in 32-bit and 64-bit RVA instructions. To avoid code dumplication, we can template the functions. For example, we can amoaddw and amoaddd this way: template <typename T> { Cpu::reg_name rs1 = decoder.rs1(); Cpu::reg_name rs2 = decoder.rs2(); Cpu::reg_name rd = decoder.rd(); uint64_t addres = cpu.regs[rs1]; T val1 = cpu->bus....