// See LICENSE for license details.
+#include "decode.h"
+#include "disasm.h"
#include "sim.h"
#include "htif.h"
#include <sys/mman.h>
#include <sstream>
#include <string>
#include <vector>
+#include <algorithm>
static std::string readline(int fd)
{
void sim_t::interactive()
{
- while (true)
+ while (!htif->done())
{
std::cerr << ": " << std::flush;
std::string s = readline(2);
size_t steps = args.size() ? atoll(args[0].c_str()) : -1;
ctrlc_pressed = false;
set_procs_debug(noisy);
- for (size_t i = 0; i < steps && !ctrlc_pressed; i++)
+ for (size_t i = 0; i < steps && !ctrlc_pressed && !htif->done(); i++)
step(1);
}
if(args.size() != 2)
throw trap_illegal_instruction();
- int p = atoi(args[0].c_str());
- int r = atoi(args[1].c_str());
- if(p >= (int)num_cores() || r >= NXPR)
+ char* ptr;
+ unsigned long p = strtoul(args[0].c_str(), &ptr, 10);
+ if (*ptr || p >= num_cores())
+ throw trap_illegal_instruction();
+
+ unsigned long r = std::find(xpr_name, xpr_name + NXPR, args[1]) - xpr_name;
+ if (r == NXPR) {
+ r = strtoul(args[1].c_str(), &ptr, 10);
+ if (*ptr) {
+ #define DECLARE_CSR(name, number) if (args[1] == #name) return procs[p]->get_csr(number);
+ if (0) ;
+ #include "encoding.h"
+ else r = NXPR;
+ #undef DECLARE_CSR
+ }
+ }
+
+ if (r >= NXPR)
throw trap_illegal_instruction();
return procs[p]->state.XPR[r];
throw trap_illegal_instruction();
int p = atoi(args[0].c_str());
- int r = atoi(args[1].c_str());
+ int r = std::find(fpr_name, fpr_name + NFPR, args[1]) - fpr_name;
+ if (r == NFPR)
+ r = atoi(args[1].c_str());
if(p >= (int)num_cores() || r >= NFPR)
throw trap_illegal_instruction();