#define set_pc_and_serialize(x) \
do { set_pc(x); /* check alignment */ \
- npc = PC_SERIALIZE; \
+ npc = PC_SERIALIZE_AFTER; \
STATE.pc = (x); \
} while(0)
-#define PC_SERIALIZE 3 /* sentinel value indicating simulator pipeline flush */
+/* Sentinel PC values to serialize simulator pipeline */
+#define PC_SERIALIZE_BEFORE 3
+#define PC_SERIALIZE_AFTER 5
+#define invalid_pc(pc) ((pc) & 1)
/* Convenience wrappers to simplify softfloat code sequences */
#define f32(x) ((float32_t){(uint32_t)x})
#define f64(x) ((float64_t){(uint64_t)x})
#define validate_csr(which, write) ({ \
- if (!STATE.serialized) return PC_SERIALIZE; \
+ if (!STATE.serialized) return PC_SERIALIZE_BEFORE; \
STATE.serialized = false; \
unsigned csr_priv = get_field((which), 0x300); \
unsigned csr_read_only = get_field((which), 0xC00) == 3; \
{
commit_log_stash_privilege(p->get_state());
reg_t npc = fetch.func(p, fetch.insn, pc);
- if (npc != PC_SERIALIZE) {
+ if (!invalid_pc(npc)) {
commit_log_print_insn(p->get_state(), pc, fetch.insn);
p->update_histogram(pc);
}
mmu_t* _mmu = mmu;
#define advance_pc() \
- if (unlikely(pc == PC_SERIALIZE)) { \
+ if (unlikely(invalid_pc(pc))) { \
+ switch (pc) { \
+ case PC_SERIALIZE_BEFORE: state.serialized = true; break; \
+ case PC_SERIALIZE_AFTER: instret++; break; \
+ default: abort(); \
+ } \
pc = state.pc; \
- state.serialized = true; \
break; \
} else { \
state.pc = pc; \
try
{
- check_timer();
take_interrupt();
if (unlikely(debug))
void processor_t::take_interrupt()
{
+ check_timer();
+
reg_t interrupts = state.mip & state.mie;
reg_t m_interrupts = interrupts & ~state.mideleg;