#include "insn_template.h"
#ifdef SPIKE_SIMPLEV
+
+/* transfer the sed/awk processing through to insn_template_sv.cc
+ * however it's been noted that the rv32_xx and rv64_xx functions
+ * are absolutely identical, so to avoid duplicating them, the
+ * exact same template is included *twice*... with macro #defines
+ * to indicate the size (32/64).
+ *
+ * the messy-looking INCLUDEFILE, INSCODE and INSN #defines are
+ * here because the sed/awk processing from Makefile is *not*
+ * a macro pre-processor, it's an *actual* hard-substitution.
+ * so below, #define INSN NAME is substituted with "#define INSN add"
+ * when add.cc is created from this template, etc. the use of the
+ * weird macro names is to avoid e.g. #define INSOPCODE OPCODE being
+ * substituted as "#define INSadd add" during the awk/sed processing.
+ */
+#define INSN NAME
+#define INCLUDEFILE "insns/NAME.h"
+#define INSNCODE OPCODE
#include "sv_decode.h"
-#endif
+#define FN rv32_NAME
+#define ISASZ 32
+#include "insn_template_sv.cc"
+#undef ISASZ
+#undef FN
+#define ISASZ 64
+#define FN rv64_NAME
+#include "insn_template_sv.cc"
-reg_t rv32_NAME(processor_t* p, insn_t s_insn, reg_t pc)
+#else
+
+reg_t rv32_NAME(processor_t* p, insn_t insn, reg_t pc)
{
int xlen = 32;
reg_t npc = sext_xlen(pc + insn_length(OPCODE));
insn_bits_t bits = s_insn.bits();
-#ifdef SPIKE_SIMPLEV
- int voffs = 0;
- sv_insn_t insn(bits, voffs);
- #include "insns/NAME.h"
- trace_opcode(p, OPCODE, s_insn);
-#else
- insn_t insn(bits);
#include "insns/NAME.h"
trace_opcode(p, OPCODE, s_insn);
-#endif
return npc;
}
int xlen = 64;
reg_t npc = sext_xlen(pc + insn_length(OPCODE));
insn_bits_t bits = s_insn.bits();
-#ifdef SPIKE_SIMPLEV
- int voffs = 0;
- sv_insn_t insn(bits, voffs);
- #include "insns/NAME.h"
- trace_opcode(p, OPCODE, s_insn);
-#else
insn_t insn(bits);
#include "insns/NAME.h"
trace_opcode(p, OPCODE, s_insn);
-#endif
return npc;
}
+#endif
+
--- /dev/null
+// See LICENSE for license details.
+
+reg_t FN(processor_t* p, insn_t s_insn, reg_t pc)
+{
+ int xlen = ISASZ;
+ reg_t npc = sext_xlen(pc + insn_length(INSNCODE));
+ insn_bits_t bits = s_insn.bits();
+ int voffs = 0;
+ sv_insn_t insn(bits, voffs);
+ #include INCLUDEFILE
+ trace_opcode(p, INSNCODE, s_insn);
+ return npc;
+}
+