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