2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include "base/misc.hh"
36 #include "base/output.hh"
37 #include "sim/builder.hh"
38 #include "sim/host.hh"
39 #include "sim/sim_events.hh"
40 #include "sim/sim_object.hh"
41 #include "sim/root.hh"
46 ostream
*outputStream
;
47 ostream
*configStream
;
49 /// The simulated frequency of curTick. (This is only here for a short time)
53 /// The simulated frequency of curTick. (In ticks per second)
67 /* namespace Float */ }
75 /* namespace Float */ }
77 /* namespace Clock */ }
81 class Root
: public SimObject
85 Tick progress_interval
;
88 Root(const std::string
&name
, Tick maxtick
, Tick pi
)
89 : SimObject(name
), max_tick(maxtick
), progress_interval(pi
)
92 virtual void startup();
99 new SimExitEvent(curTick
+ max_tick
, "reached maximum cycle count");
101 if (progress_interval
!= 0)
102 new ProgressEvent(&mainEventQueue
, progress_interval
);
105 BEGIN_DECLARE_SIM_OBJECT_PARAMS(Root
)
108 Param
<Tick
> max_tick
;
109 Param
<Tick
> progress_interval
;
110 Param
<string
> output_file
;
112 END_DECLARE_SIM_OBJECT_PARAMS(Root
)
114 BEGIN_INIT_SIM_OBJECT_PARAMS(Root
)
116 INIT_PARAM(clock
, "tick frequency"),
117 INIT_PARAM(max_tick
, "maximum simulation time"),
118 INIT_PARAM(progress_interval
, "print a progress message"),
119 INIT_PARAM(output_file
, "file to dump simulator output to")
121 END_INIT_SIM_OBJECT_PARAMS(Root
)
123 CREATE_SIM_OBJECT(Root
)
125 static bool created
= false;
127 panic("only one root object allowed!");
131 outputStream
= simout
.find(output_file
);
132 Root
*root
= new Root(getInstanceName(), max_tick
, progress_interval
);
134 using namespace Clock
;
136 Float::s
= static_cast<double>(Frequency
);
137 Float::ms
= Float::s
/ 1.0e3
;
138 Float::us
= Float::s
/ 1.0e6
;
139 Float::ns
= Float::s
/ 1.0e9
;
140 Float::ps
= Float::s
/ 1.0e12
;
142 Float::Hz
= 1.0 / Float::s
;
143 Float::kHz
= 1.0 / Float::ms
;
144 Float::MHz
= 1.0 / Float::us
;
145 Float::GHZ
= 1.0 / Float::ns
;
148 Int::ms
= Int::s
/ 1000;
149 Int::us
= Int::ms
/ 1000;
150 Int::ns
= Int::us
/ 1000;
151 Int::ps
= Int::ns
/ 1000;
156 REGISTER_SIM_OBJECT("Root", Root
)