switch (regno)
{
- case CSR_MTOHOST:
- old_val = proc->get_state()->tohost;
- if (write)
- proc->get_state()->tohost = new_val;
- break;
- case CSR_MFROMHOST:
- old_val = proc->get_state()->fromhost;
- if (write && old_val == 0)
- proc->set_csr(CSR_MFROMHOST, new_val);
- break;
case CSR_MRESET:
old_val = !proc->running();
if (write)
case CSR_MSCRATCH: state.mscratch = val; break;
case CSR_MCAUSE: state.mcause = val; break;
case CSR_MBADADDR: state.mbadaddr = val; break;
- case CSR_MTOHOST:
- if (state.tohost == 0)
- state.tohost = val;
- break;
- case CSR_MFROMHOST:
- state.mip = (state.mip & ~(1 << IRQ_HOST)) | (val ? (1 << IRQ_HOST) : 0);
- state.fromhost = val;
- break;
}
}
case CSR_MTVEC: return state.mtvec;
case CSR_MEDELEG: return state.medeleg;
case CSR_MIDELEG: return state.mideleg;
- case CSR_MTOHOST:
- sim->get_htif()->tick(); // not necessary, but faster
- return state.tohost;
- case CSR_MFROMHOST:
- sim->get_htif()->tick(); // not necessary, but faster
- return state.fromhost;
}
throw trap_illegal_instruction();
}
reg_t stvec;
reg_t sptbr;
reg_t scause;
- reg_t tohost;
- reg_t fromhost;
uint32_t fflags;
uint32_t frm;
bool serialized; // whether timer CSRs are in a well-defined state
return false;
}
-void sim_t::stop()
-{
- procs[0]->state.tohost = 1;
- while (htif->tick())
- ;
-}
-
void sim_t::set_debug(bool value)
{
debug = value;
// run the simulation to completion
int run();
bool running();
- void stop();
void set_debug(bool value);
void set_log(bool value);
void set_histogram(bool value);
reg_t get_freg(const std::vector<std::string>& args);
reg_t get_mem(const std::vector<std::string>& args);
reg_t get_pc(const std::vector<std::string>& args);
- reg_t get_tohost(const std::vector<std::string>& args);
friend class htif_isasim_t;
friend class processor_t;