Merge ktlim@zamp:./local/clean/o3-merge/m5
[gem5.git] / src / cpu / o3 / checker_builder.cc
1 /*
2 * Copyright (c) 2006 The Regents of The University of Michigan
3 * All rights reserved.
4 *
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.
15 *
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.
27 *
28 * Authors: Kevin Lim
29 */
30
31 #include <string>
32
33 #include "cpu/checker/cpu_impl.hh"
34 #include "cpu/inst_seq.hh"
35 #include "cpu/o3/alpha/dyn_inst.hh"
36 #include "cpu/o3/alpha/impl.hh"
37 #include "sim/builder.hh"
38 #include "sim/process.hh"
39 #include "sim/sim_object.hh"
40
41 class MemObject;
42
43 template
44 class Checker<RefCountingPtr<AlphaDynInst<AlphaSimpleImpl> > >;
45
46 /**
47 * Specific non-templated derived class used for SimObject configuration.
48 */
49 class O3Checker : public Checker<RefCountingPtr<AlphaDynInst<AlphaSimpleImpl> > >
50 {
51 public:
52 O3Checker(Params *p)
53 : Checker<RefCountingPtr<AlphaDynInst<AlphaSimpleImpl> > >(p)
54 { }
55 };
56
57 ////////////////////////////////////////////////////////////////////////
58 //
59 // CheckerCPU Simulation Object
60 //
61 BEGIN_DECLARE_SIM_OBJECT_PARAMS(O3Checker)
62
63 Param<Counter> max_insts_any_thread;
64 Param<Counter> max_insts_all_threads;
65 Param<Counter> max_loads_any_thread;
66 Param<Counter> max_loads_all_threads;
67 Param<Counter> stats_reset_inst;
68 Param<Tick> progress_interval;
69
70 #if FULL_SYSTEM
71 SimObjectParam<AlphaITB *> itb;
72 SimObjectParam<AlphaDTB *> dtb;
73 SimObjectParam<System *> system;
74 Param<int> cpu_id;
75 Param<Tick> profile;
76 #else
77 SimObjectParam<Process *> workload;
78 #endif // FULL_SYSTEM
79 Param<int> clock;
80
81 Param<bool> defer_registration;
82 Param<bool> exitOnError;
83 Param<bool> updateOnError;
84 Param<bool> warnOnlyOnLoadError;
85 Param<bool> function_trace;
86 Param<Tick> function_trace_start;
87
88 END_DECLARE_SIM_OBJECT_PARAMS(O3Checker)
89
90 BEGIN_INIT_SIM_OBJECT_PARAMS(O3Checker)
91
92 INIT_PARAM(max_insts_any_thread,
93 "terminate when any thread reaches this inst count"),
94 INIT_PARAM(max_insts_all_threads,
95 "terminate when all threads have reached this inst count"),
96 INIT_PARAM(max_loads_any_thread,
97 "terminate when any thread reaches this load count"),
98 INIT_PARAM(max_loads_all_threads,
99 "terminate when all threads have reached this load count"),
100 INIT_PARAM(stats_reset_inst,
101 "blah"),
102 INIT_PARAM_DFLT(progress_interval, "CPU Progress Interval", 0),
103
104 #if FULL_SYSTEM
105 INIT_PARAM(itb, "Instruction TLB"),
106 INIT_PARAM(dtb, "Data TLB"),
107 INIT_PARAM(system, "system object"),
108 INIT_PARAM(cpu_id, "processor ID"),
109 INIT_PARAM(profile, ""),
110 #else
111 INIT_PARAM(workload, "processes to run"),
112 #endif // FULL_SYSTEM
113
114 INIT_PARAM(clock, "clock speed"),
115
116 INIT_PARAM(defer_registration, "defer system registration (for sampling)"),
117 INIT_PARAM(exitOnError, "exit on error"),
118 INIT_PARAM(updateOnError, "Update the checker with the main CPU's state on error"),
119 INIT_PARAM_DFLT(warnOnlyOnLoadError, "warn, but don't exit, if a load "
120 "result errors", false),
121 INIT_PARAM(function_trace, "Enable function trace"),
122 INIT_PARAM(function_trace_start, "Cycle to start function trace")
123
124 END_INIT_SIM_OBJECT_PARAMS(O3Checker)
125
126
127 CREATE_SIM_OBJECT(O3Checker)
128 {
129 O3Checker::Params *params = new O3Checker::Params();
130 params->name = getInstanceName();
131 params->numberOfThreads = 1;
132 params->max_insts_any_thread = 0;
133 params->max_insts_all_threads = 0;
134 params->max_loads_any_thread = 0;
135 params->max_loads_all_threads = 0;
136 params->stats_reset_inst = 0;
137 params->exitOnError = exitOnError;
138 params->updateOnError = updateOnError;
139 params->warnOnlyOnLoadError = warnOnlyOnLoadError;
140 params->deferRegistration = defer_registration;
141 params->functionTrace = function_trace;
142 params->functionTraceStart = function_trace_start;
143 params->clock = clock;
144 // Hack to touch all parameters. Consider not deriving Checker
145 // from BaseCPU..it's not really a CPU in the end.
146 Counter temp;
147 temp = max_insts_any_thread;
148 temp = max_insts_all_threads;
149 temp = max_loads_any_thread;
150 temp = max_loads_all_threads;
151 temp = stats_reset_inst;
152 Tick temp2 = progress_interval;
153 params->progress_interval = 0;
154 temp2++;
155
156 #if FULL_SYSTEM
157 params->itb = itb;
158 params->dtb = dtb;
159 params->system = system;
160 params->cpu_id = cpu_id;
161 params->profile = profile;
162 #else
163 params->process = workload;
164 #endif
165
166 O3Checker *cpu = new O3Checker(params);
167 return cpu;
168 }
169
170 REGISTER_SIM_OBJECT("O3Checker", O3Checker)