[sim] fixed bug in msub.d; added ability to print FPRs in debug mode
authorAndrew Waterman <waterman@s141.Millennium.Berkeley.EDU>
Tue, 7 Sep 2010 00:06:50 +0000 (17:06 -0700)
committerAndrew Waterman <waterman@s141.Millennium.Berkeley.EDU>
Tue, 7 Sep 2010 00:06:50 +0000 (17:06 -0700)
riscv/insns/msub_d.h
riscv/sim.cc
riscv/sim.h

index a35dc198b0d3eb680946d7e78e428bc4c1adf7fc..747cacc4f1c0cce1c48f23fb63e576d6d2ee9ad1 100644 (file)
@@ -1,3 +1,3 @@
 require_fp;
-FRC = f64_mulAdd(FRA, FRB, FRD ^ (uint32_t)INT64_MIN);
+FRC = f64_mulAdd(FRA, FRB, FRD ^ (uint64_t)INT64_MIN);
 set_fp_exceptions;
index 668d23a531e5a767209514865e878ab00a530f08..06a9cba410f48b45f0b15482186410fd2e747252 100644 (file)
@@ -71,6 +71,8 @@ void sim_t::run(bool debug)
       funcs["rp"] = &sim_t::interactive_run_proc_noisy;
       funcs["rps"] = &sim_t::interactive_run_proc_silent;
       funcs["reg"] = &sim_t::interactive_reg;
+      funcs["fregs"] = &sim_t::interactive_fregs;
+      funcs["fregd"] = &sim_t::interactive_fregd;
       funcs["mem"] = &sim_t::interactive_mem;
       funcs["until"] = &sim_t::interactive_until;
       funcs["q"] = &sim_t::interactive_quit;
@@ -165,11 +167,45 @@ reg_t sim_t::get_reg(const std::vector<std::string>& args)
   return procs[p].R[r];
 }
 
+reg_t sim_t::get_freg(const std::vector<std::string>& args)
+{
+  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)procs.size() || r >= NFPR)
+    throw trap_illegal_instruction;
+
+  return procs[p].FR[r];
+}
+
 void sim_t::interactive_reg(const std::vector<std::string>& args)
 {
   printf("0x%016llx\n",(unsigned long long)get_reg(args));
 }
 
+union fpr
+{
+  reg_t r;
+  float s;
+  double d;
+};
+
+void sim_t::interactive_fregs(const std::vector<std::string>& args)
+{
+  fpr f;
+  f.r = get_freg(args);
+  printf("%g\n",f.s);
+}
+
+void sim_t::interactive_fregd(const std::vector<std::string>& args)
+{
+  fpr f;
+  f.r = get_freg(args);
+  printf("%g\n",f.d);
+}
+
 reg_t sim_t::get_mem(const std::vector<std::string>& args)
 {
   if(args.size() != 1)
index c8faa0c4c665b22f7d120d2e4fcb48fdfe0e0f06..4072fcf3b12651a5f6e97347a0f82fd3134fb8ad 100644 (file)
@@ -43,10 +43,13 @@ private:
   void interactive_run_proc_silent(const std::vector<std::string>& args);
 
   void interactive_reg(const std::vector<std::string>& args);
+  void interactive_fregs(const std::vector<std::string>& args);
+  void interactive_fregd(const std::vector<std::string>& args);
   void interactive_mem(const std::vector<std::string>& args);
   void interactive_until(const std::vector<std::string>& args);
 
   reg_t get_reg(const std::vector<std::string>& args);
+  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);