From 91f5736fd3fe989a7d5f3db10070fdedea36e1b4 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 22 Jun 2005 09:59:13 -0400 Subject: Move max_time and progress_interval parameters to the Root object and get rid of the ParamContext that each used to have. python/m5/objects/Root.py: Add max_time and progress_interval to the Root object sim/root.cc: Add max_time and progress_interval to the Root object. These parameters used to be in their own contexts in sim_events.cc sim/sim_events.cc: Get rid of the ParamContext for max cycles and the progress event. Move the functionality to the Root object sim/sim_events.hh: Move ProgressEvent declaration to the header so that it can be used in other files. --HG-- extra : convert_revision : ff664b806855e8eb9201b8a25392aa53204464f0 --- sim/root.cc | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'sim/root.cc') diff --git a/sim/root.cc b/sim/root.cc index fcfde20d1..17438cf2c 100644 --- a/sim/root.cc +++ b/sim/root.cc @@ -36,6 +36,7 @@ #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" @@ -79,13 +80,33 @@ Tick ps; // 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 clock; + Param max_time; + Param progress_interval; Param output_file; END_DECLARE_SIM_OBJECT_PARAMS(Root) @@ -93,6 +114,8 @@ 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) @@ -106,7 +129,7 @@ CREATE_SIM_OBJECT(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; -- cgit v1.2.3