Merge zizzer:/bk/newmem
[gem5.git] / src / cpu / ozone / simple_cpu_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.hh"
34 #include "cpu/inst_seq.hh"
35 #include "cpu/ozone/cpu_impl.hh"
36 #include "cpu/ozone/simple_impl.hh"
37 #include "cpu/ozone/simple_params.hh"
38 #include "mem/cache/base_cache.hh"
39 #include "sim/builder.hh"
40 #include "sim/process.hh"
41 #include "sim/sim_object.hh"
42
43 template
44 class OzoneCPU<SimpleImpl>;
45
46 class SimpleOzoneCPU : public OzoneCPU<SimpleImpl>
47 {
48 public:
49 SimpleOzoneCPU(SimpleParams *p)
50 : OzoneCPU<SimpleImpl>(p)
51 { }
52 };
53
54 ////////////////////////////////////////////////////////////////////////
55 //
56 // OzoneCPU Simulation Object
57 //
58
59 BEGIN_DECLARE_SIM_OBJECT_PARAMS(SimpleOzoneCPU)
60
61 Param<int> clock;
62 Param<int> numThreads;
63
64 #if FULL_SYSTEM
65 SimObjectParam<System *> system;
66 Param<int> cpu_id;
67 SimObjectParam<AlphaITB *> itb;
68 SimObjectParam<AlphaDTB *> dtb;
69 #else
70 SimObjectVectorParam<Process *> workload;
71 //SimObjectParam<PageTable *> page_table;
72 #endif // FULL_SYSTEM
73
74 SimObjectParam<FunctionalMemory *> mem;
75
76 SimObjectParam<BaseCPU *> checker;
77
78 Param<Counter> max_insts_any_thread;
79 Param<Counter> max_insts_all_threads;
80 Param<Counter> max_loads_any_thread;
81 Param<Counter> max_loads_all_threads;
82
83 SimObjectParam<BaseCache *> icache;
84 SimObjectParam<BaseCache *> dcache;
85
86 Param<unsigned> cachePorts;
87 Param<unsigned> width;
88 Param<unsigned> frontEndWidth;
89 Param<unsigned> backEndWidth;
90 Param<unsigned> backEndSquashLatency;
91 Param<unsigned> backEndLatency;
92 Param<unsigned> maxInstBufferSize;
93 Param<unsigned> numPhysicalRegs;
94
95 Param<unsigned> decodeToFetchDelay;
96 Param<unsigned> renameToFetchDelay;
97 Param<unsigned> iewToFetchDelay;
98 Param<unsigned> commitToFetchDelay;
99 Param<unsigned> fetchWidth;
100
101 Param<unsigned> renameToDecodeDelay;
102 Param<unsigned> iewToDecodeDelay;
103 Param<unsigned> commitToDecodeDelay;
104 Param<unsigned> fetchToDecodeDelay;
105 Param<unsigned> decodeWidth;
106
107 Param<unsigned> iewToRenameDelay;
108 Param<unsigned> commitToRenameDelay;
109 Param<unsigned> decodeToRenameDelay;
110 Param<unsigned> renameWidth;
111
112 Param<unsigned> commitToIEWDelay;
113 Param<unsigned> renameToIEWDelay;
114 Param<unsigned> issueToExecuteDelay;
115 Param<unsigned> issueWidth;
116 Param<unsigned> executeWidth;
117 Param<unsigned> executeIntWidth;
118 Param<unsigned> executeFloatWidth;
119 Param<unsigned> executeBranchWidth;
120 Param<unsigned> executeMemoryWidth;
121
122 Param<unsigned> iewToCommitDelay;
123 Param<unsigned> renameToROBDelay;
124 Param<unsigned> commitWidth;
125 Param<unsigned> squashWidth;
126
127 Param<std::string> predType;
128 Param<unsigned> localPredictorSize;
129 Param<unsigned> localCtrBits;
130 Param<unsigned> localHistoryTableSize;
131 Param<unsigned> localHistoryBits;
132 Param<unsigned> globalPredictorSize;
133 Param<unsigned> globalCtrBits;
134 Param<unsigned> globalHistoryBits;
135 Param<unsigned> choicePredictorSize;
136 Param<unsigned> choiceCtrBits;
137
138 Param<unsigned> BTBEntries;
139 Param<unsigned> BTBTagSize;
140
141 Param<unsigned> RASSize;
142
143 Param<unsigned> LQEntries;
144 Param<unsigned> SQEntries;
145 Param<unsigned> LFSTSize;
146 Param<unsigned> SSITSize;
147
148 Param<unsigned> numPhysIntRegs;
149 Param<unsigned> numPhysFloatRegs;
150 Param<unsigned> numIQEntries;
151 Param<unsigned> numROBEntries;
152
153 Param<bool> decoupledFrontEnd;
154 Param<int> dispatchWidth;
155 Param<int> wbWidth;
156
157 Param<unsigned> smtNumFetchingThreads;
158 Param<std::string> smtFetchPolicy;
159 Param<std::string> smtLSQPolicy;
160 Param<unsigned> smtLSQThreshold;
161 Param<std::string> smtIQPolicy;
162 Param<unsigned> smtIQThreshold;
163 Param<std::string> smtROBPolicy;
164 Param<unsigned> smtROBThreshold;
165 Param<std::string> smtCommitPolicy;
166
167 Param<unsigned> instShiftAmt;
168
169 Param<bool> defer_registration;
170
171 Param<bool> function_trace;
172 Param<Tick> function_trace_start;
173
174 END_DECLARE_SIM_OBJECT_PARAMS(SimpleOzoneCPU)
175
176 BEGIN_INIT_SIM_OBJECT_PARAMS(SimpleOzoneCPU)
177
178 INIT_PARAM(clock, "clock speed"),
179 INIT_PARAM(numThreads, "number of HW thread contexts"),
180
181 #if FULL_SYSTEM
182 INIT_PARAM(system, "System object"),
183 INIT_PARAM(cpu_id, "processor ID"),
184 INIT_PARAM(itb, "Instruction translation buffer"),
185 INIT_PARAM(dtb, "Data translation buffer"),
186 #else
187 INIT_PARAM(workload, "Processes to run"),
188 // INIT_PARAM(page_table, "Page table"),
189 #endif // FULL_SYSTEM
190
191 INIT_PARAM_DFLT(mem, "Memory", NULL),
192
193 INIT_PARAM_DFLT(checker, "Checker CPU", NULL),
194
195 INIT_PARAM_DFLT(max_insts_any_thread,
196 "Terminate when any thread reaches this inst count",
197 0),
198 INIT_PARAM_DFLT(max_insts_all_threads,
199 "Terminate when all threads have reached"
200 "this inst count",
201 0),
202 INIT_PARAM_DFLT(max_loads_any_thread,
203 "Terminate when any thread reaches this load count",
204 0),
205 INIT_PARAM_DFLT(max_loads_all_threads,
206 "Terminate when all threads have reached this load"
207 "count",
208 0),
209
210 INIT_PARAM_DFLT(icache, "L1 instruction cache", NULL),
211 INIT_PARAM_DFLT(dcache, "L1 data cache", NULL),
212
213 INIT_PARAM_DFLT(cachePorts, "Cache Ports", 200),
214 INIT_PARAM_DFLT(width, "Width", 1),
215 INIT_PARAM_DFLT(frontEndWidth, "Front end width", 1),
216 INIT_PARAM_DFLT(backEndWidth, "Back end width", 1),
217 INIT_PARAM_DFLT(backEndSquashLatency, "Back end squash latency", 1),
218 INIT_PARAM_DFLT(backEndLatency, "Back end latency", 1),
219 INIT_PARAM_DFLT(maxInstBufferSize, "Maximum instruction buffer size", 16),
220 INIT_PARAM(numPhysicalRegs, "Number of physical registers"),
221
222 INIT_PARAM(decodeToFetchDelay, "Decode to fetch delay"),
223 INIT_PARAM(renameToFetchDelay, "Rename to fetch delay"),
224 INIT_PARAM(iewToFetchDelay, "Issue/Execute/Writeback to fetch"
225 "delay"),
226 INIT_PARAM(commitToFetchDelay, "Commit to fetch delay"),
227 INIT_PARAM(fetchWidth, "Fetch width"),
228 INIT_PARAM(renameToDecodeDelay, "Rename to decode delay"),
229 INIT_PARAM(iewToDecodeDelay, "Issue/Execute/Writeback to decode"
230 "delay"),
231 INIT_PARAM(commitToDecodeDelay, "Commit to decode delay"),
232 INIT_PARAM(fetchToDecodeDelay, "Fetch to decode delay"),
233 INIT_PARAM(decodeWidth, "Decode width"),
234
235 INIT_PARAM(iewToRenameDelay, "Issue/Execute/Writeback to rename"
236 "delay"),
237 INIT_PARAM(commitToRenameDelay, "Commit to rename delay"),
238 INIT_PARAM(decodeToRenameDelay, "Decode to rename delay"),
239 INIT_PARAM(renameWidth, "Rename width"),
240
241 INIT_PARAM(commitToIEWDelay, "Commit to "
242 "Issue/Execute/Writeback delay"),
243 INIT_PARAM(renameToIEWDelay, "Rename to "
244 "Issue/Execute/Writeback delay"),
245 INIT_PARAM(issueToExecuteDelay, "Issue to execute delay (internal"
246 "to the IEW stage)"),
247 INIT_PARAM(issueWidth, "Issue width"),
248 INIT_PARAM(executeWidth, "Execute width"),
249 INIT_PARAM(executeIntWidth, "Integer execute width"),
250 INIT_PARAM(executeFloatWidth, "Floating point execute width"),
251 INIT_PARAM(executeBranchWidth, "Branch execute width"),
252 INIT_PARAM(executeMemoryWidth, "Memory execute width"),
253
254 INIT_PARAM(iewToCommitDelay, "Issue/Execute/Writeback to commit "
255 "delay"),
256 INIT_PARAM(renameToROBDelay, "Rename to reorder buffer delay"),
257 INIT_PARAM(commitWidth, "Commit width"),
258 INIT_PARAM(squashWidth, "Squash width"),
259
260 INIT_PARAM(predType, "Type of branch predictor ('local', 'tournament')"),
261 INIT_PARAM(localPredictorSize, "Size of local predictor"),
262 INIT_PARAM(localCtrBits, "Bits per counter"),
263 INIT_PARAM(localHistoryTableSize, "Size of local history table"),
264 INIT_PARAM(localHistoryBits, "Bits for the local history"),
265 INIT_PARAM(globalPredictorSize, "Size of global predictor"),
266 INIT_PARAM(globalCtrBits, "Bits per counter"),
267 INIT_PARAM(globalHistoryBits, "Bits of history"),
268 INIT_PARAM(choicePredictorSize, "Size of choice predictor"),
269 INIT_PARAM(choiceCtrBits, "Bits of choice counters"),
270
271 INIT_PARAM(BTBEntries, "Number of BTB entries"),
272 INIT_PARAM(BTBTagSize, "Size of the BTB tags, in bits"),
273
274 INIT_PARAM(RASSize, "RAS size"),
275
276 INIT_PARAM(LQEntries, "Number of load queue entries"),
277 INIT_PARAM(SQEntries, "Number of store queue entries"),
278 INIT_PARAM(LFSTSize, "Last fetched store table size"),
279 INIT_PARAM(SSITSize, "Store set ID table size"),
280
281 INIT_PARAM(numPhysIntRegs, "Number of physical integer registers"),
282 INIT_PARAM(numPhysFloatRegs, "Number of physical floating point "
283 "registers"),
284 INIT_PARAM(numIQEntries, "Number of instruction queue entries"),
285 INIT_PARAM(numROBEntries, "Number of reorder buffer entries"),
286
287 INIT_PARAM_DFLT(decoupledFrontEnd, "Decoupled front end", true),
288 INIT_PARAM_DFLT(dispatchWidth, "Dispatch width", 0),
289 INIT_PARAM_DFLT(wbWidth, "Writeback width", 0),
290
291 INIT_PARAM_DFLT(smtNumFetchingThreads, "SMT Number of Fetching Threads", 1),
292 INIT_PARAM_DFLT(smtFetchPolicy, "SMT Fetch Policy", "SingleThread"),
293 INIT_PARAM_DFLT(smtLSQPolicy, "SMT LSQ Sharing Policy", "Partitioned"),
294 INIT_PARAM_DFLT(smtLSQThreshold,"SMT LSQ Threshold", 100),
295 INIT_PARAM_DFLT(smtIQPolicy, "SMT IQ Policy", "Partitioned"),
296 INIT_PARAM_DFLT(smtIQThreshold, "SMT IQ Threshold", 100),
297 INIT_PARAM_DFLT(smtROBPolicy, "SMT ROB Sharing Policy", "Partitioned"),
298 INIT_PARAM_DFLT(smtROBThreshold,"SMT ROB Threshold", 100),
299 INIT_PARAM_DFLT(smtCommitPolicy,"SMT Commit Fetch Policy", "RoundRobin"),
300
301 INIT_PARAM(instShiftAmt, "Number of bits to shift instructions by"),
302 INIT_PARAM(defer_registration, "defer system registration (for sampling)"),
303
304 INIT_PARAM(function_trace, "Enable function trace"),
305 INIT_PARAM(function_trace_start, "Cycle to start function trace")
306
307 END_INIT_SIM_OBJECT_PARAMS(SimpleOzoneCPU)
308
309 CREATE_SIM_OBJECT(SimpleOzoneCPU)
310 {
311 SimpleOzoneCPU *cpu;
312
313 #if FULL_SYSTEM
314 // Full-system only supports a single thread for the moment.
315 int actual_num_threads = 1;
316 #else
317 // In non-full-system mode, we infer the number of threads from
318 // the workload if it's not explicitly specified.
319 int actual_num_threads =
320 numThreads.isValid() ? numThreads : workload.size();
321
322 if (workload.size() == 0) {
323 fatal("Must specify at least one workload!");
324 }
325
326 #endif
327
328 SimpleParams *params = new SimpleParams;
329
330 params->clock = clock;
331
332 params->name = getInstanceName();
333 params->numberOfThreads = actual_num_threads;
334
335 #if FULL_SYSTEM
336 params->system = system;
337 params->cpu_id = cpu_id;
338 params->itb = itb;
339 params->dtb = dtb;
340 #else
341 params->workload = workload;
342 // params->pTable = page_table;
343 #endif // FULL_SYSTEM
344
345 params->mem = mem;
346 params->checker = checker;
347 params->max_insts_any_thread = max_insts_any_thread;
348 params->max_insts_all_threads = max_insts_all_threads;
349 params->max_loads_any_thread = max_loads_any_thread;
350 params->max_loads_all_threads = max_loads_all_threads;
351
352 //
353 // Caches
354 //
355 params->icacheInterface = icache ? icache->getInterface() : NULL;
356 params->dcacheInterface = dcache ? dcache->getInterface() : NULL;
357 params->cachePorts = cachePorts;
358
359 params->width = width;
360 params->frontEndWidth = frontEndWidth;
361 params->backEndWidth = backEndWidth;
362 params->backEndSquashLatency = backEndSquashLatency;
363 params->backEndLatency = backEndLatency;
364 params->maxInstBufferSize = maxInstBufferSize;
365 params->numPhysicalRegs = numPhysIntRegs + numPhysFloatRegs;
366
367 params->decodeToFetchDelay = decodeToFetchDelay;
368 params->renameToFetchDelay = renameToFetchDelay;
369 params->iewToFetchDelay = iewToFetchDelay;
370 params->commitToFetchDelay = commitToFetchDelay;
371 params->fetchWidth = fetchWidth;
372
373 params->renameToDecodeDelay = renameToDecodeDelay;
374 params->iewToDecodeDelay = iewToDecodeDelay;
375 params->commitToDecodeDelay = commitToDecodeDelay;
376 params->fetchToDecodeDelay = fetchToDecodeDelay;
377 params->decodeWidth = decodeWidth;
378
379 params->iewToRenameDelay = iewToRenameDelay;
380 params->commitToRenameDelay = commitToRenameDelay;
381 params->decodeToRenameDelay = decodeToRenameDelay;
382 params->renameWidth = renameWidth;
383
384 params->commitToIEWDelay = commitToIEWDelay;
385 params->renameToIEWDelay = renameToIEWDelay;
386 params->issueToExecuteDelay = issueToExecuteDelay;
387 params->issueWidth = issueWidth;
388 params->executeWidth = executeWidth;
389 params->executeIntWidth = executeIntWidth;
390 params->executeFloatWidth = executeFloatWidth;
391 params->executeBranchWidth = executeBranchWidth;
392 params->executeMemoryWidth = executeMemoryWidth;
393
394 params->iewToCommitDelay = iewToCommitDelay;
395 params->renameToROBDelay = renameToROBDelay;
396 params->commitWidth = commitWidth;
397 params->squashWidth = squashWidth;
398
399 params->predType = predType;
400 params->localPredictorSize = localPredictorSize;
401 params->localCtrBits = localCtrBits;
402 params->localHistoryTableSize = localHistoryTableSize;
403 params->localHistoryBits = localHistoryBits;
404 params->globalPredictorSize = globalPredictorSize;
405 params->globalCtrBits = globalCtrBits;
406 params->globalHistoryBits = globalHistoryBits;
407 params->choicePredictorSize = choicePredictorSize;
408 params->choiceCtrBits = choiceCtrBits;
409
410 params->BTBEntries = BTBEntries;
411 params->BTBTagSize = BTBTagSize;
412
413 params->RASSize = RASSize;
414
415 params->LQEntries = LQEntries;
416 params->SQEntries = SQEntries;
417
418 params->SSITSize = SSITSize;
419 params->LFSTSize = LFSTSize;
420
421 params->numPhysIntRegs = numPhysIntRegs;
422 params->numPhysFloatRegs = numPhysFloatRegs;
423 params->numIQEntries = numIQEntries;
424 params->numROBEntries = numROBEntries;
425
426 params->decoupledFrontEnd = decoupledFrontEnd;
427 params->dispatchWidth = dispatchWidth;
428 params->wbWidth = wbWidth;
429
430 params->smtNumFetchingThreads = smtNumFetchingThreads;
431 params->smtFetchPolicy = smtFetchPolicy;
432 params->smtIQPolicy = smtIQPolicy;
433 params->smtLSQPolicy = smtLSQPolicy;
434 params->smtLSQThreshold = smtLSQThreshold;
435 params->smtROBPolicy = smtROBPolicy;
436 params->smtROBThreshold = smtROBThreshold;
437 params->smtCommitPolicy = smtCommitPolicy;
438
439 params->instShiftAmt = 2;
440
441 params->deferRegistration = defer_registration;
442
443 params->functionTrace = function_trace;
444 params->functionTraceStart = function_trace_start;
445
446 cpu = new SimpleOzoneCPU(params);
447
448 return cpu;
449 }
450
451 REGISTER_SIM_OBJECT("SimpleOzoneCPU", SimpleOzoneCPU)
452