X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=operators%2Foperators.h;h=b9abb3e4a1505af262559c38b895f4dd1f93ca65;hb=1e33219bc00f9d93832ce7d057cdbc280c512e9c;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hpb=76741f66364651749e7dfbd857df335656a30dee;p=riscv-isa-sim.git diff --git a/operators/operators.h b/operators/operators.h index e69de29..b9abb3e 100644 --- a/operators/operators.h +++ b/operators/operators.h @@ -0,0 +1,25 @@ +#include "stdint.h" +#include "decode.h" + +typedef uint64_t (*cvt)(uint64_t r); + +uint64_t u64_u64_cvt(reg_t r) { return r; } +uint64_t u64_u16_cvt(reg_t r) { return (uint64_t)(uint16_t)r; } + +uint64_t (sext32)(reg_t r) { return sext32(r); } + +class opcvt +{ +public: + cvt cv_rd; + cvt cv_rs1; + cvt cv_rs2; + opcvt(cvt _cv_rd, cvt _cv_rs1, cvt _cv_rs2) : + cv_rd(_cv_rd), cv_rs1(_cv_rs1), cv_rs2(_cv_rs2) {} + + void add(reg_t &rd, const reg_t &rs1, const reg_t &rs2) + { rd = cv_rd(cv_rs1(rs1) + cv_rs2(rs2)); } + + //R operator+ (op2 &s2) { return typecvt(s1 + typecvt(s2)); } + //operator R() { return typecvt(s1); } +};