class Root(SimObject):
type = 'Root'
clock = Param.RootClock('200MHz', "tick frequency")
+ max_time = Param.Latency('0ns', "maximum simulation time (0 = infinite)")
+ progress_interval = Param.Latency('0ns',
+ "print a progress message at a regular interval (0 = never)")
output_file = Param.String('cout', "file to dump simulator output to")
checkpoint = Param.String('', "checkpoint file to load")
# hier = Param.HierParams(HierParams(do_data = False, do_events = True),
#include "base/output.hh"
#include "sim/builder.hh"
#include "sim/host.hh"
+#include "sim/sim_events.hh"
#include "sim/sim_object.hh"
#include "sim/root.hh"
// Dummy Object
class Root : public SimObject
{
+ private:
+ Tick max_time;
+ Tick progress_interval;
+
public:
- Root(const std::string &name) : SimObject(name) {}
+ Root(const std::string &name, Tick maxtime, Tick pi)
+ : SimObject(name), max_time(maxtime), progress_interval(pi)
+ {}
+
+ virtual void startup();
};
+void
+Root::startup()
+{
+ if (max_time != 0)
+ new SimExitEvent(curTick + max_time, "reached maximum cycle count");
+
+ if (progress_interval != 0)
+ new ProgressEvent(&mainEventQueue, progress_interval);
+}
+
BEGIN_DECLARE_SIM_OBJECT_PARAMS(Root)
Param<Tick> clock;
+ Param<Tick> max_time;
+ Param<Tick> progress_interval;
Param<string> output_file;
END_DECLARE_SIM_OBJECT_PARAMS(Root)
BEGIN_INIT_SIM_OBJECT_PARAMS(Root)
INIT_PARAM(clock, "tick frequency"),
+ INIT_PARAM(max_time, "maximum simulation time"),
+ INIT_PARAM(progress_interval, "print a progress message"),
INIT_PARAM(output_file, "file to dump simulator output to")
END_INIT_SIM_OBJECT_PARAMS(Root)
created = true;
outputStream = simout.find(output_file);
- Root *root = new Root(getInstanceName());
+ Root *root = new Root(getInstanceName(), max_time, progress_interval);
using namespace Clock;
Frequency = clock;
return "check swap";
}
-
-///////////////////////////////////////////////////
-//
-// Simulation termination parameters
-//
-///////////////////////////////////////////////////
-
-class TermParamContext : public ParamContext
-{
- public:
- TermParamContext(const string &_iniSection)
- : ParamContext(_iniSection) {}
- void checkParams();
-};
-
-TermParamContext simTerminationParams("max");
-
-Param<Tick> max_cycle(&simTerminationParams, "cycle",
- "maximum number of cycles to execute");
-
-void
-TermParamContext::checkParams()
-{
- // if a max cycle count was specified, put a termination event on
- // the event queue at that point
- if (max_cycle.isValid())
- new SimExitEvent(max_cycle, "reached maximum cycle count");
-}
-
-//
-// Progress event: print out cycle every so often so we know we're
-// making forward progress.
-//
-class ProgressEvent : public Event
-{
- protected:
- Tick interval;
-
- public:
- ProgressEvent(EventQueue *q, Tick interval);
-
- void process(); // process event
- virtual const char *description();
-};
-
-//
-// constructor: schedule at specified time
-//
-ProgressEvent::ProgressEvent(EventQueue *q, Tick _interval)
- : Event(q), interval(_interval)
-{
- schedule(curTick + interval);
-}
-
//
// handle progress event: print message and reschedule
//
{
return "progress message";
}
-
-/////////
-//
-// Periodic progress message support: print out a message every n
-// cycles so we know we're making forward progress.
-//
-/////////
-
-// Parameter space for execution address tracing options. Derive
-// from ParamContext so we can override checkParams() function.
-struct ProgressParamContext : public ParamContext
-{
- ProgressParamContext(const string &_iniSection)
- : ParamContext(_iniSection) {}
- void startup();
-};
-
-ProgressParamContext progessMessageParams("progress");
-
-Param<Tick> progress_interval(&progessMessageParams, "cycle",
- "cycle interval for progress messages");
-
-void
-ProgressParamContext::startup()
-{
- if (progress_interval.isValid())
- new ProgressEvent(&mainEventQueue, progress_interval);
-}
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __SIM_EVENTS_HH__
-#define __SIM_EVENTS_HH__
+#ifndef __SIM_SIM_EVENTS_HH__
+#define __SIM_SIM_EVENTS_HH__
#include "sim/eventq.hh"
};
//
-// Event to cause a statistics dump
+// Event to check swap usage
//
class CheckSwapEvent : public Event
{
public:
CheckSwapEvent(EventQueue *q, int ival)
: Event(q), interval(ival)
- { schedule(interval); }
+ { schedule(curTick + interval); }
void process(); // process event
virtual const char *description();
};
-#endif // __SIM_EVENTS_HH__
+//
+// Progress event: print out cycle every so often so we know we're
+// making forward progress.
+//
+class ProgressEvent : public Event
+{
+ protected:
+ Tick interval;
+
+ public:
+ ProgressEvent(EventQueue *q, Tick ival)
+ : Event(q), interval(ival)
+ { schedule(curTick + interval); }
+
+ void process(); // process event
+
+ virtual const char *description();
+};
+
+#endif // __SIM_SIM_EVENTS_HH__