diff --git a/.cproject b/.cproject
index 48c5c3a..7a0ad6f 100644
--- a/.cproject
+++ b/.cproject
@@ -10,15 +10,14 @@
-
-
+
-
+
@@ -46,7 +45,7 @@
-
+
diff --git a/dbt-core b/dbt-core
index 393c374..23dbab0 160000
--- a/dbt-core
+++ b/dbt-core
@@ -1 +1 @@
-Subproject commit 393c374cac4950e629036dda1615abedf866961f
+Subproject commit 23dbab0b768d122c492110d1db34408e9ae787f3
diff --git a/riscv/gen_input/RV32A.core_desc b/riscv/gen_input/RV32A.core_desc
index 67e0c89..16638c5 100644
--- a/riscv/gen_input/RV32A.core_desc
+++ b/riscv/gen_input/RV32A.core_desc
@@ -1,108 +1,108 @@
import "RV32IBase.core_desc"
InsructionSet RV32A extends RV32IBase{
-
- address_spaces {
- RES[8]
- }
-
- instructions{
- LR.W {
- encoding: b00010 | aq[0:0] | rl[0:0] | b00000 | rs1[4:0] | b010 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d";
- if(rd!=0){
- val offs[XLEN] <= X[rs1];
- X[rd]<= sext(MEM[offs]{32}, XLEN);
- RES[offs]{32}<=sext(-1, 32);
- }
- }
- SC.W {
- encoding: b00011 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d";
- val offs[XLEN] <= X[rs1];
- val res1[32] <= RES[offs]{32};
- if(res1!=0)
- MEM[offs]{32} <= X[rs2];
- if(rd!=0) X[rd]<= choose(res1!=0, 0, 1);
- }
- AMOSWAP.W{
- encoding: b00001 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%aq$d,rel=%rl$d)";
- val offs[XLEN]<=X[rs1];
- if(rd!=0) X[rd]<=sext(MEM[offs]{32});
- MEM[offs]{32}<=X[rs2];
- }
- AMOADD.W{
- encoding: b00000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%aq$d,rel=%rl$d)";
- val offs[XLEN]<=X[rs1];
- val res1[XLEN] <= sext(MEM[offs]{32});
- if(rd!=0) X[rd]<=res1;
- val res2[XLEN]<=res1 + X[rs2];
- MEM[offs]{32}<=res2;
- }
- AMOXOR.W{
- encoding: b00100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%aq$d,rel=%rl$d)";
- val offs[XLEN]<=X[rs1];
- val res1[XLEN] <= sext(MEM[offs]{32});
- if(rd!=0) X[rd]<=res1;
- val res2[XLEN]<=res1 ^ X[rs2];
- MEM[offs]{32}<=res2;
- }
- AMOAND.W{
- encoding: b01100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%aq$d,rel=%rl$d)";
- val offs[XLEN]<=X[rs1];
- val res1[XLEN] <= sext(MEM[offs]{32});
- if(rd!=0) X[rd]<=res1;
- val res2[XLEN] <=res1 & X[rs2];
- MEM[offs]{32}<=res2;
- }
- AMOOR.W {
- encoding: b01000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%aq$d,rel=%rl$d)";
- val offs[XLEN]<=X[rs1];
- val res1[XLEN] <= sext(MEM[offs]{32});
- if(rd!=0) X[rd]<=res1;
- val res2[XLEN]<=res1 | X[rs2];
- MEM[offs]{32}<=res2;
- }
- AMOMIN.W{
- encoding: b10000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%aq$d,rel=%rl$d)";
- val offs[XLEN]<=X[rs1];
- val res1[XLEN] <= sext(MEM[offs]{32});
- if(rd!=0) X[rd]<=res1;
- val res2[XLEN]<= choose(res1's>X[rs2]s, X[rs2], res1);
- MEM[offs]{32}<=res2;
- }
- AMOMAX.W{
- encoding: b10100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%aq$d,rel=%rl$d)";
- val offs[XLEN]<=X[rs1];
- val res1[XLEN] <= sext(MEM[offs]{32});
- if(rd!=0) X[rd]<=res1;
- val res2[XLEN]<= choose(res1'sX[rs2], X[rs2], res1);
- MEM[offs]{32}<=res2;
- }
- AMOMAXU.W{
- encoding: b11100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%aq$d,rel=%rl$d)";
- val offs[XLEN]<=X[rs1];
- val res1[XLEN] <= zext(MEM[offs]{32});
- if(rd!=0) X[rd]<=res1;
- val res2[XLEN]<= choose(res1'uX[rs2]s, X[rs2], res1);
+ MEM[offs]{32}<=res2;
+ }
+ AMOMAX.W{
+ encoding: b10100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
+ args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%aq$d,rel=%rl$d)";
+ val offs[XLEN]<=X[rs1];
+ val res1[XLEN] <= sext(MEM[offs]{32});
+ if(rd!=0) X[rd]<=res1;
+ val res2[XLEN]<= choose(res1'sX[rs2], X[rs2], res1);
+ MEM[offs]{32}<=res2;
+ }
+ AMOMAXU.W{
+ encoding: b11100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
+ args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%aq$d,rel=%rl$d)";
+ val offs[XLEN]<=X[rs1];
+ val res1[XLEN] <= zext(MEM[offs]{32});
+ if(rd!=0) X[rd]<=res1;
+ val res2[XLEN]<= choose(res1'uF[rs2]f, F[rs1]f, F[rs2]f);
- val res[64] <= fdispatch_fsel_d(F[rs1]{64}, F[rs2]{64}, zext(1, 32));
- if(FLEN==64)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<64) | res;
- }
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FCVT.S.D {
- encoding: b0100000 | b00001 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"f%rd$d, f%rs1$d";
- val res[32] <= fdispatch_fconv_d2f(F[rs1], rm{8});
- // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= upper<<32 | zext(res, FLEN);
- }
- FCVT.D.S {
- encoding: b0100001 | b00000 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"f%rd$d, f%rs1$d";
- val res[64] <= fdispatch_fconv_f2d(F[rs1]{32}, rm{8});
- if(FLEN==64){
- F[rd] <= res;
- } else {
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<64) | res;
- }
- }
- FEQ.D {
- encoding: b1010001 | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b1010011;
- args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
- X[rd]<=fdispatch_fcmp_d(F[rs1]{64}, F[rs2]{64}, zext(0, 32));
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FLT.D {
- encoding: b1010001 | rs2[4:0] | rs1[4:0] | b001 | rd[4:0] | b1010011;
- args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
- X[rd]<=fdispatch_fcmp_d(F[rs1]{64}, F[rs2]{64}, zext(2, 32));
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FLE.D {
- encoding: b1010001 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b1010011;
- args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
- X[rd]<=fdispatch_fcmp_d(F[rs1]{64}, F[rs2]{64}, zext(1, 32));
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FCLASS.D {
- encoding: b1110001 | b00000 | rs1[4:0] | b001 | rd[4:0] | b1010011;
- args_disass:"x%rd$d, f%rs1$d";
- X[rd]<=fdispatch_fclass_d(F[rs1]{64});
- }
- FCVT.W.D {
- encoding: b1100001 | b00000 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"x%rd$d, f%rs1$d";
- X[rd]<= sext(fdispatch_fcvt_d(F[rs1]{64}, zext(0, 32), rm{8}), XLEN);
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FCVT.WU.D {
- encoding: b1100001 | b00001 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"x%rd$d, f%rs1$d";
- X[rd]<= zext(fdispatch_fcvt_d(F[rs1]{64}, zext(1, 32), rm{8}), XLEN);
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FCVT.D.W {
- encoding: b1101001 | b00000 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"f%rd$d, x%rs1$d";
- val res[64] <= fdispatch_fcvt_d(sext(X[rs1],64), zext(2, 32), rm{8});
- if(FLEN==64)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<64) | res;
- }
- }
- FCVT.D.WU {
- encoding: b1101001 | b00001 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"f%rd$d, x%rs1$d";
- val res[64] <=fdispatch_fcvt_d(zext(X[rs1],64), zext(3,32), rm{8});
- if(FLEN==64)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<64) | res;
- }
- }
- }
+ constants {
+ FLEN, FFLAG_MASK := 0x1f
+ }
+ registers {
+ [31:0] F[FLEN], FCSR[32]
+ }
+ instructions{
+ FLD {
+ encoding: imm[11:0]s | rs1[4:0] | b011 | rd[4:0] | b0000111;
+ args_disass:"f%rd$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1]+imm;
+ val res[64] <= MEM[offs]{64};
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ }
+ FSD {
+ encoding: imm[11:5]s | rs2[4:0] | rs1[4:0] | b011 | imm[4:0]s | b0100111;
+ args_disass:"f%rs2$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1]+imm;
+ MEM[offs]{64}<=F[rs2]{64};
+ }
+ FMADD.D {
+ encoding: rs3[4:0] | b01 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1000011;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d, f%rs3$d";
+ //F[rd]f<= F[rs1]f * F[rs2]f + F[rs3]f;
+ val res[64] <= fdispatch_fmadd_d(F[rs1]{64}, F[rs2]{64}, F[rs3]{64}, zext(0, 64), choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FMSUB.D {
+ encoding: rs3[4:0] | b01 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1000111;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d, f%rs3$d";
+ //F[rd]f<=F[rs1]f * F[rs2]f - F[rs3]f;
+ val res[64] <= fdispatch_fmadd_d(F[rs1]{64}, F[rs2]{64}, F[rs3]{64}, zext(1, 32), choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FNMADD.D {
+ encoding: rs3[4:0] | b01 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1001111;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d, f%rs3$d";
+ //F[rd]f<=-F[rs1]f * F[rs2]f + F[rs3]f;
+ val res[64] <= fdispatch_fmadd_d(F[rs1]{64}, F[rs2]{64}, F[rs3]{64}, zext(2, 32), choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FNMSUB.D {
+ encoding: rs3[4:0] | b01 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1001011;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d, f%rs3$d";
+ //F[rd]f<=-F[rs1]f * F[rs2]f - F[rs3]f;
+ val res[64] <= fdispatch_fmadd_d(F[rs1]{64}, F[rs2]{64}, F[rs3]{64}, zext(3, 32), choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FADD.D {
+ encoding: b0000001 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
+ // F[rd]f <= F[rs1]f + F[rs2]f;
+ val res[64] <= fdispatch_fadd_d(F[rs1]{64}, F[rs2]{64}, choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FSUB.D {
+ encoding: b0000101 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
+ // F[rd]f <= F[rs1]f - F[rs2]f;
+ val res[64] <= fdispatch_fsub_d(F[rs1]{64}, F[rs2]{64}, choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FMUL.D {
+ encoding: b0001001 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
+ // F[rd]f <= F[rs1]f * F[rs2]f;
+ val res[64] <= fdispatch_fmul_d(F[rs1]{64}, F[rs2]{64}, choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FDIV.D {
+ encoding: b0001101 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
+ // F[rd]f <= F[rs1]f / F[rs2]f;
+ val res[64] <= fdispatch_fdiv_d(F[rs1]{64}, F[rs2]{64}, choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FSQRT.D {
+ encoding: b0101101 | b00000 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d";
+ //F[rd]f<=sqrt(F[rs1]f);
+ val res[64] <= fdispatch_fsqrt_d(F[rs1]{64}, choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FSGNJ.D {
+ encoding: b0010001 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
+ val res[64] <= (F[rs1]{64} & 0x7fffffff) | (F[rs2]{64} & 0x80000000);
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ }
+ FSGNJN.D {
+ encoding: b0010001 | rs2[4:0] | rs1[4:0] | b001 | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
+ val res[64] <= (F[rs1]{64} & 0x7fffffff) | (~F[rs2]{64} & 0x80000000);
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ }
+ FSGNJX.D {
+ encoding: b0010001 | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
+ val res[64] <= F[rs1]{64} ^ (F[rs2]{64} & 0x80000000);
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ }
+ FMIN.D {
+ encoding: b0010101 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
+ //F[rd]f<= choose(F[rs1]fF[rs2]f, F[rs1]f, F[rs2]f);
+ val res[64] <= fdispatch_fsel_d(F[rs1]{64}, F[rs2]{64}, zext(1, 32));
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FCVT.S.D {
+ encoding: b0100000 | b00001 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d";
+ val res[32] <= fdispatch_fconv_d2f(F[rs1], rm{8});
+ // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= upper<<32 | zext(res, FLEN);
+ }
+ FCVT.D.S {
+ encoding: b0100001 | b00000 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d";
+ val res[64] <= fdispatch_fconv_f2d(F[rs1]{32}, rm{8});
+ if(FLEN==64){
+ F[rd] <= res;
+ } else {
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ }
+ FEQ.D {
+ encoding: b1010001 | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
+ X[rd]<=fdispatch_fcmp_d(F[rs1]{64}, F[rs2]{64}, zext(0, 32));
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FLT.D {
+ encoding: b1010001 | rs2[4:0] | rs1[4:0] | b001 | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
+ X[rd]<=fdispatch_fcmp_d(F[rs1]{64}, F[rs2]{64}, zext(2, 32));
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FLE.D {
+ encoding: b1010001 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
+ X[rd]<=fdispatch_fcmp_d(F[rs1]{64}, F[rs2]{64}, zext(1, 32));
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FCLASS.D {
+ encoding: b1110001 | b00000 | rs1[4:0] | b001 | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d";
+ X[rd]<=fdispatch_fclass_d(F[rs1]{64});
+ }
+ FCVT.W.D {
+ encoding: b1100001 | b00000 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d";
+ X[rd]<= sext(fdispatch_fcvt_d(F[rs1]{64}, zext(0, 32), rm{8}), XLEN);
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FCVT.WU.D {
+ encoding: b1100001 | b00001 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d";
+ X[rd]<= zext(fdispatch_fcvt_d(F[rs1]{64}, zext(1, 32), rm{8}), XLEN);
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FCVT.D.W {
+ encoding: b1101001 | b00000 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, x%rs1$d";
+ val res[64] <= fdispatch_fcvt_d(sext(X[rs1],64), zext(2, 32), rm{8});
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ }
+ FCVT.D.WU {
+ encoding: b1101001 | b00001 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, x%rs1$d";
+ val res[64] <=fdispatch_fcvt_d(zext(X[rs1],64), zext(3,32), rm{8});
+ if(FLEN==64)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<64) | res;
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/riscv/gen_input/RV32F.core_desc b/riscv/gen_input/RV32F.core_desc
index a5324fd..a950f7b 100644
--- a/riscv/gen_input/RV32F.core_desc
+++ b/riscv/gen_input/RV32F.core_desc
@@ -1,294 +1,294 @@
import "RV32IBase.core_desc"
InsructionSet RV32F extends RV32IBase{
- constants {
- FLEN, FFLAG_MASK := 0x1f
- }
- registers {
- [31:0] F[FLEN], FCSR[32]
- }
- instructions{
- FLW {
- encoding: imm[11:0]s | rs1[4:0] | b010 | rd[4:0] | b0000111;
- args_disass:"f%rd$d, %imm%(x%rs1$d)";
- val offs[XLEN] <= X[rs1]+imm;
- val res[32] <= MEM[offs]{32};
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- }
- FSW {
- encoding: imm[11:5]s | rs2[4:0] | rs1[4:0] | b010 | imm[4:0]s | b0100111;
- args_disass:"f%rs2$d, %imm%(x%rs1$d)";
- val offs[XLEN] <= X[rs1]+imm;
- MEM[offs]{32}<=F[rs2]{32};
- }
- FMADD.S {
- encoding: rs3[4:0] | b00 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1000011;
- args_disass:"x%rd$d, f%rs1$d, f%rs2$d, f%rs3$d";
- //F[rd]f<= F[rs1]f * F[rs2]f + F[rs3]f;
- val res[32] <= fdispatch_fmadd_s(F[rs1]{32}, F[rs2]{32}, F[rs3]{32}, zext(0, 32), choose(rm<7, rm{8}, FCSR{8}));
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FMSUB.S {
- encoding: rs3[4:0] | b00 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1000111;
- args_disass:"x%rd$d, f%rs1$d, f%rs2$d, f%rs3$d";
- //F[rd]f<=F[rs1]f * F[rs2]f - F[rs3]f;
- val res[32] <= fdispatch_fmadd_s(F[rs1]{32}, F[rs2]{32}, F[rs3]{32}, zext(1, 32), choose(rm<7, rm{8}, FCSR{8}));
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FNMADD.S {
- encoding: rs3[4:0] | b00 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1001111;
- args_disass:"x%rd$d, f%rs1$d, f%rs2$d, f%rs3$d";
- //F[rd]f<=-F[rs1]f * F[rs2]f + F[rs3]f;
- val res[32] <= fdispatch_fmadd_s(F[rs1]{32}, F[rs2]{32}, F[rs3]{32}, zext(2, 32), choose(rm<7, rm{8}, FCSR{8}));
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FNMSUB.S {
- encoding: rs3[4:0] | b00 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1001011;
- args_disass:"x%rd$d, f%rs1$d, f%rs2$d, f%rs3$d";
- //F[rd]f<=-F[rs1]f * F[rs2]f - F[rs3]f;
- val res[32] <= fdispatch_fmadd_s(F[rs1]{32}, F[rs2]{32}, F[rs3]{32}, zext(3, 32), choose(rm<7, rm{8}, FCSR{8}));
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FADD.S {
- encoding: b0000000 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
- // F[rd]f <= F[rs1]f + F[rs2]f;
- val res[32] <= fdispatch_fadd_s(F[rs1]{32}, F[rs2]{32}, choose(rm<7, rm{8}, FCSR{8}));
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FSUB.S {
- encoding: b0000100 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
- // F[rd]f <= F[rs1]f - F[rs2]f;
- val res[32] <= fdispatch_fsub_s(F[rs1]{32}, F[rs2]{32}, choose(rm<7, rm{8}, FCSR{8}));
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FMUL.S {
- encoding: b0001000 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
- // F[rd]f <= F[rs1]f * F[rs2]f;
- val res[32] <= fdispatch_fmul_s(F[rs1]{32}, F[rs2]{32}, choose(rm<7, rm{8}, FCSR{8}));
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FDIV.S {
- encoding: b0001100 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
- // F[rd]f <= F[rs1]f / F[rs2]f;
- val res[32] <= fdispatch_fdiv_s(F[rs1]{32}, F[rs2]{32}, choose(rm<7, rm{8}, FCSR{8}));
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FSQRT.S {
- encoding: b0101100 | b00000 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"f%rd$d, f%rs1$d";
- //F[rd]f<=sqrt(F[rs1]f);
- val res[32] <= fdispatch_fsqrt_s(F[rs1]{32}, choose(rm<7, rm{8}, FCSR{8}));
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FSGNJ.S {
- encoding: b0010000 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b1010011;
- args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
- val res[32] <= (F[rs1]{32} & 0x7fffffff) | (F[rs2]{32} & 0x80000000);
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- }
- FSGNJN.S {
- encoding: b0010000 | rs2[4:0] | rs1[4:0] | b001 | rd[4:0] | b1010011;
- args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
- val res[32] <= (F[rs1]{32} & 0x7fffffff) | (~F[rs2]{32} & 0x80000000);
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- }
- FSGNJX.S {
- encoding: b0010000 | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b1010011;
- args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
- val res[32] <= F[rs1]{32} ^ (F[rs2]{32} & 0x80000000);
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- }
- FMIN.S {
- encoding: b0010100 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b1010011;
- args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
- //F[rd]f<= choose(F[rs1]fF[rs2]f, F[rs1]f, F[rs2]f);
- val res[32] <= fdispatch_fsel_s(F[rs1]{32}, F[rs2]{32}, zext(1, 32));
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FCVT.W.S {
- encoding: b1100000 | b00000 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"x%rd$d, f%rs1$d";
- X[rd]<= sext(fdispatch_fcvt_s(F[rs1]{32}, zext(0, 32), rm{8}), XLEN);
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FCVT.WU.S {
- encoding: b1100000 | b00001 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"x%rd$d, f%rs1$d";
- X[rd]<= zext(fdispatch_fcvt_s(F[rs1]{32}, zext(1, 32), rm{8}), XLEN);
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FEQ.S {
- encoding: b1010000 | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b1010011;
- args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
- X[rd]<=fdispatch_fcmp_s(F[rs1]{32}, F[rs2]{32}, zext(0, 32));
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FLT.S {
- encoding: b1010000 | rs2[4:0] | rs1[4:0] | b001 | rd[4:0] | b1010011;
- args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
- X[rd]<=fdispatch_fcmp_s(F[rs1]{32}, F[rs2]{32}, zext(2, 32));
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FLE.S {
- encoding: b1010000 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b1010011;
- args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
- X[rd]<=fdispatch_fcmp_s(F[rs1]{32}, F[rs2]{32}, zext(1, 32));
- val flags[32] <= fdispatch_fget_flags();
- FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
- }
- FCLASS.S {
- encoding: b1110000 | b00000 | rs1[4:0] | b001 | rd[4:0] | b1010011;
- args_disass:"x%rd$d, f%rs1$d";
- X[rd]<=fdispatch_fclass_s(F[rs1]{32});
- }
- FCVT.S.W {
- encoding: b1101000 | b00000 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"f%rd$d, x%rs1$d";
- val res[32] <= fdispatch_fcvt_s(X[rs1]{32}, zext(2, 32), rm{8});
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- }
- FCVT.S.WU {
- encoding: b1101000 | b00001 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
- args_disass:"f%rd$d, x%rs1$d";
- val res[32] <=fdispatch_fcvt_s(X[rs1]{32}, zext(3,32), rm{8});
- if(FLEN==32)
- F[rd] <= res;
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(res, FLEN);
- }
- }
- FMV.X.W {
- encoding: b1110000 | b00000 | rs1[4:0] | b000 | rd[4:0] | b1010011;
- args_disass:"x%rd$d, f%rs1$d";
- X[rd]<=sext(F[rs1]{32});
- }
- FMV.W.X {
- encoding: b1111000 | b00000 | rs1[4:0] | b000 | rd[4:0] | b1010011;
- args_disass:"f%rd$d, x%rs1$d";
- if(FLEN==32)
- F[rd] <= X[rs1];
- else { // NaN boxing
- val upper[FLEN] <= -1;
- F[rd] <= (upper<<32) | zext(X[rs1], FLEN);
- }
- }
- }
+ constants {
+ FLEN, FFLAG_MASK := 0x1f
+ }
+ registers {
+ [31:0] F[FLEN], FCSR[32]
+ }
+ instructions{
+ FLW {
+ encoding: imm[11:0]s | rs1[4:0] | b010 | rd[4:0] | b0000111;
+ args_disass:"f%rd$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1]+imm;
+ val res[32] <= MEM[offs]{32};
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ }
+ FSW {
+ encoding: imm[11:5]s | rs2[4:0] | rs1[4:0] | b010 | imm[4:0]s | b0100111;
+ args_disass:"f%rs2$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1]+imm;
+ MEM[offs]{32}<=F[rs2]{32};
+ }
+ FMADD.S {
+ encoding: rs3[4:0] | b00 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1000011;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d, f%rs3$d";
+ //F[rd]f<= F[rs1]f * F[rs2]f + F[rs3]f;
+ val res[32] <= fdispatch_fmadd_s(F[rs1]{32}, F[rs2]{32}, F[rs3]{32}, zext(0, 32), choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FMSUB.S {
+ encoding: rs3[4:0] | b00 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1000111;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d, f%rs3$d";
+ //F[rd]f<=F[rs1]f * F[rs2]f - F[rs3]f;
+ val res[32] <= fdispatch_fmadd_s(F[rs1]{32}, F[rs2]{32}, F[rs3]{32}, zext(1, 32), choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FNMADD.S {
+ encoding: rs3[4:0] | b00 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1001111;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d, f%rs3$d";
+ //F[rd]f<=-F[rs1]f * F[rs2]f + F[rs3]f;
+ val res[32] <= fdispatch_fmadd_s(F[rs1]{32}, F[rs2]{32}, F[rs3]{32}, zext(2, 32), choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FNMSUB.S {
+ encoding: rs3[4:0] | b00 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1001011;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d, f%rs3$d";
+ //F[rd]f<=-F[rs1]f * F[rs2]f - F[rs3]f;
+ val res[32] <= fdispatch_fmadd_s(F[rs1]{32}, F[rs2]{32}, F[rs3]{32}, zext(3, 32), choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FADD.S {
+ encoding: b0000000 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
+ // F[rd]f <= F[rs1]f + F[rs2]f;
+ val res[32] <= fdispatch_fadd_s(F[rs1]{32}, F[rs2]{32}, choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FSUB.S {
+ encoding: b0000100 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
+ // F[rd]f <= F[rs1]f - F[rs2]f;
+ val res[32] <= fdispatch_fsub_s(F[rs1]{32}, F[rs2]{32}, choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FMUL.S {
+ encoding: b0001000 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
+ // F[rd]f <= F[rs1]f * F[rs2]f;
+ val res[32] <= fdispatch_fmul_s(F[rs1]{32}, F[rs2]{32}, choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FDIV.S {
+ encoding: b0001100 | rs2[4:0] | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
+ // F[rd]f <= F[rs1]f / F[rs2]f;
+ val res[32] <= fdispatch_fdiv_s(F[rs1]{32}, F[rs2]{32}, choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FSQRT.S {
+ encoding: b0101100 | b00000 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d";
+ //F[rd]f<=sqrt(F[rs1]f);
+ val res[32] <= fdispatch_fsqrt_s(F[rs1]{32}, choose(rm<7, rm{8}, FCSR{8}));
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FSGNJ.S {
+ encoding: b0010000 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
+ val res[32] <= (F[rs1]{32} & 0x7fffffff) | (F[rs2]{32} & 0x80000000);
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ }
+ FSGNJN.S {
+ encoding: b0010000 | rs2[4:0] | rs1[4:0] | b001 | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
+ val res[32] <= (F[rs1]{32} & 0x7fffffff) | (~F[rs2]{32} & 0x80000000);
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ }
+ FSGNJX.S {
+ encoding: b0010000 | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
+ val res[32] <= F[rs1]{32} ^ (F[rs2]{32} & 0x80000000);
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ }
+ FMIN.S {
+ encoding: b0010100 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, f%rs1$d, f%rs2$d";
+ //F[rd]f<= choose(F[rs1]fF[rs2]f, F[rs1]f, F[rs2]f);
+ val res[32] <= fdispatch_fsel_s(F[rs1]{32}, F[rs2]{32}, zext(1, 32));
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FCVT.W.S {
+ encoding: b1100000 | b00000 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d";
+ X[rd]<= sext(fdispatch_fcvt_s(F[rs1]{32}, zext(0, 32), rm{8}), XLEN);
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FCVT.WU.S {
+ encoding: b1100000 | b00001 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d";
+ X[rd]<= zext(fdispatch_fcvt_s(F[rs1]{32}, zext(1, 32), rm{8}), XLEN);
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FEQ.S {
+ encoding: b1010000 | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
+ X[rd]<=fdispatch_fcmp_s(F[rs1]{32}, F[rs2]{32}, zext(0, 32));
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FLT.S {
+ encoding: b1010000 | rs2[4:0] | rs1[4:0] | b001 | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
+ X[rd]<=fdispatch_fcmp_s(F[rs1]{32}, F[rs2]{32}, zext(2, 32));
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FLE.S {
+ encoding: b1010000 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d, f%rs2$d";
+ X[rd]<=fdispatch_fcmp_s(F[rs1]{32}, F[rs2]{32}, zext(1, 32));
+ val flags[32] <= fdispatch_fget_flags();
+ FCSR <= (FCSR & ~FFLAG_MASK) + flags{5};
+ }
+ FCLASS.S {
+ encoding: b1110000 | b00000 | rs1[4:0] | b001 | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d";
+ X[rd]<=fdispatch_fclass_s(F[rs1]{32});
+ }
+ FCVT.S.W {
+ encoding: b1101000 | b00000 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, x%rs1$d";
+ val res[32] <= fdispatch_fcvt_s(X[rs1]{32}, zext(2, 32), rm{8});
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ }
+ FCVT.S.WU {
+ encoding: b1101000 | b00001 | rs1[4:0] | rm[2:0] | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, x%rs1$d";
+ val res[32] <=fdispatch_fcvt_s(X[rs1]{32}, zext(3,32), rm{8});
+ if(FLEN==32)
+ F[rd] <= res;
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(res, FLEN);
+ }
+ }
+ FMV.X.W {
+ encoding: b1110000 | b00000 | rs1[4:0] | b000 | rd[4:0] | b1010011;
+ args_disass:"x%rd$d, f%rs1$d";
+ X[rd]<=sext(F[rs1]{32});
+ }
+ FMV.W.X {
+ encoding: b1111000 | b00000 | rs1[4:0] | b000 | rd[4:0] | b1010011;
+ args_disass:"f%rd$d, x%rs1$d";
+ if(FLEN==32)
+ F[rd] <= X[rs1];
+ else { // NaN boxing
+ val upper[FLEN] <= -1;
+ F[rd] <= (upper<<32) | zext(X[rs1], FLEN);
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/riscv/gen_input/RV32IBase.core_desc b/riscv/gen_input/RV32IBase.core_desc
index 22f02f7..cfea414 100644
--- a/riscv/gen_input/RV32IBase.core_desc
+++ b/riscv/gen_input/RV32IBase.core_desc
@@ -1,325 +1,326 @@
InsructionSet RV32IBase {
- constants {
- XLEN,
- PCLEN,
- XLEN_BIT_MASK:=0x1f,
+ constants {
+ XLEN,
+ PCLEN,
+ XLEN_BIT_MASK:=0x1f,
fence:=0,
fencei:=1,
fencevmal:=2,
fencevmau:=3
- }
-
- address_spaces {
- MEM[8], CSR[XLEN], FENCE[XLEN]
- }
-
- registers {
- [31:0] X[XLEN],
- PC[XLEN](is_pc)
- }
-
- instructions {
- LUI{
- encoding: imm[31:12]s | rd[4:0] | b0110111;
- args_disass: "x%rd$d, 0x%imm$05x";
- if(rd!=0) X[rd] <= imm;
- }
- AUIPC{
- encoding: imm[31:12]s | rd[4:0] | b0010111;
- args_disass: "x%rd%, 0x%imm$08x";
- if(rd!=0) X[rd] <= PC+imm;
- }
- JAL(no_cont){
- encoding: imm[20:20]s | imm[10:1]s | imm[11:11]s | imm[19:12]s | rd[4:0] | b1101111;
- args_disass: "x%rd$d, 0x%imm$x";
- if(rd!=0) X[rd] <= PC+4;
- PC<=PC+imm;
- }
- JALR(no_cont){
- encoding: imm[11:0]s | rs1[4:0] | b000 | rd[4:0] | b1100111;
- args_disass: "x%rd$d, x%rs1$d, 0x%imm$x";
+ }
+
+ address_spaces {
+ MEM[8], CSR[XLEN], FENCE[XLEN]
+ }
+
+ registers {
+ [31:0] X[XLEN],
+ PC[XLEN](is_pc),
+ alias ZERO[XLEN] is X[0]
+ }
+
+ instructions {
+ LUI{
+ encoding: imm[31:12]s | rd[4:0] | b0110111;
+ args_disass: "x%rd$d, 0x%imm$05x";
+ if(rd!=0) X[rd] <= imm;
+ }
+ AUIPC{
+ encoding: imm[31:12]s | rd[4:0] | b0010111;
+ args_disass: "x%rd%, 0x%imm$08x";
+ if(rd!=0) X[rd] <= PC+imm;
+ }
+ JAL(no_cont){
+ encoding: imm[20:20]s | imm[10:1]s | imm[11:11]s | imm[19:12]s | rd[4:0] | b1101111;
+ args_disass: "x%rd$d, 0x%imm$x";
+ if(rd!=0) X[rd] <= PC+4;
+ PC<=PC+imm;
+ }
+ JALR(no_cont){
+ encoding: imm[11:0]s | rs1[4:0] | b000 | rd[4:0] | b1100111;
+ args_disass: "x%rd$d, x%rs1$d, 0x%imm$x";
val new_pc[XLEN] <= X[rs1]+ imm;
val align[XLEN] <= new_pc & 0x2;
- if(align != 0){
- raise(0, 0);
- } else {
- if(rd!=0) X[rd] <= PC+4;
- PC<=new_pc & ~0x1;
- }
- }
- BEQ(no_cont,cond){
- encoding: imm[12:12]s |imm[10:5]s | rs2[4:0] | rs1[4:0] | b000 | imm[4:1]s | imm[11:11]s | b1100011;
- args_disass:"x%rs1$d, x%rs2$d, 0x%imm$x";
- PC<=choose(X[rs1]==X[rs2], PC+imm, PC+4);
- }
- BNE(no_cont,cond){
- encoding: imm[12:12]s |imm[10:5]s | rs2[4:0] | rs1[4:0] | b001 | imm[4:1]s | imm[11:11]s | b1100011;
- args_disass:"x%rs1$d, x%rs2$d, 0x%imm$x";
- PC<=choose(X[rs1]!=X[rs2], PC+imm, PC+4);
- }
- BLT(no_cont,cond){
- encoding: imm[12:12]s |imm[10:5]s | rs2[4:0] | rs1[4:0] | b100 | imm[4:1]s | imm[11:11]s | b1100011;
- args_disass:"x%rs1$d, x%rs2$d, 0x%imm$x";
- PC<=choose(X[rs1]s=X[rs2]s, PC+imm, PC+4);
- }
- BLTU(no_cont,cond) {
- encoding: imm[12:12]s |imm[10:5]s | rs2[4:0] | rs1[4:0] | b110 | imm[4:1]s | imm[11:11]s | b1100011;
- args_disass:"x%rs1$d, x%rs2$d, 0x%imm$x";
- PC<=choose(X[rs1]=X[rs2], PC+imm, PC+4);
- }
- LB {
- encoding: imm[11:0]s | rs1[4:0] | b000 | rd[4:0] | b0000011;
- args_disass:"x%rd$d, %imm%(x%rs1$d)";
- val offs[XLEN] <= X[rs1]+imm;
- if(rd!=0) X[rd]<=sext(MEM[offs]);
- }
- LH {
- encoding: imm[11:0]s | rs1[4:0] | b001 | rd[4:0] | b0000011;
- args_disass:"x%rd$d, %imm%(x%rs1$d)";
- val offs[XLEN] <= X[rs1]+imm;
- if(rd!=0) X[rd]<=sext(MEM[offs]{16});
- }
- LW {
- encoding: imm[11:0]s | rs1[4:0] | b010 | rd[4:0] | b0000011;
- args_disass:"x%rd$d, %imm%(x%rs1$d)";
- val offs[XLEN] <= X[rs1]+imm;
- if(rd!=0) X[rd]<=sext(MEM[offs]{32});
- }
- LBU {
- encoding: imm[11:0]s | rs1[4:0] | b100 | rd[4:0] | b0000011;
- args_disass:"x%rd$d, %imm%(x%rs1$d)";
- val offs[XLEN] <= X[rs1]+imm;
- if(rd!=0) X[rd]<=zext(MEM[offs]);
- }
- LHU {
- encoding: imm[11:0]s | rs1[4:0] | b101 | rd[4:0] | b0000011;
- args_disass:"x%rd$d, %imm%(x%rs1$d)";
- val offs[XLEN] <= X[rs1]+imm;
- if(rd!=0) X[rd]<=zext(MEM[offs]{16});
- }
- SB {
- encoding: imm[11:5]s | rs2[4:0] | rs1[4:0] | b000 | imm[4:0]s | b0100011;
- args_disass:"x%rs2$d, %imm%(x%rs1$d)";
- val offs[XLEN] <= X[rs1] + imm;
- MEM[offs] <= X[rs2];
- }
- SH {
- encoding: imm[11:5]s | rs2[4:0] | rs1[4:0] | b001 | imm[4:0]s | b0100011;
- args_disass:"x%rs2$d, %imm%(x%rs1$d)";
- val offs[XLEN] <= X[rs1] + imm;
- MEM[offs]{16} <= X[rs2];
- }
- SW {
- encoding: imm[11:5]s | rs2[4:0] | rs1[4:0] | b010 | imm[4:0]s | b0100011;
- args_disass:"x%rs2$d, %imm%(x%rs1$d)";
- val offs[XLEN] <= X[rs1] + imm;
- MEM[offs]{32} <= X[rs2];
- }
- ADDI {
- encoding: imm[11:0]s | rs1[4:0] | b000 | rd[4:0] | b0010011;
- args_disass:"x%rd$d, x%rs1$d, %imm%";
- if(rd != 0) X[rd] <= X[rs1] + imm;
- }
- SLTI {
- encoding: imm[11:0]s | rs1[4:0] | b010 | rd[4:0] | b0010011;
- args_disass:"x%rd$d, x%rs1$d, %imm%";
- if (rd != 0) X[rd] <= choose(X[rs1]s < imm's, 1, 0); //TODO: needs fix
- }
- SLTIU {
- encoding: imm[11:0]s | rs1[4:0] | b011 | rd[4:0] | b0010011;
- args_disass:"x%rd$d, x%rs1$d, %imm%";
- val full_imm[XLEN] <= imm's;
- if (rd != 0) X[rd] <= choose(X[rs1]'u < full_imm'u, 1, 0);
- }
- XORI {
- encoding: imm[11:0]s | rs1[4:0] | b100 | rd[4:0] | b0010011;
- args_disass:"x%rd$d, x%rs1$d, %imm%";
- if(rd != 0) X[rd] <= X[rs1] ^ imm;
- }
- ORI {
- encoding: imm[11:0]s | rs1[4:0] | b110 | rd[4:0] | b0010011;
- args_disass:"x%rd$d, x%rs1$d, %imm%";
- if(rd != 0) X[rd] <= X[rs1] | imm;
- }
- ANDI {
- encoding: imm[11:0]s | rs1[4:0] | b111 | rd[4:0] | b0010011;
- args_disass:"x%rd$d, x%rs1$d, %imm%";
- if(rd != 0) X[rd] <= X[rs1] & imm;
- }
- SLLI {
- encoding: b0000000 | shamt[4:0] | rs1[4:0] | b001 | rd[4:0] | b0010011;
- args_disass:"x%rd$d, x%rs1$d, %shamt%";
- if(shamt > 31){
- raise(0,0);
- } else {
- if(rd != 0) X[rd] <= shll(X[rs1], shamt);
- }
- }
- SRLI {
- encoding: b0000000 | shamt[4:0] | rs1[4:0] | b101 | rd[4:0] | b0010011;
- args_disass:"x%rd$d, x%rs1$d, %shamt%";
+ if(align != 0){
+ raise(0, 0);
+ } else {
+ if(rd!=0) X[rd] <= PC+4;
+ PC<=new_pc & ~0x1;
+ }
+ }
+ BEQ(no_cont,cond){
+ encoding: imm[12:12]s |imm[10:5]s | rs2[4:0] | rs1[4:0] | b000 | imm[4:1]s | imm[11:11]s | b1100011;
+ args_disass:"x%rs1$d, x%rs2$d, 0x%imm$x";
+ PC<=choose(X[rs1]==X[rs2], PC+imm, PC+4);
+ }
+ BNE(no_cont,cond){
+ encoding: imm[12:12]s |imm[10:5]s | rs2[4:0] | rs1[4:0] | b001 | imm[4:1]s | imm[11:11]s | b1100011;
+ args_disass:"x%rs1$d, x%rs2$d, 0x%imm$x";
+ PC<=choose(X[rs1]!=X[rs2], PC+imm, PC+4);
+ }
+ BLT(no_cont,cond){
+ encoding: imm[12:12]s |imm[10:5]s | rs2[4:0] | rs1[4:0] | b100 | imm[4:1]s | imm[11:11]s | b1100011;
+ args_disass:"x%rs1$d, x%rs2$d, 0x%imm$x";
+ PC<=choose(X[rs1]s=X[rs2]s, PC+imm, PC+4);
+ }
+ BLTU(no_cont,cond) {
+ encoding: imm[12:12]s |imm[10:5]s | rs2[4:0] | rs1[4:0] | b110 | imm[4:1]s | imm[11:11]s | b1100011;
+ args_disass:"x%rs1$d, x%rs2$d, 0x%imm$x";
+ PC<=choose(X[rs1]=X[rs2], PC+imm, PC+4);
+ }
+ LB {
+ encoding: imm[11:0]s | rs1[4:0] | b000 | rd[4:0] | b0000011;
+ args_disass:"x%rd$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1]+imm;
+ if(rd!=0) X[rd]<=sext(MEM[offs]);
+ }
+ LH {
+ encoding: imm[11:0]s | rs1[4:0] | b001 | rd[4:0] | b0000011;
+ args_disass:"x%rd$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1]+imm;
+ if(rd!=0) X[rd]<=sext(MEM[offs]{16});
+ }
+ LW {
+ encoding: imm[11:0]s | rs1[4:0] | b010 | rd[4:0] | b0000011;
+ args_disass:"x%rd$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1]+imm;
+ if(rd!=0) X[rd]<=sext(MEM[offs]{32});
+ }
+ LBU {
+ encoding: imm[11:0]s | rs1[4:0] | b100 | rd[4:0] | b0000011;
+ args_disass:"x%rd$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1]+imm;
+ if(rd!=0) X[rd]<=zext(MEM[offs]);
+ }
+ LHU {
+ encoding: imm[11:0]s | rs1[4:0] | b101 | rd[4:0] | b0000011;
+ args_disass:"x%rd$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1]+imm;
+ if(rd!=0) X[rd]<=zext(MEM[offs]{16});
+ }
+ SB {
+ encoding: imm[11:5]s | rs2[4:0] | rs1[4:0] | b000 | imm[4:0]s | b0100011;
+ args_disass:"x%rs2$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1] + imm;
+ MEM[offs] <= X[rs2];
+ }
+ SH {
+ encoding: imm[11:5]s | rs2[4:0] | rs1[4:0] | b001 | imm[4:0]s | b0100011;
+ args_disass:"x%rs2$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1] + imm;
+ MEM[offs]{16} <= X[rs2];
+ }
+ SW {
+ encoding: imm[11:5]s | rs2[4:0] | rs1[4:0] | b010 | imm[4:0]s | b0100011;
+ args_disass:"x%rs2$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1] + imm;
+ MEM[offs]{32} <= X[rs2];
+ }
+ ADDI {
+ encoding: imm[11:0]s | rs1[4:0] | b000 | rd[4:0] | b0010011;
+ args_disass:"x%rd$d, x%rs1$d, %imm%";
+ if(rd != 0) X[rd] <= X[rs1] + imm;
+ }
+ SLTI {
+ encoding: imm[11:0]s | rs1[4:0] | b010 | rd[4:0] | b0010011;
+ args_disass:"x%rd$d, x%rs1$d, %imm%";
+ if (rd != 0) X[rd] <= choose(X[rs1]s < imm's, 1, 0);
+ }
+ SLTIU {
+ encoding: imm[11:0]s | rs1[4:0] | b011 | rd[4:0] | b0010011;
+ args_disass:"x%rd$d, x%rs1$d, %imm%";
+ val full_imm[XLEN] <= imm's;
+ if (rd != 0) X[rd] <= choose(X[rs1]'u < full_imm'u, 1, 0);
+ }
+ XORI {
+ encoding: imm[11:0]s | rs1[4:0] | b100 | rd[4:0] | b0010011;
+ args_disass:"x%rd$d, x%rs1$d, %imm%";
+ if(rd != 0) X[rd] <= X[rs1] ^ imm;
+ }
+ ORI {
+ encoding: imm[11:0]s | rs1[4:0] | b110 | rd[4:0] | b0010011;
+ args_disass:"x%rd$d, x%rs1$d, %imm%";
+ if(rd != 0) X[rd] <= X[rs1] | imm;
+ }
+ ANDI {
+ encoding: imm[11:0]s | rs1[4:0] | b111 | rd[4:0] | b0010011;
+ args_disass:"x%rd$d, x%rs1$d, %imm%";
+ if(rd != 0) X[rd] <= X[rs1] & imm;
+ }
+ SLLI {
+ encoding: b0000000 | shamt[4:0] | rs1[4:0] | b001 | rd[4:0] | b0010011;
+ args_disass:"x%rd$d, x%rs1$d, %shamt%";
if(shamt > 31){
raise(0,0);
} else {
- if(rd != 0) X[rd] <= shrl(X[rs1], shamt);
- }
- }
- SRAI {
- encoding: b0100000 | shamt[4:0] | rs1[4:0] | b101 | rd[4:0] | b0010011;
- args_disass:"x%rd$d, x%rs1$d, %shamt%";
- if(shamt > 31){
+ if(rd != 0) X[rd] <= shll(X[rs1], shamt);
+ }
+ }
+ SRLI {
+ encoding: b0000000 | shamt[4:0] | rs1[4:0] | b101 | rd[4:0] | b0010011;
+ args_disass:"x%rd$d, x%rs1$d, %shamt%";
+ if(shamt > 31){
raise(0,0);
} else {
- if(rd != 0) X[rd] <= shra(X[rs1], shamt);
- }
- }
- ADD {
- encoding: b0000000 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0) X[rd] <= X[rs1] + X[rs2];
- }
- SUB {
- encoding: b0100000 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0) X[rd] <= X[rs1] - X[rs2];
- }
- SLL {
- encoding: b0000000 | rs2[4:0] | rs1[4:0] | b001 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0) X[rd] <= shll(X[rs1], X[rs2]&XLEN_BIT_MASK);
- }
- SLT {
- encoding: b0000000 | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if (rd != 0) X[rd] <= choose(X[rs1]s < X[rs2]s, 1, 0);
- }
- SLTU {
- encoding: b0000000 | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if (rd != 0) X[rd] <= choose(zext(X[rs1]) < zext(X[rs2]), 1, 0);
- }
- XOR {
- encoding: b0000000 | rs2[4:0] | rs1[4:0] | b100 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0) X[rd] <= X[rs1] ^ X[rs2];
- }
- SRL {
- encoding: b0000000 | rs2[4:0] | rs1[4:0] | b101 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0) X[rd] <= shrl(X[rs1], X[rs2]&XLEN_BIT_MASK);
- }
- SRA {
- encoding: b0100000 | rs2[4:0] | rs1[4:0] | b101 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0) X[rd] <= shra(X[rs1], X[rs2]&XLEN_BIT_MASK);
- }
- OR {
- encoding: b0000000 | rs2[4:0] | rs1[4:0] | b110 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0) X[rd] <= X[rs1] | X[rs2];
- }
- AND {
- encoding: b0000000 | rs2[4:0] | rs1[4:0] | b111 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0) X[rd] <= X[rs1] & X[rs2];
- }
- FENCE {
- encoding: b0000 | pred[3:0] | succ[3:0] | rs1[4:0] | b000 | rd[4:0] | b0001111;
- FENCE[fence] <= pred<<4 | succ;
- }
- FENCE_I(flush) {
- encoding: imm[11:0] | rs1[4:0] | b001 | rd[4:0] | b0001111 ;
- FENCE[fencei] <= imm;
- }
- ECALL(no_cont) {
- encoding: b000000000000 | b00000 | b000 | b00000 | b1110011;
- raise(0, 11);
- }
- EBREAK(no_cont) {
- encoding: b000000000001 | b00000 | b000 | b00000 | b1110011;
- raise(0, 3);
- }
- URET(no_cont) {
- encoding: b0000000 | b00010 | b00000 | b000 | b00000 | b1110011;
- leave(0);
- }
- SRET(no_cont) {
- encoding: b0001000 | b00010 | b00000 | b000 | b00000 | b1110011;
- leave(1);
- }
- MRET(no_cont) {
- encoding: b0011000 | b00010 | b00000 | b000 | b00000 | b1110011;
- leave(3);
- }
- WFI {
- encoding: b0001000 | b00101 | b00000 | b000 | b00000 | b1110011;
- wait(1);
- }
- SFENCE.VMA {
- encoding: b0001001 | rs2[4:0] | rs1[4:0] | b000 | b00000 | b1110011;
- FENCE[fencevmal] <= rs1;
- FENCE[fencevmau] <= rs2;
- }
- CSRRW {
- encoding: csr[11:0] | rs1[4:0] | b001 | rd[4:0] | b1110011;
- args_disass:"x%rd$d, %csr$d, x%rs1$d";
+ if(rd != 0) X[rd] <= shrl(X[rs1], shamt);
+ }
+ }
+ SRAI {
+ encoding: b0100000 | shamt[4:0] | rs1[4:0] | b101 | rd[4:0] | b0010011;
+ args_disass:"x%rd$d, x%rs1$d, %shamt%";
+ if(shamt > 31){
+ raise(0,0);
+ } else {
+ if(rd != 0) X[rd] <= shra(X[rs1], shamt);
+ }
+ }
+ ADD {
+ encoding: b0000000 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0) X[rd] <= X[rs1] + X[rs2];
+ }
+ SUB {
+ encoding: b0100000 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0) X[rd] <= X[rs1] - X[rs2];
+ }
+ SLL {
+ encoding: b0000000 | rs2[4:0] | rs1[4:0] | b001 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0) X[rd] <= shll(X[rs1], X[rs2]&XLEN_BIT_MASK);
+ }
+ SLT {
+ encoding: b0000000 | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if (rd != 0) X[rd] <= choose(X[rs1]s < X[rs2]s, 1, 0);
+ }
+ SLTU {
+ encoding: b0000000 | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if (rd != 0) X[rd] <= choose(zext(X[rs1]) < zext(X[rs2]), 1, 0);
+ }
+ XOR {
+ encoding: b0000000 | rs2[4:0] | rs1[4:0] | b100 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0) X[rd] <= X[rs1] ^ X[rs2];
+ }
+ SRL {
+ encoding: b0000000 | rs2[4:0] | rs1[4:0] | b101 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0) X[rd] <= shrl(X[rs1], X[rs2]&XLEN_BIT_MASK);
+ }
+ SRA {
+ encoding: b0100000 | rs2[4:0] | rs1[4:0] | b101 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0) X[rd] <= shra(X[rs1], X[rs2]&XLEN_BIT_MASK);
+ }
+ OR {
+ encoding: b0000000 | rs2[4:0] | rs1[4:0] | b110 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0) X[rd] <= X[rs1] | X[rs2];
+ }
+ AND {
+ encoding: b0000000 | rs2[4:0] | rs1[4:0] | b111 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0) X[rd] <= X[rs1] & X[rs2];
+ }
+ FENCE {
+ encoding: b0000 | pred[3:0] | succ[3:0] | rs1[4:0] | b000 | rd[4:0] | b0001111;
+ FENCE[fence] <= pred<<4 | succ;
+ }
+ FENCE_I(flush) {
+ encoding: imm[11:0] | rs1[4:0] | b001 | rd[4:0] | b0001111 ;
+ FENCE[fencei] <= imm;
+ }
+ ECALL(no_cont) {
+ encoding: b000000000000 | b00000 | b000 | b00000 | b1110011;
+ raise(0, 11);
+ }
+ EBREAK(no_cont) {
+ encoding: b000000000001 | b00000 | b000 | b00000 | b1110011;
+ raise(0, 3);
+ }
+ URET(no_cont) {
+ encoding: b0000000 | b00010 | b00000 | b000 | b00000 | b1110011;
+ leave(0);
+ }
+ SRET(no_cont) {
+ encoding: b0001000 | b00010 | b00000 | b000 | b00000 | b1110011;
+ leave(1);
+ }
+ MRET(no_cont) {
+ encoding: b0011000 | b00010 | b00000 | b000 | b00000 | b1110011;
+ leave(3);
+ }
+ WFI {
+ encoding: b0001000 | b00101 | b00000 | b000 | b00000 | b1110011;
+ wait(1);
+ }
+ SFENCE.VMA {
+ encoding: b0001001 | rs2[4:0] | rs1[4:0] | b000 | b00000 | b1110011;
+ FENCE[fencevmal] <= rs1;
+ FENCE[fencevmau] <= rs2;
+ }
+ CSRRW {
+ encoding: csr[11:0] | rs1[4:0] | b001 | rd[4:0] | b1110011;
+ args_disass:"x%rd$d, %csr$d, x%rs1$d";
val rs_val[XLEN] <= X[rs1];
- if(rd!=0){
- val csr_val[XLEN] <= CSR[csr];
+ if(rd!=0){
+ val csr_val[XLEN] <= CSR[csr];
CSR[csr] <= rs_val;
// make sure Xrd is updated once CSR write succeeds
- X[rd] <= csr_val;
- } else {
- CSR[csr] <= rs_val;
- }
- }
- CSRRS {
- encoding: csr[11:0] | rs1[4:0] | b010 | rd[4:0] | b1110011;
- args_disass:"x%rd$d, %csr$d, x%rs1$d";
- val xrd[XLEN] <= CSR[csr];
- val xrs1[XLEN] <= X[rs1];
- if(rd!=0) X[rd] <= xrd;
- if(rs1!=0) CSR[csr] <= xrd | xrs1;
- }
- CSRRC {
- encoding: csr[11:0] | rs1[4:0] | b011 | rd[4:0] | b1110011;
- args_disass:"x%rd$d, %csr$d, x%rs1$d";
- val xrd[XLEN] <= CSR[csr];
- val xrs1[XLEN] <= X[rs1];
- if(rd!=0) X[rd] <= xrd;
- if(rs1!=0) CSR[csr] <= xrd & ~xrs1;
- }
- CSRRWI {
- encoding: csr[11:0] | zimm[4:0] | b101 | rd[4:0] | b1110011;
- args_disass:"x%rd$d, %csr$d, 0x%zimm$x";
- if(rd!=0) X[rd] <= CSR[csr];
- CSR[csr] <= zext(zimm);
- }
- CSRRSI {
- encoding: csr[11:0] | zimm[4:0] | b110 | rd[4:0] | b1110011;
- args_disass:"x%rd$d, %csr$d, 0x%zimm$x";
- val res[XLEN] <= CSR[csr];
- if(zimm!=0) CSR[csr] <= res | zext(zimm);
- // make sure rd is written after csr write succeeds
+ X[rd] <= csr_val;
+ } else {
+ CSR[csr] <= rs_val;
+ }
+ }
+ CSRRS {
+ encoding: csr[11:0] | rs1[4:0] | b010 | rd[4:0] | b1110011;
+ args_disass:"x%rd$d, %csr$d, x%rs1$d";
+ val xrd[XLEN] <= CSR[csr];
+ val xrs1[XLEN] <= X[rs1];
+ if(rd!=0) X[rd] <= xrd;
+ if(rs1!=0) CSR[csr] <= xrd | xrs1;
+ }
+ CSRRC {
+ encoding: csr[11:0] | rs1[4:0] | b011 | rd[4:0] | b1110011;
+ args_disass:"x%rd$d, %csr$d, x%rs1$d";
+ val xrd[XLEN] <= CSR[csr];
+ val xrs1[XLEN] <= X[rs1];
+ if(rd!=0) X[rd] <= xrd;
+ if(rs1!=0) CSR[csr] <= xrd & ~xrs1;
+ }
+ CSRRWI {
+ encoding: csr[11:0] | zimm[4:0] | b101 | rd[4:0] | b1110011;
+ args_disass:"x%rd$d, %csr$d, 0x%zimm$x";
+ if(rd!=0) X[rd] <= CSR[csr];
+ CSR[csr] <= zext(zimm);
+ }
+ CSRRSI {
+ encoding: csr[11:0] | zimm[4:0] | b110 | rd[4:0] | b1110011;
+ args_disass:"x%rd$d, %csr$d, 0x%zimm$x";
+ val res[XLEN] <= CSR[csr];
+ if(zimm!=0) CSR[csr] <= res | zext(zimm);
+ // make sure rd is written after csr write succeeds
if(rd!=0) X[rd] <= res;
- }
- CSRRCI {
- encoding: csr[11:0] | zimm[4:0] | b111 | rd[4:0] | b1110011;
- args_disass:"x%rd$d, %csr$d, 0x%zimm$x";
- val res[XLEN] <= CSR[csr];
- if(rd!=0) X[rd] <= res;
- if(zimm!=0) CSR[csr] <= res & ~zext(zimm, XLEN);
- }
- }
+ }
+ CSRRCI {
+ encoding: csr[11:0] | zimm[4:0] | b111 | rd[4:0] | b1110011;
+ args_disass:"x%rd$d, %csr$d, 0x%zimm$x";
+ val res[XLEN] <= CSR[csr];
+ if(rd!=0) X[rd] <= res;
+ if(zimm!=0) CSR[csr] <= res & ~zext(zimm, XLEN);
+ }
+ }
}
diff --git a/riscv/gen_input/RV32M.core_desc b/riscv/gen_input/RV32M.core_desc
index 2296923..a115295 100644
--- a/riscv/gen_input/RV32M.core_desc
+++ b/riscv/gen_input/RV32M.core_desc
@@ -1,97 +1,97 @@
import "RV32IBase.core_desc"
InsructionSet RV32M extends RV32IBase {
- constants {
- MAXLEN:=128
- }
- instructions{
- MUL{
- encoding: b0000001 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
- val res[MAXLEN] <= zext(X[rs1], MAXLEN) * zext(X[rs2], MAXLEN);
- X[rd]<= zext(res , XLEN);
- }
- }
- MULH {
- encoding: b0000001 | rs2[4:0] | rs1[4:0] | b001 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
- val res[MAXLEN] <= sext(X[rs1], MAXLEN) * sext(X[rs2], MAXLEN);
+ constants {
+ MAXLEN:=128
+ }
+ instructions{
+ MUL{
+ encoding: b0000001 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
+ val res[MAXLEN] <= zext(X[rs1], MAXLEN) * zext(X[rs2], MAXLEN);
+ X[rd]<= zext(res , XLEN);
+ }
+ }
+ MULH {
+ encoding: b0000001 | rs2[4:0] | rs1[4:0] | b001 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
+ val res[MAXLEN] <= sext(X[rs1], MAXLEN) * sext(X[rs2], MAXLEN);
X[rd]<= zext(res >> XLEN, XLEN);
- }
- }
- MULHSU {
- encoding: b0000001 | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
+ }
+ }
+ MULHSU {
+ encoding: b0000001 | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
val res[MAXLEN] <= sext(X[rs1], MAXLEN) * zext(X[rs2], MAXLEN);
X[rd]<= zext(res >> XLEN, XLEN);
- }
- }
- MULHU {
- encoding: b0000001 | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
+ }
+ }
+ MULHU {
+ encoding: b0000001 | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
val res[MAXLEN] <= zext(X[rs1], MAXLEN) * zext(X[rs2], MAXLEN);
X[rd]<= zext(res >> XLEN, XLEN);
- }
- }
- DIV {
- encoding: b0000001 | rs2[4:0] | rs1[4:0] | b100 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
- if(X[rs2]!=0){
- val M1[XLEN] <= -1;
- val MMIN[XLEN] <= -1<<(XLEN-1);
- if(X[rs1]s==MMIN's)
- if(X[rs2]s==M1's)
- X[rd]<=MMIN;
- else
- X[rd] <= X[rs1]s / X[rs2]s;
- else
- X[rd] <= X[rs1]s / X[rs2]s;
- }else
- X[rd] <= -1;
- }
- }
- DIVU {
- encoding: b0000001 | rs2[4:0] | rs1[4:0] | b101 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
- if(X[rs2]!=0)
- X[rd] <= zext(X[rs1], 32) / zext(X[rs2], 32);
- else
- X[rd] <= -1;
- }
- }
- REM {
- encoding: b0000001 | rs2[4:0] | rs1[4:0] | b110 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
- if(X[rs2]!=0) {
- val M1[XLEN] <= -1;
- val MMIN[XLEN] <= -1<<(XLEN-1);
- if(X[rs1]s==MMIN's)
- if(X[rs2]s==M1's)
- X[rd] <= 0;
- else
- X[rd] <= sext(X[rs1], 32) % sext(X[rs2], 32);
- else
- X[rd] <= sext(X[rs1], 32) % sext(X[rs2], 32);
- } else
- X[rd] <= X[rs1];
- }
- }
- REMU {
- encoding: b0000001 | rs2[4:0] | rs1[4:0] | b111 | rd[4:0] | b0110011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
- if(X[rs2]!=0)
- X[rd] <= zext(X[rs1], 32) % zext(X[rs2], 32);
- else
- X[rd] <= X[rs1];
- }
- }
- }
+ }
+ }
+ DIV {
+ encoding: b0000001 | rs2[4:0] | rs1[4:0] | b100 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
+ if(X[rs2]!=0){
+ val M1[XLEN] <= -1;
+ val MMIN[XLEN] <= -1<<(XLEN-1);
+ if(X[rs1]s==MMIN's)
+ if(X[rs2]s==M1's)
+ X[rd]<=MMIN;
+ else
+ X[rd] <= X[rs1]s / X[rs2]s;
+ else
+ X[rd] <= X[rs1]s / X[rs2]s;
+ }else
+ X[rd] <= -1;
+ }
+ }
+ DIVU {
+ encoding: b0000001 | rs2[4:0] | rs1[4:0] | b101 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
+ if(X[rs2]!=0)
+ X[rd] <= zext(X[rs1], 32) / zext(X[rs2], 32);
+ else
+ X[rd] <= -1;
+ }
+ }
+ REM {
+ encoding: b0000001 | rs2[4:0] | rs1[4:0] | b110 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
+ if(X[rs2]!=0) {
+ val M1[XLEN] <= -1;
+ val MMIN[XLEN] <= -1<<(XLEN-1);
+ if(X[rs1]s==MMIN's)
+ if(X[rs2]s==M1's)
+ X[rd] <= 0;
+ else
+ X[rd] <= sext(X[rs1], 32) % sext(X[rs2], 32);
+ else
+ X[rd] <= sext(X[rs1], 32) % sext(X[rs2], 32);
+ } else
+ X[rd] <= X[rs1];
+ }
+ }
+ REMU {
+ encoding: b0000001 | rs2[4:0] | rs1[4:0] | b111 | rd[4:0] | b0110011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
+ if(X[rs2]!=0)
+ X[rd] <= zext(X[rs1], 32) % zext(X[rs2], 32);
+ else
+ X[rd] <= X[rs1];
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/riscv/gen_input/RV64A.core_desc b/riscv/gen_input/RV64A.core_desc
index 91ffb3d..5080d11 100644
--- a/riscv/gen_input/RV64A.core_desc
+++ b/riscv/gen_input/RV64A.core_desc
@@ -2,111 +2,111 @@ import "RV64IBase.core_desc"
import "RV32A.core_desc"
InsructionSet RV64A extends RV64IBase {
-
- address_spaces {
- RES[8]
- }
-
- instructions{
- LR.D {
- encoding: b00010 | aq[0:0] | rl[0:0] | b00000 | rs1[4:0] | b011 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d";
- if(rd!=0){
- val offs[XLEN] <= X[rs1];
- X[rd]<= sext(MEM[offs]{64}, XLEN);
- RES[offs]{64}<=sext(-1, 64);
- }
- }
- SC.D {
- encoding: b00011 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d";
- val offs[XLEN] <= X[rs1];
- val res[64] <= RES[offs];
- if(res!=0){
- MEM[offs]{64} <= X[rs2];
- if(rd!=0) X[rd]<=0;
- } else{
- if(rd!=0) X[rd]<= 1;
- }
- }
- AMOSWAP.D{
- encoding: b00001 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
- val offs[XLEN] <= X[rs1];
- if(rd!=0) X[rd] <= sext(MEM[offs]{64});
- MEM[offs]{64} <= X[rs2];
- }
- AMOADD.D{
- encoding: b00000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
- val offs[XLEN] <= X[rs1];
- val res[XLEN] <= sext(MEM[offs]{64});
- if(rd!=0) X[rd]<=res;
- val res2[XLEN] <= res + X[rs2];
- MEM[offs]{64}<=res2;
- }
- AMOXOR.D{
- encoding: b00100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
- val offs[XLEN] <= X[rs1];
- val res[XLEN] <= sext(MEM[offs]{64});
- if(rd!=0) X[rd] <= res;
- val res2[XLEN] <= res ^ X[rs2];
- MEM[offs]{64} <= res2;
- }
- AMOAND.D{
- encoding: b01100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
- val offs[XLEN] <= X[rs1];
- val res[XLEN] <= sext(MEM[offs]{64});
- if(rd!=0) X[rd] <= res;
- val res2[XLEN] <= res & X[rs2];
- MEM[offs]{64} <= res2;
- }
- AMOOR.D {
- encoding: b01000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
- val offs[XLEN] <= X[rs1];
- val res[XLEN] <= sext(MEM[offs]{64});
- if(rd!=0) X[rd] <= res;
- val res2[XLEN] <= res | X[rs2];
- MEM[offs]{64} <= res2;
- }
- AMOMIN.D{
- encoding: b10000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
- val offs[XLEN] <= X[rs1];
- val res[XLEN] <= sext(MEM[offs]{64});
- if(rd!=0) X[rd] <= res;
- val res2[XLEN] <= choose(res s > X[rs2]s, X[rs2], res);
- MEM[offs]{64} <= res;
- }
- AMOMAX.D{
- encoding: b10100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
- val offs[XLEN] <= X[rs1];
- val res[XLEN] <= sext(MEM[offs]{64});
- if(rd!=0) X[rd] <= res;
- val res2[XLEN] <= choose(res s < X[rs2]s, X[rs2], res);
- MEM[offs]{64} <= res2;
- }
- AMOMINU.D{
- encoding: b11000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
- val offs[XLEN] <= X[rs1];
- val res[XLEN] <= zext(MEM[offs]{64});
- if(rd!=0) X[rd] <= res;
- val res2[XLEN] <= choose(res > X[rs2], X[rs2], res);
- MEM[offs]{64} <= res2;
- }
- AMOMAXU.D{
- encoding: b11100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
- args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
- val offs[XLEN] <= X[rs1];
- val res[XLEN] <= zext(MEM[offs]{64});
- if(rd!=0) X[rd] <= res;
- val res2[XLEN] <= choose(res < X[rs2], X[rs2], res);
- MEM[offs]{64} <= res2;
- }
- }
+
+ address_spaces {
+ RES[8]
+ }
+
+ instructions{
+ LR.D {
+ encoding: b00010 | aq[0:0] | rl[0:0] | b00000 | rs1[4:0] | b011 | rd[4:0] | b0101111;
+ args_disass: "x%rd$d, x%rs1$d";
+ if(rd!=0){
+ val offs[XLEN] <= X[rs1];
+ X[rd]<= sext(MEM[offs]{64}, XLEN);
+ RES[offs]{64}<=sext(-1, 64);
+ }
+ }
+ SC.D {
+ encoding: b00011 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
+ args_disass: "x%rd$d, x%rs1$d, x%rs2$d";
+ val offs[XLEN] <= X[rs1];
+ val res[64] <= RES[offs];
+ if(res!=0){
+ MEM[offs]{64} <= X[rs2];
+ if(rd!=0) X[rd]<=0;
+ } else{
+ if(rd!=0) X[rd]<= 1;
+ }
+ }
+ AMOSWAP.D{
+ encoding: b00001 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
+ args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
+ val offs[XLEN] <= X[rs1];
+ if(rd!=0) X[rd] <= sext(MEM[offs]{64});
+ MEM[offs]{64} <= X[rs2];
+ }
+ AMOADD.D{
+ encoding: b00000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
+ args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
+ val offs[XLEN] <= X[rs1];
+ val res[XLEN] <= sext(MEM[offs]{64});
+ if(rd!=0) X[rd]<=res;
+ val res2[XLEN] <= res + X[rs2];
+ MEM[offs]{64}<=res2;
+ }
+ AMOXOR.D{
+ encoding: b00100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
+ args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
+ val offs[XLEN] <= X[rs1];
+ val res[XLEN] <= sext(MEM[offs]{64});
+ if(rd!=0) X[rd] <= res;
+ val res2[XLEN] <= res ^ X[rs2];
+ MEM[offs]{64} <= res2;
+ }
+ AMOAND.D{
+ encoding: b01100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
+ args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
+ val offs[XLEN] <= X[rs1];
+ val res[XLEN] <= sext(MEM[offs]{64});
+ if(rd!=0) X[rd] <= res;
+ val res2[XLEN] <= res & X[rs2];
+ MEM[offs]{64} <= res2;
+ }
+ AMOOR.D {
+ encoding: b01000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
+ args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
+ val offs[XLEN] <= X[rs1];
+ val res[XLEN] <= sext(MEM[offs]{64});
+ if(rd!=0) X[rd] <= res;
+ val res2[XLEN] <= res | X[rs2];
+ MEM[offs]{64} <= res2;
+ }
+ AMOMIN.D{
+ encoding: b10000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
+ args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
+ val offs[XLEN] <= X[rs1];
+ val res[XLEN] <= sext(MEM[offs]{64});
+ if(rd!=0) X[rd] <= res;
+ val res2[XLEN] <= choose(res s > X[rs2]s, X[rs2], res);
+ MEM[offs]{64} <= res;
+ }
+ AMOMAX.D{
+ encoding: b10100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
+ args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
+ val offs[XLEN] <= X[rs1];
+ val res[XLEN] <= sext(MEM[offs]{64});
+ if(rd!=0) X[rd] <= res;
+ val res2[XLEN] <= choose(res s < X[rs2]s, X[rs2], res);
+ MEM[offs]{64} <= res2;
+ }
+ AMOMINU.D{
+ encoding: b11000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
+ args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
+ val offs[XLEN] <= X[rs1];
+ val res[XLEN] <= zext(MEM[offs]{64});
+ if(rd!=0) X[rd] <= res;
+ val res2[XLEN] <= choose(res > X[rs2], X[rs2], res);
+ MEM[offs]{64} <= res2;
+ }
+ AMOMAXU.D{
+ encoding: b11100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b011 | rd[4:0] | b0101111;
+ args_disass: "x%rd$d, x%rs1$d, x%rs2$d (aqu=%a,rel=%rl)";
+ val offs[XLEN] <= X[rs1];
+ val res[XLEN] <= zext(MEM[offs]{64});
+ if(rd!=0) X[rd] <= res;
+ val res2[XLEN] <= choose(res < X[rs2], X[rs2], res);
+ MEM[offs]{64} <= res2;
+ }
+ }
}
\ No newline at end of file
diff --git a/riscv/gen_input/RV64IBase.core_desc b/riscv/gen_input/RV64IBase.core_desc
index 013b716..00bcaf0 100644
--- a/riscv/gen_input/RV64IBase.core_desc
+++ b/riscv/gen_input/RV64IBase.core_desc
@@ -1,116 +1,116 @@
import "RV32IBase.core_desc"
InsructionSet RV64IBase extends RV32IBase {
- instructions{
- LWU { // 80000104: 0000ef03 lwu t5,0(ra)
- encoding: imm[11:0]s | rs1[4:0] | b110 | rd[4:0] | b0000011;
- args_disass:"x%rd$d, %imm%(x%rs1$d)";
- val offs[XLEN] <= X[rs1]+imm;
- if(rd!=0) X[rd]<=zext(MEM[offs]{32});
- }
- LD{
- encoding: imm[11:0]s | rs1[4:0] | b011 | rd[4:0] | b0000011;
- args_disass:"x%rd$d, %imm%(x%rs1$d)";
- val offs[XLEN] <= X[rs1]+imm;
- if(rd!=0) X[rd]<=sext(MEM[offs]{64});
- }
- SD{
- encoding: imm[11:5]s | rs2[4:0] | rs1[4:0] | b011 | imm[4:0]s | b0100011;
- args_disass:"x%rs2$d, %imm%(x%rs1$d)";
- val offs[XLEN] <= X[rs1] + imm;
- MEM[offs]{64} <= X[rs2];
- }
- SLLI {
- encoding: b000000 | shamt[5:0] | rs1[4:0] | b001 | rd[4:0] | b0010011;
- args_disass:"x%rd$d, x%rs1$d, %shamt%";
- if(rd != 0) X[rd] <= shll(X[rs1], shamt);
- }
- SRLI {
- encoding: b000000 | shamt[5:0] | rs1[4:0] | b101 | rd[4:0] | b0010011;
- args_disass:"x%rd$d, x%rs1$d, %shamt%";
- if(rd != 0) X[rd] <= shrl(X[rs1], shamt);
- }
- SRAI {
- encoding: b010000 | shamt[5:0] | rs1[4:0] | b101 | rd[4:0] | b0010011;
- args_disass:"x%rd$d, x%rs1$d, %shamt%";
- if(rd != 0) X[rd] <= shra(X[rs1], shamt);
- }
- ADDIW {
- encoding: imm[11:0]s | rs1[4:0] | b000 | rd[4:0] | b0011011;
- args_disass:"x%rd$d, x%rs1$d, %imm%";
- if(rd != 0){
- val res[32] <= X[rs1]{32} + imm;
- X[rd] <= sext(res);
- }
- }
- SLLIW {
- encoding: b0000000 | shamt[4:0] | rs1[4:0] | b001 | rd[4:0] | b0011011;
- args_disass:"x%rd$d, x%rs1$d, %shamt%";
- if(rd != 0){
- val sh_val[32] <= shll(X[rs1]{32}, shamt);
- X[rd] <= sext(sh_val);
- }
- }
- SRLIW {
- encoding: b0000000 | shamt[4:0] | rs1[4:0] | b101 | rd[4:0] | b0011011;
- args_disass:"x%rd$d, x%rs1$d, %shamt%";
- if(rd != 0){
- val sh_val[32] <= shrl(X[rs1]{32}, shamt);
- X[rd] <= sext(sh_val);
- }
- }
- SRAIW {
- encoding: b0100000 | shamt[4:0] | rs1[4:0] | b101 | rd[4:0] | b0011011;
- args_disass:"x%rd$d, x%rs1$d, %shamt%";
- if(rd != 0){
- val sh_val[32] <= shra(X[rs1]{32}, shamt);
- X[rd] <= sext(sh_val);
- }
- }
- ADDW {
- encoding: b0000000 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b0111011;
- if(rd != 0){
- val res[32] <= X[rs1]{32} + X[rs2]{32};
- X[rd] <= sext(res);
- }
- }
- SUBW {
- encoding: b0100000 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b0111011;
- if(rd != 0){
- val res[32] <= X[rs1]{32} - X[rs2]{32};
- X[rd] <= sext(res);
- }
- }
- SLLW {
- encoding: b0000000 | rs2[4:0] | rs1[4:0] | b001 | rd[4:0] | b0111011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
- val mask[32] <= 0x1f;
- val count[32] <= X[rs2]{32} & mask;
- val sh_val[32] <= shll(X[rs1]{32}, count);
- X[rd] <= sext(sh_val);
- }
- }
- SRLW {
- encoding: b0000000 | rs2[4:0] | rs1[4:0] | b101 | rd[4:0] | b0111011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
+ instructions{
+ LWU { // 80000104: 0000ef03 lwu t5,0(ra)
+ encoding: imm[11:0]s | rs1[4:0] | b110 | rd[4:0] | b0000011;
+ args_disass:"x%rd$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1]+imm;
+ if(rd!=0) X[rd]<=zext(MEM[offs]{32});
+ }
+ LD{
+ encoding: imm[11:0]s | rs1[4:0] | b011 | rd[4:0] | b0000011;
+ args_disass:"x%rd$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1]+imm;
+ if(rd!=0) X[rd]<=sext(MEM[offs]{64});
+ }
+ SD{
+ encoding: imm[11:5]s | rs2[4:0] | rs1[4:0] | b011 | imm[4:0]s | b0100011;
+ args_disass:"x%rs2$d, %imm%(x%rs1$d)";
+ val offs[XLEN] <= X[rs1] + imm;
+ MEM[offs]{64} <= X[rs2];
+ }
+ SLLI {
+ encoding: b000000 | shamt[5:0] | rs1[4:0] | b001 | rd[4:0] | b0010011;
+ args_disass:"x%rd$d, x%rs1$d, %shamt%";
+ if(rd != 0) X[rd] <= shll(X[rs1], shamt);
+ }
+ SRLI {
+ encoding: b000000 | shamt[5:0] | rs1[4:0] | b101 | rd[4:0] | b0010011;
+ args_disass:"x%rd$d, x%rs1$d, %shamt%";
+ if(rd != 0) X[rd] <= shrl(X[rs1], shamt);
+ }
+ SRAI {
+ encoding: b010000 | shamt[5:0] | rs1[4:0] | b101 | rd[4:0] | b0010011;
+ args_disass:"x%rd$d, x%rs1$d, %shamt%";
+ if(rd != 0) X[rd] <= shra(X[rs1], shamt);
+ }
+ ADDIW {
+ encoding: imm[11:0]s | rs1[4:0] | b000 | rd[4:0] | b0011011;
+ args_disass:"x%rd$d, x%rs1$d, %imm%";
+ if(rd != 0){
+ val res[32] <= X[rs1]{32} + imm;
+ X[rd] <= sext(res);
+ }
+ }
+ SLLIW {
+ encoding: b0000000 | shamt[4:0] | rs1[4:0] | b001 | rd[4:0] | b0011011;
+ args_disass:"x%rd$d, x%rs1$d, %shamt%";
+ if(rd != 0){
+ val sh_val[32] <= shll(X[rs1]{32}, shamt);
+ X[rd] <= sext(sh_val);
+ }
+ }
+ SRLIW {
+ encoding: b0000000 | shamt[4:0] | rs1[4:0] | b101 | rd[4:0] | b0011011;
+ args_disass:"x%rd$d, x%rs1$d, %shamt%";
+ if(rd != 0){
+ val sh_val[32] <= shrl(X[rs1]{32}, shamt);
+ X[rd] <= sext(sh_val);
+ }
+ }
+ SRAIW {
+ encoding: b0100000 | shamt[4:0] | rs1[4:0] | b101 | rd[4:0] | b0011011;
+ args_disass:"x%rd$d, x%rs1$d, %shamt%";
+ if(rd != 0){
+ val sh_val[32] <= shra(X[rs1]{32}, shamt);
+ X[rd] <= sext(sh_val);
+ }
+ }
+ ADDW {
+ encoding: b0000000 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b0111011;
+ if(rd != 0){
+ val res[32] <= X[rs1]{32} + X[rs2]{32};
+ X[rd] <= sext(res);
+ }
+ }
+ SUBW {
+ encoding: b0100000 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b0111011;
+ if(rd != 0){
+ val res[32] <= X[rs1]{32} - X[rs2]{32};
+ X[rd] <= sext(res);
+ }
+ }
+ SLLW {
+ encoding: b0000000 | rs2[4:0] | rs1[4:0] | b001 | rd[4:0] | b0111011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
val mask[32] <= 0x1f;
val count[32] <= X[rs2]{32} & mask;
- val sh_val[32] <= shrl(X[rs1]{32}, count);
- X[rd] <= sext(sh_val);
- }
- }
- SRAW {
- encoding: b0100000 | rs2[4:0] | rs1[4:0] | b101 | rd[4:0] | b0111011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
+ val sh_val[32] <= shll(X[rs1]{32}, count);
+ X[rd] <= sext(sh_val);
+ }
+ }
+ SRLW {
+ encoding: b0000000 | rs2[4:0] | rs1[4:0] | b101 | rd[4:0] | b0111011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
val mask[32] <= 0x1f;
val count[32] <= X[rs2]{32} & mask;
- val sh_val[32] <= shra(X[rs1]{32}, count);
- X[rd] <= sext(sh_val);
- }
- }
- }
+ val sh_val[32] <= shrl(X[rs1]{32}, count);
+ X[rd] <= sext(sh_val);
+ }
+ }
+ SRAW {
+ encoding: b0100000 | rs2[4:0] | rs1[4:0] | b101 | rd[4:0] | b0111011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
+ val mask[32] <= 0x1f;
+ val count[32] <= X[rs2]{32} & mask;
+ val sh_val[32] <= shra(X[rs1]{32}, count);
+ X[rd] <= sext(sh_val);
+ }
+ }
+ }
}
diff --git a/riscv/gen_input/RV64M.core_desc b/riscv/gen_input/RV64M.core_desc
index 32728bb..cb53da9 100644
--- a/riscv/gen_input/RV64M.core_desc
+++ b/riscv/gen_input/RV64M.core_desc
@@ -1,41 +1,41 @@
import "RV64IBase.core_desc"
InsructionSet RV64M extends RV64IBase {
- instructions{
- MULW{
- encoding: b0000001 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b0111011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
- X[rd]<= X[rs1] * X[rs2];
- }
- }
- DIVW {
- encoding: b0000001 | rs2[4:0] | rs1[4:0] | b100 | rd[4:0] | b0111011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
- X[rd] <= X[rs1]s / X[rs2]s;
- }
- }
- DIVUW {
- encoding: b0000001 | rs2[4:0] | rs1[4:0] | b101 | rd[4:0] | b0111011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
- X[rd] <= X[rs1] / X[rs2];
- }
- }
- REMW {
- encoding: b0000001 | rs2[4:0] | rs1[4:0] | b110 | rd[4:0] | b0111011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
- X[rd] <= X[rs1]s % X[rs2]s;
- }
- }
- REMUW {
- encoding: b0000001 | rs2[4:0] | rs1[4:0] | b111 | rd[4:0] | b0111011;
- args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
- if(rd != 0){
- X[rd] <= X[rs1] % X[rs2];
- }
- }
- }
+ instructions{
+ MULW{
+ encoding: b0000001 | rs2[4:0] | rs1[4:0] | b000 | rd[4:0] | b0111011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
+ X[rd]<= X[rs1] * X[rs2];
+ }
+ }
+ DIVW {
+ encoding: b0000001 | rs2[4:0] | rs1[4:0] | b100 | rd[4:0] | b0111011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
+ X[rd] <= X[rs1]s / X[rs2]s;
+ }
+ }
+ DIVUW {
+ encoding: b0000001 | rs2[4:0] | rs1[4:0] | b101 | rd[4:0] | b0111011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
+ X[rd] <= X[rs1] / X[rs2];
+ }
+ }
+ REMW {
+ encoding: b0000001 | rs2[4:0] | rs1[4:0] | b110 | rd[4:0] | b0111011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
+ X[rd] <= X[rs1]s % X[rs2]s;
+ }
+ }
+ REMUW {
+ encoding: b0000001 | rs2[4:0] | rs1[4:0] | b111 | rd[4:0] | b0111011;
+ args_disass:"x%rd$d, x%rs1$d, x%rs2$d";
+ if(rd != 0){
+ X[rd] <= X[rs1] % X[rs2];
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/riscv/gen_input/minres_rv.core_desc b/riscv/gen_input/minres_rv.core_desc
index b5d82fe..c0cb5f2 100644
--- a/riscv/gen_input/minres_rv.core_desc
+++ b/riscv/gen_input/minres_rv.core_desc
@@ -8,7 +8,6 @@ import "RV64IBase.core_desc"
//import "RV64M.core_desc"
import "RV64A.core_desc"
-
Core RV32IMAC provides RV32IBase, RV32M, RV32A, RV32IC {
template:"vm_riscv.in.cpp";
constants {
@@ -17,8 +16,8 @@ Core RV32IMAC provides RV32IBase, RV32M, RV32A, RV32IC {
// definitions for the architecture wrapper
// XL ZYXWVUTSRQPONMLKJIHGFEDCBA
MISA_VAL:=0b01000000000101000001000100000101;
- PGSIZE := 4096; //1 << 12;
- PGMASK := 4095; //PGSIZE-1
+ PGSIZE := 0x1000; //1 << 12;
+ PGMASK := 0xfff; //PGSIZE-1
}
}
@@ -30,8 +29,8 @@ Core RV32GC provides RV32IBase, RV32M, RV32A, RV32IC, RV32F, RV32FC, RV32D, RV32
// definitions for the architecture wrapper
// XL ZYXWVUTSRQPONMLKJIHGFEDCBA
MISA_VAL:=0b01000000000101000001000100101101;
- PGSIZE := 4096; //1 << 12;
- PGMASK := 4095; //PGSIZE-1
+ PGSIZE := 0x1000; //1 << 12;
+ PGMASK := 0xfff; //PGSIZE-1
}
}
@@ -44,7 +43,7 @@ Core RV64IA provides RV64IBase, RV64A, RV32A {
// definitions for the architecture wrapper
// XL ZYXWVUTSRQPONMLKJIHGFEDCBA
MISA_VAL:=0b10000000000001000000000100000001;
- PGSIZE := 4096; //1 << 12;
- PGMASK := 4095; //PGSIZE-1
+ PGSIZE := 0x1000; //1 << 12;
+ PGMASK := 0xfff; //PGSIZE-1
}
}
diff --git a/riscv/gen_input/templates/incl-CORENAME.h.gtl b/riscv/gen_input/templates/incl-CORENAME.h.gtl
index 5e53476..0b5ecb0 100644
--- a/riscv/gen_input/templates/incl-CORENAME.h.gtl
+++ b/riscv/gen_input/templates/incl-CORENAME.h.gtl
@@ -80,6 +80,8 @@ struct traits<${coreDef.name.toLowerCase()}> {
using addr_t = uint${addrDataWidth}_t;
+ using code_word_t = uint${addrDataWidth}_t; //TODO: check removal
+
using virt_addr_t = iss::typed_addr_t;
using phys_addr_t = iss::typed_addr_t;
diff --git a/riscv/gen_input/templates/vm-vm_CORENAME.cpp.gtl b/riscv/gen_input/templates/vm-vm_CORENAME.cpp.gtl
index d4552cc..6233125 100644
--- a/riscv/gen_input/templates/vm-vm_CORENAME.cpp.gtl
+++ b/riscv/gen_input/templates/vm-vm_CORENAME.cpp.gtl
@@ -320,6 +320,8 @@ template inline void vm_impl::gen_trap_check(llvm::BasicBl
bb, this->trap_blk, 1);
}
+} // namespace ${coreDef.name.toLowerCase()}
+
template <>
std::unique_ptr create(arch::${coreDef.name.toLowerCase()} *core, unsigned short port, bool dump) {
std::unique_ptr<${coreDef.name.toLowerCase()}::vm_impl> ret =
diff --git a/riscv/incl/iss/arch/rv32gc.h b/riscv/incl/iss/arch/rv32gc.h
index 0f9d93e..6fbc025 100644
--- a/riscv/incl/iss/arch/rv32gc.h
+++ b/riscv/incl/iss/arch/rv32gc.h
@@ -48,7 +48,7 @@ struct traits {
constexpr static char const* const core_type = "RV32GC";
- enum constants {XLEN=32, FLEN=64, PCLEN=32, MISA_VAL=1075056941, PGSIZE=4096, PGMASK=4095};
+ enum constants {XLEN=32, FLEN=64, PCLEN=32, MISA_VAL=0b1000000000101000001000100101101, PGSIZE=0x1000, PGMASK=0xfff};
constexpr static unsigned FP_REGS_SIZE = 64;
diff --git a/riscv/incl/iss/arch/rv32imac.h b/riscv/incl/iss/arch/rv32imac.h
index 571b758..923d16e 100644
--- a/riscv/incl/iss/arch/rv32imac.h
+++ b/riscv/incl/iss/arch/rv32imac.h
@@ -48,7 +48,7 @@ struct traits {
constexpr static char const* const core_type = "RV32IMAC";
- enum constants {XLEN=32, PCLEN=32, MISA_VAL=1075056901, PGSIZE=4096, PGMASK=4095};
+ enum constants {XLEN=32, PCLEN=32, MISA_VAL=0b1000000000101000001000100000101, PGSIZE=0x1000, PGMASK=0xfff};
constexpr static unsigned FP_REGS_SIZE = 0;
diff --git a/riscv/incl/iss/arch/rv64ia.h b/riscv/incl/iss/arch/rv64ia.h
index 10a8989..51fc774 100644
--- a/riscv/incl/iss/arch/rv64ia.h
+++ b/riscv/incl/iss/arch/rv64ia.h
@@ -48,7 +48,7 @@ struct traits {
constexpr static char const* const core_type = "RV64IA";
- enum constants {XLEN=64, PCLEN=64, MISA_VAL=2147746049, PGSIZE=4096, PGMASK=4095};
+ enum constants {XLEN=64, PCLEN=64, MISA_VAL=0b10000000000001000000000100000001, PGSIZE=0x1000, PGMASK=0xfff};
constexpr static unsigned FP_REGS_SIZE = 0;
diff --git a/riscv/src/internal/vm_rv32gc.cpp b/riscv/src/internal/vm_rv32gc.cpp
index 5514005..d33bf1b 100644
--- a/riscv/src/internal/vm_rv32gc.cpp
+++ b/riscv/src/internal/vm_rv32gc.cpp
@@ -112,15 +112,10 @@ protected:
void gen_trap_check(llvm::BasicBlock *bb);
-
inline llvm::Value *gen_reg_load(unsigned i, unsigned level = 0) {
return this->builder.CreateLoad(get_reg_ptr(i), false);
}
- llvm::Value* gen_fdispatch(std::string fname, const std::vector& args);
-
- llvm::Value* gen_dispatch(std::string name, llvm::Value*, llvm::Value*, llvm::Value*);
-
inline void gen_set_pc(virt_addr_t pc, unsigned reg_num) {
llvm::Value *next_pc_v = this->builder.CreateSExtOrTrunc(this->gen_const(traits::XLEN, pc.val),
this->get_type(traits::XLEN));
@@ -541,8 +536,8 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->gen_const(32U, fld_imm_val);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ Value* Xtmp0_val = this->gen_const(32U, fld_imm_val);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 0);
@@ -575,10 +570,10 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateAdd(
+ Value* Xtmp0_val = this->builder.CreateAdd(
cur_pc_val,
this->gen_const(32U, fld_imm_val));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 1);
@@ -611,10 +606,10 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateAdd(
+ Value* Xtmp0_val = this->builder.CreateAdd(
cur_pc_val,
this->gen_const(32U, 4));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
Value* PC_val = this->builder.CreateAdd(
cur_pc_val,
@@ -650,17 +645,17 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateAdd(
+ Value* Xtmp0_val = this->builder.CreateAdd(
cur_pc_val,
this->gen_const(32U, 4));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
Value* ret_val = this->builder.CreateAdd(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_imm_val));
Value* PC_val = this->builder.CreateAnd(
ret_val,
- this->builder.CreateNot(this->gen_const(32U, 1)));
+ this->builder.CreateNot(this->gen_const(32U, 0x1)));
this->builder.CreateStore(PC_val, get_reg_ptr(traits::NEXT_PC), false);
this->gen_sync(iss::POST_SYNC, 3);
this->gen_trap_check(this->leave_blk);
@@ -955,11 +950,11 @@ private:
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_imm_val));
if(fld_rd_val != 0){
- Value* X_rd_val = this->gen_ext(
+ Value* Xtmp0_val = this->gen_ext(
this->gen_read_mem(traits::MEM, offs_val, 8/8),
32,
true);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 10);
@@ -996,11 +991,11 @@ private:
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_imm_val));
if(fld_rd_val != 0){
- Value* X_rd_val = this->gen_ext(
+ Value* Xtmp0_val = this->gen_ext(
this->gen_read_mem(traits::MEM, offs_val, 16/8),
32,
true);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 11);
@@ -1037,11 +1032,11 @@ private:
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_imm_val));
if(fld_rd_val != 0){
- Value* X_rd_val = this->gen_ext(
+ Value* Xtmp0_val = this->gen_ext(
this->gen_read_mem(traits::MEM, offs_val, 32/8),
32,
true);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 12);
@@ -1078,11 +1073,11 @@ private:
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_imm_val));
if(fld_rd_val != 0){
- Value* X_rd_val = this->gen_ext(
+ Value* Xtmp0_val = this->gen_ext(
this->gen_read_mem(traits::MEM, offs_val, 8/8),
32,
false);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 13);
@@ -1119,11 +1114,11 @@ private:
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_imm_val));
if(fld_rd_val != 0){
- Value* X_rd_val = this->gen_ext(
+ Value* Xtmp0_val = this->gen_ext(
this->gen_read_mem(traits::MEM, offs_val, 16/8),
32,
false);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 14);
@@ -1159,11 +1154,11 @@ private:
Value* offs_val = this->builder.CreateAdd(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_imm_val));
- Value* MEM_offs_val = this->gen_reg_load(fld_rs2_val + traits::X0, 0);
+ Value* MEMtmp0_val = this->gen_reg_load(fld_rs2_val + traits::X0, 0);
this->gen_write_mem(
traits::MEM,
offs_val,
- this->builder.CreateZExtOrTrunc(MEM_offs_val,this->get_type(8)));
+ this->builder.CreateZExtOrTrunc(MEMtmp0_val,this->get_type(8)));
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 15);
bb = llvm::BasicBlock::Create(this->mod->getContext(), "entry", this->func, this->leave_blk); /* create next BasicBlock in chain */
@@ -1198,11 +1193,11 @@ private:
Value* offs_val = this->builder.CreateAdd(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_imm_val));
- Value* MEM_offs_val = this->gen_reg_load(fld_rs2_val + traits::X0, 0);
+ Value* MEMtmp0_val = this->gen_reg_load(fld_rs2_val + traits::X0, 0);
this->gen_write_mem(
traits::MEM,
offs_val,
- this->builder.CreateZExtOrTrunc(MEM_offs_val,this->get_type(16)));
+ this->builder.CreateZExtOrTrunc(MEMtmp0_val,this->get_type(16)));
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 16);
bb = llvm::BasicBlock::Create(this->mod->getContext(), "entry", this->func, this->leave_blk); /* create next BasicBlock in chain */
@@ -1237,11 +1232,11 @@ private:
Value* offs_val = this->builder.CreateAdd(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_imm_val));
- Value* MEM_offs_val = this->gen_reg_load(fld_rs2_val + traits::X0, 0);
+ Value* MEMtmp0_val = this->gen_reg_load(fld_rs2_val + traits::X0, 0);
this->gen_write_mem(
traits::MEM,
offs_val,
- this->builder.CreateZExtOrTrunc(MEM_offs_val,this->get_type(32)));
+ this->builder.CreateZExtOrTrunc(MEMtmp0_val,this->get_type(32)));
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 17);
bb = llvm::BasicBlock::Create(this->mod->getContext(), "entry", this->func, this->leave_blk); /* create next BasicBlock in chain */
@@ -1274,10 +1269,10 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateAdd(
+ Value* Xtmp0_val = this->builder.CreateAdd(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_imm_val));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 18);
@@ -1311,7 +1306,7 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->gen_choose(
+ Value* Xtmp0_val = this->gen_choose(
this->builder.CreateICmp(
ICmpInst::ICMP_SLT,
this->gen_ext(
@@ -1321,7 +1316,7 @@ private:
this->gen_const(32U, 1),
this->gen_const(32U, 0),
32);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 19);
@@ -1356,7 +1351,7 @@ private:
int32_t full_imm_val = fld_imm_val;
if(fld_rd_val != 0){
- Value* X_rd_val = this->gen_choose(
+ Value* Xtmp0_val = this->gen_choose(
this->builder.CreateICmp(
ICmpInst::ICMP_ULT,
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
@@ -1364,7 +1359,7 @@ private:
this->gen_const(32U, 1),
this->gen_const(32U, 0),
32);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 20);
@@ -1398,10 +1393,10 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateXor(
+ Value* Xtmp0_val = this->builder.CreateXor(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_imm_val));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 21);
@@ -1435,10 +1430,10 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateOr(
+ Value* Xtmp0_val = this->builder.CreateOr(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_imm_val));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 22);
@@ -1472,10 +1467,10 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateAnd(
+ Value* Xtmp0_val = this->builder.CreateAnd(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_imm_val));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 23);
@@ -1512,10 +1507,10 @@ private:
this->gen_raise_trap(0, 0);
} else {
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateShl(
+ Value* Xtmp0_val = this->builder.CreateShl(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_shamt_val));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
}
this->gen_set_pc(pc, traits::NEXT_PC);
@@ -1553,10 +1548,10 @@ private:
this->gen_raise_trap(0, 0);
} else {
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateLShr(
+ Value* Xtmp0_val = this->builder.CreateLShr(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_shamt_val));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
}
this->gen_set_pc(pc, traits::NEXT_PC);
@@ -1594,10 +1589,10 @@ private:
this->gen_raise_trap(0, 0);
} else {
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateAShr(
+ Value* Xtmp0_val = this->builder.CreateAShr(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_const(32U, fld_shamt_val));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
}
this->gen_set_pc(pc, traits::NEXT_PC);
@@ -1632,10 +1627,10 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateAdd(
+ Value* Xtmp0_val = this->builder.CreateAdd(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_reg_load(fld_rs2_val + traits::X0, 0));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 27);
@@ -1669,10 +1664,10 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateSub(
+ Value* Xtmp0_val = this->builder.CreateSub(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_reg_load(fld_rs2_val + traits::X0, 0));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 28);
@@ -1706,12 +1701,12 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateShl(
+ Value* Xtmp0_val = this->builder.CreateShl(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->builder.CreateAnd(
this->gen_reg_load(fld_rs2_val + traits::X0, 0),
- this->gen_const(32U, 31)));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->gen_const(32U, 0x1f)));
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 29);
@@ -1745,7 +1740,7 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->gen_choose(
+ Value* Xtmp0_val = this->gen_choose(
this->builder.CreateICmp(
ICmpInst::ICMP_SLT,
this->gen_ext(
@@ -1757,7 +1752,7 @@ private:
this->gen_const(32U, 1),
this->gen_const(32U, 0),
32);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 30);
@@ -1791,7 +1786,7 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->gen_choose(
+ Value* Xtmp0_val = this->gen_choose(
this->builder.CreateICmp(
ICmpInst::ICMP_ULT,
this->gen_ext(
@@ -1805,7 +1800,7 @@ private:
this->gen_const(32U, 1),
this->gen_const(32U, 0),
32);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 31);
@@ -1839,10 +1834,10 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateXor(
+ Value* Xtmp0_val = this->builder.CreateXor(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_reg_load(fld_rs2_val + traits::X0, 0));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 32);
@@ -1876,12 +1871,12 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateLShr(
+ Value* Xtmp0_val = this->builder.CreateLShr(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->builder.CreateAnd(
this->gen_reg_load(fld_rs2_val + traits::X0, 0),
- this->gen_const(32U, 31)));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->gen_const(32U, 0x1f)));
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 33);
@@ -1915,12 +1910,12 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateAShr(
+ Value* Xtmp0_val = this->builder.CreateAShr(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->builder.CreateAnd(
this->gen_reg_load(fld_rs2_val + traits::X0, 0),
- this->gen_const(32U, 31)));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->gen_const(32U, 0x1f)));
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 34);
@@ -1954,10 +1949,10 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateOr(
+ Value* Xtmp0_val = this->builder.CreateOr(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_reg_load(fld_rs2_val + traits::X0, 0));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 35);
@@ -1991,10 +1986,10 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->builder.CreateAnd(
+ Value* Xtmp0_val = this->builder.CreateAnd(
this->gen_reg_load(fld_rs1_val + traits::X0, 0),
this->gen_reg_load(fld_rs2_val + traits::X0, 0));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 36);
@@ -2026,15 +2021,15 @@ private:
Value* cur_pc_val = this->gen_const(32, pc.val);
pc=pc+4;
- Value* FENCE_fence_val = this->builder.CreateOr(
+ Value* FENCEtmp0_val = this->builder.CreateOr(
this->builder.CreateShl(
this->gen_const(32U, fld_pred_val),
this->gen_const(32U, 4)),
this->gen_const(32U, fld_succ_val));
this->gen_write_mem(
traits::FENCE,
- (uint64_t)0,
- this->builder.CreateZExtOrTrunc(FENCE_fence_val,this->get_type(32)));
+ this->gen_const(64U, 0),
+ this->builder.CreateZExtOrTrunc(FENCEtmp0_val,this->get_type(32)));
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 37);
bb = llvm::BasicBlock::Create(this->mod->getContext(), "entry", this->func, this->leave_blk); /* create next BasicBlock in chain */
@@ -2064,11 +2059,11 @@ private:
Value* cur_pc_val = this->gen_const(32, pc.val);
pc=pc+4;
- Value* FENCE_fencei_val = this->gen_const(32U, fld_imm_val);
+ Value* FENCEtmp0_val = this->gen_const(32U, fld_imm_val);
this->gen_write_mem(
traits::FENCE,
- (uint64_t)1,
- this->builder.CreateZExtOrTrunc(FENCE_fencei_val,this->get_type(32)));
+ this->gen_const(64U, 1),
+ this->builder.CreateZExtOrTrunc(FENCEtmp0_val,this->get_type(32)));
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 38);
this->gen_trap_check(this->leave_blk);
@@ -2254,16 +2249,16 @@ private:
Value* cur_pc_val = this->gen_const(32, pc.val);
pc=pc+4;
- Value* FENCE_fencevmal_val = this->gen_const(32U, fld_rs1_val);
+ Value* FENCEtmp0_val = this->gen_const(32U, fld_rs1_val);
this->gen_write_mem(
traits::FENCE,
- (uint64_t)2,
- this->builder.CreateZExtOrTrunc(FENCE_fencevmal_val,this->get_type(32)));
- Value* FENCE_fencevmau_val = this->gen_const(32U, fld_rs2_val);
+ this->gen_const(64U, 2),
+ this->builder.CreateZExtOrTrunc(FENCEtmp0_val,this->get_type(32)));
+ Value* FENCEtmp1_val = this->gen_const(32U, fld_rs2_val);
this->gen_write_mem(
traits::FENCE,
- (uint64_t)3,
- this->builder.CreateZExtOrTrunc(FENCE_fencevmau_val,this->get_type(32)));
+ this->gen_const(64U, 3),
+ this->builder.CreateZExtOrTrunc(FENCEtmp1_val,this->get_type(32)));
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 45);
bb = llvm::BasicBlock::Create(this->mod->getContext(), "entry", this->func, this->leave_blk); /* create next BasicBlock in chain */
@@ -2297,20 +2292,20 @@ private:
Value* rs_val_val = this->gen_reg_load(fld_rs1_val + traits::X0, 0);
if(fld_rd_val != 0){
- Value* csr_val_val = this->gen_read_mem(traits::CSR, fld_csr_val, 32/8);
- Value* CSR_csr_val = rs_val_val;
+ Value* csr_val_val = this->gen_read_mem(traits::CSR, this->gen_const(16U, fld_csr_val), 32/8);
+ Value* CSRtmp0_val = rs_val_val;
this->gen_write_mem(
traits::CSR,
- fld_csr_val,
- this->builder.CreateZExtOrTrunc(CSR_csr_val,this->get_type(32)));
- Value* X_rd_val = csr_val_val;
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->gen_const(16U, fld_csr_val),
+ this->builder.CreateZExtOrTrunc(CSRtmp0_val,this->get_type(32)));
+ Value* Xtmp1_val = csr_val_val;
+ this->builder.CreateStore(Xtmp1_val, get_reg_ptr(fld_rd_val + traits::X0), false);
} else {
- Value* CSR_csr_val = rs_val_val;
+ Value* CSRtmp2_val = rs_val_val;
this->gen_write_mem(
traits::CSR,
- fld_csr_val,
- this->builder.CreateZExtOrTrunc(CSR_csr_val,this->get_type(32)));
+ this->gen_const(16U, fld_csr_val),
+ this->builder.CreateZExtOrTrunc(CSRtmp2_val,this->get_type(32)));
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 46);
@@ -2343,20 +2338,20 @@ private:
Value* cur_pc_val = this->gen_const(32, pc.val);
pc=pc+4;
- Value* xrd_val = this->gen_read_mem(traits::CSR, fld_csr_val, 32/8);
+ Value* xrd_val = this->gen_read_mem(traits::CSR, this->gen_const(16U, fld_csr_val), 32/8);
Value* xrs1_val = this->gen_reg_load(fld_rs1_val + traits::X0, 0);
if(fld_rd_val != 0){
- Value* X_rd_val = xrd_val;
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ Value* Xtmp0_val = xrd_val;
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
if(fld_rs1_val != 0){
- Value* CSR_csr_val = this->builder.CreateOr(
+ Value* CSRtmp1_val = this->builder.CreateOr(
xrd_val,
xrs1_val);
this->gen_write_mem(
traits::CSR,
- fld_csr_val,
- this->builder.CreateZExtOrTrunc(CSR_csr_val,this->get_type(32)));
+ this->gen_const(16U, fld_csr_val),
+ this->builder.CreateZExtOrTrunc(CSRtmp1_val,this->get_type(32)));
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 47);
@@ -2389,20 +2384,20 @@ private:
Value* cur_pc_val = this->gen_const(32, pc.val);
pc=pc+4;
- Value* xrd_val = this->gen_read_mem(traits::CSR, fld_csr_val, 32/8);
+ Value* xrd_val = this->gen_read_mem(traits::CSR, this->gen_const(16U, fld_csr_val), 32/8);
Value* xrs1_val = this->gen_reg_load(fld_rs1_val + traits::X0, 0);
if(fld_rd_val != 0){
- Value* X_rd_val = xrd_val;
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ Value* Xtmp0_val = xrd_val;
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
if(fld_rs1_val != 0){
- Value* CSR_csr_val = this->builder.CreateAnd(
+ Value* CSRtmp1_val = this->builder.CreateAnd(
xrd_val,
this->builder.CreateNot(xrs1_val));
this->gen_write_mem(
traits::CSR,
- fld_csr_val,
- this->builder.CreateZExtOrTrunc(CSR_csr_val,this->get_type(32)));
+ this->gen_const(16U, fld_csr_val),
+ this->builder.CreateZExtOrTrunc(CSRtmp1_val,this->get_type(32)));
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 48);
@@ -2436,17 +2431,17 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- Value* X_rd_val = this->gen_read_mem(traits::CSR, fld_csr_val, 32/8);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ Value* Xtmp0_val = this->gen_read_mem(traits::CSR, this->gen_const(16U, fld_csr_val), 32/8);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
- Value* CSR_csr_val = this->gen_ext(
+ Value* CSRtmp1_val = this->gen_ext(
this->gen_const(32U, fld_zimm_val),
32,
false);
this->gen_write_mem(
traits::CSR,
- fld_csr_val,
- this->builder.CreateZExtOrTrunc(CSR_csr_val,this->get_type(32)));
+ this->gen_const(16U, fld_csr_val),
+ this->builder.CreateZExtOrTrunc(CSRtmp1_val,this->get_type(32)));
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 49);
bb = llvm::BasicBlock::Create(this->mod->getContext(), "entry", this->func, this->leave_blk); /* create next BasicBlock in chain */
@@ -2478,9 +2473,9 @@ private:
Value* cur_pc_val = this->gen_const(32, pc.val);
pc=pc+4;
- Value* res_val = this->gen_read_mem(traits::CSR, fld_csr_val, 32/8);
+ Value* res_val = this->gen_read_mem(traits::CSR, this->gen_const(16U, fld_csr_val), 32/8);
if(fld_zimm_val != 0){
- Value* CSR_csr_val = this->builder.CreateOr(
+ Value* CSRtmp0_val = this->builder.CreateOr(
res_val,
this->gen_ext(
this->gen_const(32U, fld_zimm_val),
@@ -2488,12 +2483,12 @@ private:
false));
this->gen_write_mem(
traits::CSR,
- fld_csr_val,
- this->builder.CreateZExtOrTrunc(CSR_csr_val,this->get_type(32)));
+ this->gen_const(16U, fld_csr_val),
+ this->builder.CreateZExtOrTrunc(CSRtmp0_val,this->get_type(32)));
}
if(fld_rd_val != 0){
- Value* X_rd_val = res_val;
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ Value* Xtmp1_val = res_val;
+ this->builder.CreateStore(Xtmp1_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 50);
@@ -2526,13 +2521,13 @@ private:
Value* cur_pc_val = this->gen_const(32, pc.val);
pc=pc+4;
- Value* res_val = this->gen_read_mem(traits::CSR, fld_csr_val, 32/8);
+ Value* res_val = this->gen_read_mem(traits::CSR, this->gen_const(16U, fld_csr_val), 32/8);
if(fld_rd_val != 0){
- Value* X_rd_val = res_val;
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ Value* Xtmp0_val = res_val;
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
if(fld_zimm_val != 0){
- Value* CSR_csr_val = this->builder.CreateAnd(
+ Value* CSRtmp1_val = this->builder.CreateAnd(
res_val,
this->builder.CreateNot(this->gen_ext(
this->gen_const(32U, fld_zimm_val),
@@ -2540,8 +2535,8 @@ private:
false)));
this->gen_write_mem(
traits::CSR,
- fld_csr_val,
- this->builder.CreateZExtOrTrunc(CSR_csr_val,this->get_type(32)));
+ this->gen_const(16U, fld_csr_val),
+ this->builder.CreateZExtOrTrunc(CSRtmp1_val,this->get_type(32)));
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 51);
@@ -2584,11 +2579,11 @@ private:
this->gen_reg_load(fld_rs2_val + traits::X0, 0),
128,
false));
- Value* X_rd_val = this->gen_ext(
+ Value* Xtmp0_val = this->gen_ext(
res_val,
32,
false);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 52);
@@ -2631,13 +2626,13 @@ private:
this->gen_reg_load(fld_rs2_val + traits::X0, 0),
128,
true));
- Value* X_rd_val = this->gen_ext(
+ Value* Xtmp0_val = this->gen_ext(
this->builder.CreateLShr(
res_val,
this->gen_const(32U, 32)),
32,
false);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 53);
@@ -2680,13 +2675,13 @@ private:
this->gen_reg_load(fld_rs2_val + traits::X0, 0),
128,
false));
- Value* X_rd_val = this->gen_ext(
+ Value* Xtmp0_val = this->gen_ext(
this->builder.CreateLShr(
res_val,
this->gen_const(32U, 32)),
32,
false);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 54);
@@ -2729,13 +2724,13 @@ private:
this->gen_reg_load(fld_rs2_val + traits::X0, 0),
128,
false));
- Value* X_rd_val = this->gen_ext(
+ Value* Xtmp0_val = this->gen_ext(
this->builder.CreateLShr(
res_val,
this->gen_const(32U, 32)),
32,
false);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->gen_set_pc(pc, traits::NEXT_PC);
this->gen_sync(iss::POST_SYNC, 55);
@@ -2769,95 +2764,101 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- llvm::BasicBlock* bbnext = llvm::BasicBlock::Create(this->mod->getContext(), "endif", this->func, this->leave_blk);
- llvm::BasicBlock* bb_then = llvm::BasicBlock::Create(this->mod->getContext(), "thenbr", this->func, bbnext);
- llvm::BasicBlock* bb_else = llvm::BasicBlock::Create(this->mod->getContext(), "elsebr", this->func, bbnext);
- // this->builder.SetInsertPoint(bb);
- this->gen_cond_branch(this->builder.CreateICmp(
- ICmpInst::ICMP_NE,
- this->gen_reg_load(fld_rs2_val + traits::X0, 0),
- this->gen_const(32U, 0)),
- bb_then,
- bb_else);
- this->builder.SetInsertPoint(bb_then);
{
- uint32_t M1_val = (-1);
- uint32_t MMIN_val = (-1) << (32 - 1);
llvm::BasicBlock* bbnext = llvm::BasicBlock::Create(this->mod->getContext(), "endif", this->func, this->leave_blk);
llvm::BasicBlock* bb_then = llvm::BasicBlock::Create(this->mod->getContext(), "thenbr", this->func, bbnext);
llvm::BasicBlock* bb_else = llvm::BasicBlock::Create(this->mod->getContext(), "elsebr", this->func, bbnext);
// this->builder.SetInsertPoint(bb);
this->gen_cond_branch(this->builder.CreateICmp(
- ICmpInst::ICMP_EQ,
- this->gen_ext(
- this->gen_reg_load(fld_rs1_val + traits::X0, 1),
- 32, true),
- this->gen_ext(
- this->gen_const(32U, MMIN_val),
- 32, true)),
+ ICmpInst::ICMP_NE,
+ this->gen_reg_load(fld_rs2_val + traits::X0, 0),
+ this->gen_const(32U, 0)),
bb_then,
bb_else);
this->builder.SetInsertPoint(bb_then);
{
- llvm::BasicBlock* bbnext = llvm::BasicBlock::Create(this->mod->getContext(), "endif", this->func, this->leave_blk);
- llvm::BasicBlock* bb_then = llvm::BasicBlock::Create(this->mod->getContext(), "thenbr", this->func, bbnext);
- llvm::BasicBlock* bb_else = llvm::BasicBlock::Create(this->mod->getContext(), "elsebr", this->func, bbnext);
- // this->builder.SetInsertPoint(bb);
- this->gen_cond_branch(this->builder.CreateICmp(
- ICmpInst::ICMP_EQ,
- this->gen_ext(
- this->gen_reg_load(fld_rs2_val + traits::X0, 2),
- 32, true),
- this->gen_ext(
- this->gen_const(32U, M1_val),
- 32, true)),
- bb_then,
- bb_else);
- this->builder.SetInsertPoint(bb_then);
+ int32_t M1_val = (-1);
+ uint32_t MMIN_val = (-1) << (32 - 1);
{
- Value* X_rd_val = this->gen_const(32U, MMIN_val);
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
- }
- this->builder.CreateBr(bbnext);
- this->builder.SetInsertPoint(bb_else);
- {
- Value* X_rd_val = this->builder.CreateSDiv(
+ llvm::BasicBlock* bbnext = llvm::BasicBlock::Create(this->mod->getContext(), "endif", this->func, this->leave_blk);
+ llvm::BasicBlock* bb_then = llvm::BasicBlock::Create(this->mod->getContext(), "thenbr", this->func, bbnext);
+ llvm::BasicBlock* bb_else = llvm::BasicBlock::Create(this->mod->getContext(), "elsebr", this->func, bbnext);
+ // this->builder.SetInsertPoint(bb);
+ this->gen_cond_branch(this->builder.CreateICmp(
+ ICmpInst::ICMP_EQ,
this->gen_ext(
- this->gen_reg_load(fld_rs1_val + traits::X0, 3),
+ this->gen_reg_load(fld_rs1_val + traits::X0, 1),
32, true),
this->gen_ext(
- this->gen_reg_load(fld_rs2_val + traits::X0, 3),
- 32, true));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ this->gen_const(32U, MMIN_val),
+ 32, true)),
+ bb_then,
+ bb_else);
+ this->builder.SetInsertPoint(bb_then);
+ {
+ {
+ llvm::BasicBlock* bbnext = llvm::BasicBlock::Create(this->mod->getContext(), "endif", this->func, this->leave_blk);
+ llvm::BasicBlock* bb_then = llvm::BasicBlock::Create(this->mod->getContext(), "thenbr", this->func, bbnext);
+ llvm::BasicBlock* bb_else = llvm::BasicBlock::Create(this->mod->getContext(), "elsebr", this->func, bbnext);
+ // this->builder.SetInsertPoint(bb);
+ this->gen_cond_branch(this->builder.CreateICmp(
+ ICmpInst::ICMP_EQ,
+ this->gen_ext(
+ this->gen_reg_load(fld_rs2_val + traits::X0, 2),
+ 32, true),
+ this->gen_ext(
+ this->gen_const(32U, M1_val),
+ 32, true)),
+ bb_then,
+ bb_else);
+ this->builder.SetInsertPoint(bb_then);
+ {
+ Value* Xtmp0_val = this->gen_const(32U, MMIN_val);
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ }
+ this->builder.CreateBr(bbnext);
+ this->builder.SetInsertPoint(bb_else);
+ {
+ Value* Xtmp1_val = this->builder.CreateSDiv(
+ this->gen_ext(
+ this->gen_reg_load(fld_rs1_val + traits::X0, 3),
+ 32, true),
+ this->gen_ext(
+ this->gen_reg_load(fld_rs2_val + traits::X0, 3),
+ 32, true));
+ this->builder.CreateStore(Xtmp1_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ }
+ this->builder.CreateBr(bbnext);
+ bb=bbnext;
+ }
+ this->builder.SetInsertPoint(bb);
+ }
+ this->builder.CreateBr(bbnext);
+ this->builder.SetInsertPoint(bb_else);
+ {
+ Value* Xtmp2_val = this->builder.CreateSDiv(
+ this->gen_ext(
+ this->gen_reg_load(fld_rs1_val + traits::X0, 2),
+ 32, true),
+ this->gen_ext(
+ this->gen_reg_load(fld_rs2_val + traits::X0, 2),
+ 32, true));
+ this->builder.CreateStore(Xtmp2_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ }
+ this->builder.CreateBr(bbnext);
+ bb=bbnext;
}
- this->builder.CreateBr(bbnext);
- bb=bbnext;
this->builder.SetInsertPoint(bb);
}
this->builder.CreateBr(bbnext);
this->builder.SetInsertPoint(bb_else);
{
- Value* X_rd_val = this->builder.CreateSDiv(
- this->gen_ext(
- this->gen_reg_load(fld_rs1_val + traits::X0, 2),
- 32, true),
- this->gen_ext(
- this->gen_reg_load(fld_rs2_val + traits::X0, 2),
- 32, true));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ Value* Xtmp3_val = this->builder.CreateNeg(this->gen_const(32U, 1));
+ this->builder.CreateStore(Xtmp3_val, get_reg_ptr(fld_rd_val + traits::X0), false);
}
this->builder.CreateBr(bbnext);
bb=bbnext;
- this->builder.SetInsertPoint(bb);
}
- this->builder.CreateBr(bbnext);
- this->builder.SetInsertPoint(bb_else);
- {
- Value* X_rd_val = this->builder.CreateNeg(this->gen_const(32U, 1));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
- }
- this->builder.CreateBr(bbnext);
- bb=bbnext;
this->builder.SetInsertPoint(bb);
}
this->gen_set_pc(pc, traits::NEXT_PC);
@@ -2892,37 +2893,39 @@ private:
pc=pc+4;
if(fld_rd_val != 0){
- llvm::BasicBlock* bbnext = llvm::BasicBlock::Create(this->mod->getContext(), "endif", this->func, this->leave_blk);
- llvm::BasicBlock* bb_then = llvm::BasicBlock::Create(this->mod->getContext(), "thenbr", this->func, bbnext);
- llvm::BasicBlock* bb_else = llvm::BasicBlock::Create(this->mod->getContext(), "elsebr", this->func, bbnext);
- // this->builder.SetInsertPoint(bb);
- this->gen_cond_branch(this->builder.CreateICmp(
- ICmpInst::ICMP_NE,
- this->gen_reg_load(fld_rs2_val + traits::X0, 0),
- this->gen_const(32U, 0)),
- bb_then,
- bb_else);
- this->builder.SetInsertPoint(bb_then);
{
- Value* X_rd_val = this->builder.CreateUDiv(
- this->gen_ext(
- this->gen_reg_load(fld_rs1_val + traits::X0, 1),
- 32,
- false),
- this->gen_ext(
- this->gen_reg_load(fld_rs2_val + traits::X0, 1),
- 32,
- false));
- this->builder.CreateStore(X_rd_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ llvm::BasicBlock* bbnext = llvm::BasicBlock::Create(this->mod->getContext(), "endif", this->func, this->leave_blk);
+ llvm::BasicBlock* bb_then = llvm::BasicBlock::Create(this->mod->getContext(), "thenbr", this->func, bbnext);
+ llvm::BasicBlock* bb_else = llvm::BasicBlock::Create(this->mod->getContext(), "elsebr", this->func, bbnext);
+ // this->builder.SetInsertPoint(bb);
+ this->gen_cond_branch(this->builder.CreateICmp(
+ ICmpInst::ICMP_NE,
+ this->gen_reg_load(fld_rs2_val + traits::X0, 0),
+ this->gen_const(32U, 0)),
+ bb_then,
+ bb_else);
+ this->builder.SetInsertPoint(bb_then);
+ {
+ Value* Xtmp0_val = this->builder.CreateUDiv(
+ this->gen_ext(
+ this->gen_reg_load(fld_rs1_val + traits::X0, 1),
+ 32,
+ false),
+ this->gen_ext(
+ this->gen_reg_load(fld_rs2_val + traits::X0, 1),
+ 32,
+ false));
+ this->builder.CreateStore(Xtmp0_val, get_reg_ptr(fld_rd_val + traits::X0), false);
+ }
+ this->builder.CreateBr(bbnext);
+ this->builder.SetInsertPoint(bb_else);
+ {
+ Value* Xtmp1_val = this->builder.CreateNeg(this->gen_const(32U, 1));
+ this->builder.CreateStore(Xtmp1_val, get_reg_ptr(fld_rd_val + traits