OSDN Git Service

2008-06-17 Dave Brolley <brolley@redhat.com>
authorbrolley <brolley>
Tue, 17 Jun 2008 18:11:51 +0000 (18:11 +0000)
committerbrolley <brolley>
Tue, 17 Jun 2008 18:11:51 +0000 (18:11 +0000)
        * mainDynamic.cxx (usage): Document --reversible.
        (try_add_memory): Call sess->add_memory.
        (option_num): add opt_reversible.
        (long_options): Add "reversible".
        (main): Handle opt_reversible.
        * commonCfg.h (set_reversible): New method of SessionCfg.
        (add_memory): Likewise.
        (reversible_p): New member of SessionCfg.
        (memory): Likewise.
        * commonCfg.cxx (CpuCfg): Establish sim-sched relation.
        (SessionCfg): Initialize reversible_p.
        (SessionCfg::write_load): Set up all memory regions as reversible,
        if requested.
        (BoardCfg::write_config): Set up the cpu to be reversible, if
        requested.

sid/main/dynamic/ChangeLog
sid/main/dynamic/commonCfg.cxx
sid/main/dynamic/commonCfg.h
sid/main/dynamic/mainDynamic.cxx

index 937b82c..b427119 100644 (file)
@@ -1,3 +1,21 @@
+2008-06-17  Dave Brolley  <brolley@redhat.com>
+
+       * mainDynamic.cxx (usage): Document --reversible.
+       (try_add_memory): Call sess->add_memory.
+       (option_num): add opt_reversible.
+       (long_options): Add "reversible".
+       (main): Handle opt_reversible.
+       * commonCfg.h (set_reversible): New method of SessionCfg.
+       (add_memory): Likewise.
+       (reversible_p): New member of SessionCfg.
+       (memory): Likewise.
+       * commonCfg.cxx (CpuCfg): Establish sim-sched relation.
+       (SessionCfg): Initialize reversible_p.
+       (SessionCfg::write_load): Set up all memory regions as reversible,
+       if requested.
+       (BoardCfg::write_config): Set up the cpu to be reversible, if
+       requested.
+
 2007-11-06  Dave Brolley  <brolley@redhat.com>
 
        * mepCfg.cxx (MepBoardCfg): Set the gloss component's
index 4975dbc..062be68 100644 (file)
@@ -344,6 +344,7 @@ CpuCfg::CpuCfg (const string name,
     sess->sim_sched->add_subscription 
     (this, "step!", "step-cycles", 
      "time-query", "time-high", "time-low");
+  relate (this, "sim-sched", sess->sim_sched);
 }
 
 
@@ -579,6 +580,7 @@ SessionCfg::SessionCfg (const string name)
     tcl_bridge (NULL),
     loader (NULL),
     verbose (false),
+    reversible_p (false),
     use_stdio (true),
     need_gprof (false),
     need_core_probe (false),
@@ -658,6 +660,18 @@ void SessionCfg::write_load (Writer &w)
       host_sched->set_time (n, 150);
       use_stdio = false;
     }
+
+  // Setup all memory regions to be reversible, if specified.
+  if (reversible_p)
+    for (vector<MemCfg *>::iterator it = memory.begin ();
+        it != memory.end ();
+        ++it)
+      {
+       set (*it, "reversible?", "true");
+       relate (*it, "sim-sched", sim_sched);
+       conn_pin (sim_sched, "time-set", *it, "restore-to-time!");
+      }
+
   AggregateCfg::write_load (w);
 }
 
@@ -1386,6 +1400,13 @@ void BoardCfg::write_config (Writer &w)
          PinConnection (cpu, "trap-code", gdb, "trap-code").write_to(w);
        }
     }  
+
+  // Set up the cpu to be reversible, if requested.
+  if (sess->reversible_p)
+    {
+      Setting (cpu, "reversible?", "true").write_to (w);
+      PinConnection (sess->sim_sched, "time-set", cpu, "restore-to-time!").write_to(w);
+    }
 }
 
 void BoardCfg::set_gprof (const string filename, gprof_type type, int interval)
index bd132f8..140d489 100644 (file)
@@ -233,6 +233,7 @@ struct SessionCfg :
   void use_tksm();
   void use_tcl_bridge();
   void use_no_stdio ();
+  void set_reversible () { reversible_p = true; }
   virtual void set_loader (LoaderCfg *l);
   LoaderCfg *get_loader () const { return loader; }
   AtomicCfg *audio;
@@ -241,6 +242,7 @@ struct SessionCfg :
   AtomicCfg *tcl_bridge;
   bool verbose;
   bool use_stdio;
+  bool reversible_p;
   bool need_gprof;
   bool need_core_probe;
   bool maybe_model_busses;
@@ -249,6 +251,8 @@ struct SessionCfg :
   map<const string, AtomicCfg *> ulog_map;
   void add_gdb () { ++gdb_count; }
   void add_board (ComponentCfg *b) { ++board_count; add_child (b); }
+  void add_memory (MemCfg *mem) { memory.push_back (mem); }
+  vector<MemCfg *> memory;
   virtual void write_config (Writer &w);
   // Support for dynamic configuration profiles
   vector<AtomicCfg *> wrapped_components;
index 95accf3..b9fd45f 100644 (file)
@@ -176,6 +176,7 @@ usage ()
   cout << "--profile-config=NAME,OPTIONS" << endl;
   cout << "                      Specify options for a named profiling configuration" << endl;
   cout << "--rc                  Pass stop code as simulator exit rc" << endl;
+  cout << "--reversible          Configure for reversible simulation" << endl;
   cout << "--save-temps=FILE     Write config to FILE, '-' for stdout." << endl;
   cout << "--wrap=COMPONENT      Turn on SID API tracing for COMPONENT" << endl;
   cout << "--verbose             Turn on run-time verbosity settings" << endl;
@@ -550,6 +551,8 @@ void try_add_memory (const string memspec,
       if (! (mmap_p || read_only_p))
        sess->shutdown_seq->add_output (6, mem, "image-store");
     }
+
+  sess->add_memory (mem);
 }
 
 
@@ -703,7 +706,7 @@ main(int argc, char* argv[])
   enum option_num { opt_help, opt_version, opt_save_temps, opt_wrap, 
                    opt_verbose, opt_tksched, opt_enable_warnings,
                    opt_persistent, opt_profile_config,
-                   opt_rc, opt_no_run, opt_sidrtc, opt_sidcodec, 
+                   opt_rc, opt_reversible, opt_no_run, opt_sidrtc, opt_sidcodec, 
                    opt_tksm, opt_board, opt_cpu, opt_gdb, opt_gloss, opt_engine, 
                    opt_insn_count, opt_load, opt_icache, opt_dcache, 
                    opt_memory_region, opt_profile_func,
@@ -749,6 +752,7 @@ main(int argc, char* argv[])
     {"persistent",      no_argument, & curr_opt, opt_persistent },
     {"profile-config",  required_argument, &curr_opt, opt_profile_config },
     {"rc",              no_argument, & curr_opt, opt_rc },
+    {"reversible",      no_argument, & curr_opt, opt_reversible },
     {"tksm",            no_argument, & curr_opt, opt_tksm },
 
 
@@ -1103,6 +1107,24 @@ main(int argc, char* argv[])
              rc_p = true;
              break;
 
+           case opt_reversible:
+             if (sess)
+               {
+                 sess->set_reversible ();
+                 // --insn-count must be 1 for this to work correctly
+                 if (curr_board)
+                   {
+                     curr_board->set_step_insn_count("1");
+                     board_start_config += " --insn-count=1";
+                   }
+                 else
+                   {
+                     defaults.step_insn_count = "1";
+                     defaults.start_config += " --insn-count=1";
+                   }
+               }
+             break;
+
            case opt_sidrtc:
              option_requires_board (curr_board, "sidrtc");
              curr_board->add_sidrtc (optaddr("sidrtc"));