aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@s144.Millennium.Berkeley.EDU>2011-04-18 19:28:51 -0700
committerAndrew Waterman <waterman@s144.Millennium.Berkeley.EDU>2011-04-18 19:28:51 -0700
commit0433532951969fc2330cd451a91c0094e9d942e0 (patch)
tree2c1611d1bef54f4fed4e65481bb3d3b22871c13a
parent95d58037b2fece5db3ca45a2eb8a1b22967f81f9 (diff)
downloadriscv-isa-sim-0433532951969fc2330cd451a91c0094e9d942e0.zip
riscv-isa-sim-0433532951969fc2330cd451a91c0094e9d942e0.tar.gz
riscv-isa-sim-0433532951969fc2330cd451a91c0094e9d942e0.tar.bz2
[xcc,sim,opcodes] added rvc conditional branches
-rw-r--r--riscv/decode.h11
-rw-r--r--riscv/execute.h40
-rw-r--r--riscv/insns/c_beq.h3
-rw-r--r--riscv/insns/c_bne.h3
4 files changed, 53 insertions, 4 deletions
diff --git a/riscv/decode.h b/riscv/decode.h
index a49137a..f411c10 100644
--- a/riscv/decode.h
+++ b/riscv/decode.h
@@ -216,12 +216,15 @@ private:
#define CIMM6 ((int32_t)((insn.bits >> 10) & 0x3f) << 26 >> 26)
#define CIMM5 ((int32_t)((insn.bits >> 5) & 0x1f) << 27 >> 27)
#define CIMM10 ((int32_t)((insn.bits >> 5) & 0x3ff) << 22 >> 22)
+#define CBRANCH_TARGET (pc + (CIMM5 << BRANCH_ALIGN_BITS))
#define CJUMP_TARGET (pc + (CIMM10 << JUMP_ALIGN_BITS))
-static const uint8_t rvc_regmap[8] = { 20, 21, 2, 3, 4, 5, 6, 7 };
-#define CRDS do_writeback(XPR, rvc_regmap[(insn.bits >> 13) & 0x7])
-#define CRS1S XPR[rvc_regmap[(insn.bits >> 10) & 0x7]]
-#define CRS2S XPR[rvc_regmap[(insn.bits >> 13) & 0x7]]
+static const int rvc_rs1_regmap[8] = { 20, 21, 2, 3, 4, 5, 6, 7 };
+#define rvc_rd_regmap rvc_rs1_regmap
+static const int rvc_rs2_regmap[8] = { 20, 21, 2, 3, 4, 5, 6, 0 };
+#define CRDS do_writeback(XPR, rvc_rd_regmap[(insn.bits >> 13) & 0x7])
+#define CRS1S XPR[rvc_rs1_regmap[(insn.bits >> 10) & 0x7]]
+#define CRS2S XPR[rvc_rs2_regmap[(insn.bits >> 13) & 0x7]]
// vector stuff
#define VL vl
diff --git a/riscv/execute.h b/riscv/execute.h
index 1005a53..fbc595a 100644
--- a/riscv/execute.h
+++ b/riscv/execute.h
@@ -659,6 +659,16 @@ switch((insn.bits >> 0x0) & 0x7f)
}
break;
}
+ case 0x10:
+ {
+ #include "insns/c_beq.h"
+ break;
+ }
+ case 0x11:
+ {
+ #include "insns/c_bne.h"
+ break;
+ }
case 0x13:
{
switch((insn.bits >> 0x7) & 0x7)
@@ -1127,6 +1137,16 @@ switch((insn.bits >> 0x0) & 0x7f)
}
break;
}
+ case 0x30:
+ {
+ #include "insns/c_beq.h"
+ break;
+ }
+ case 0x31:
+ {
+ #include "insns/c_bne.h"
+ break;
+ }
case 0x33:
{
switch((insn.bits >> 0x7) & 0x7)
@@ -1647,6 +1667,16 @@ switch((insn.bits >> 0x0) & 0x7f)
}
break;
}
+ case 0x50:
+ {
+ #include "insns/c_beq.h"
+ break;
+ }
+ case 0x51:
+ {
+ #include "insns/c_bne.h"
+ break;
+ }
case 0x53:
{
switch((insn.bits >> 0x7) & 0x7)
@@ -2308,6 +2338,16 @@ switch((insn.bits >> 0x0) & 0x7f)
#include "insns/jal.h"
break;
}
+ case 0x70:
+ {
+ #include "insns/c_beq.h"
+ break;
+ }
+ case 0x71:
+ {
+ #include "insns/c_bne.h"
+ break;
+ }
case 0x73:
{
switch((insn.bits >> 0x7) & 0x7)
diff --git a/riscv/insns/c_beq.h b/riscv/insns/c_beq.h
new file mode 100644
index 0000000..4ceaba2
--- /dev/null
+++ b/riscv/insns/c_beq.h
@@ -0,0 +1,3 @@
+require_rvc;
+if(cmp_trunc(CRS1S) == cmp_trunc(CRS2S))
+ npc = CBRANCH_TARGET;
diff --git a/riscv/insns/c_bne.h b/riscv/insns/c_bne.h
new file mode 100644
index 0000000..59f257b
--- /dev/null
+++ b/riscv/insns/c_bne.h
@@ -0,0 +1,3 @@
+require_rvc;
+if(cmp_trunc(CRS1S) != cmp_trunc(CRS2S))
+ npc = CBRANCH_TARGET;