Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2007 MIPS Technologies, Inc. |
| 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: Korey Sewell |
| 29 | * |
| 30 | */ |
| 31 | |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 32 | #include <algorithm> |
Steve Reinhardt | 14808ec | 2009-04-17 16:54:58 -0700 | [diff] [blame] | 33 | |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 34 | #include "arch/utility.hh" |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 35 | #include "config/full_system.hh" |
Nathan Binkert | d9f39c8 | 2009-09-23 08:34:21 -0700 | [diff] [blame] | 36 | #include "config/the_isa.hh" |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 37 | #include "cpu/activity.hh" |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 38 | #include "cpu/base.hh" |
Nathan Binkert | d9f39c8 | 2009-09-23 08:34:21 -0700 | [diff] [blame] | 39 | #include "cpu/exetrace.hh" |
| 40 | #include "cpu/inorder/cpu.hh" |
| 41 | #include "cpu/inorder/first_stage.hh" |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 42 | #include "cpu/inorder/inorder_dyn_inst.hh" |
Nathan Binkert | d9f39c8 | 2009-09-23 08:34:21 -0700 | [diff] [blame] | 43 | #include "cpu/inorder/pipeline_traits.hh" |
| 44 | #include "cpu/inorder/resource_pool.hh" |
| 45 | #include "cpu/inorder/resources/resource_list.hh" |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 46 | #include "cpu/inorder/thread_context.hh" |
| 47 | #include "cpu/inorder/thread_state.hh" |
Nathan Binkert | d9f39c8 | 2009-09-23 08:34:21 -0700 | [diff] [blame] | 48 | #include "cpu/simple_thread.hh" |
| 49 | #include "cpu/thread_context.hh" |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 50 | #include "mem/translating_port.hh" |
Nathan Binkert | d9f39c8 | 2009-09-23 08:34:21 -0700 | [diff] [blame] | 51 | #include "params/InOrderCPU.hh" |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 52 | #include "sim/process.hh" |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 53 | #include "sim/stat_control.hh" |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 54 | |
Korey Sewell | badb238 | 2009-09-15 01:44:48 -0400 | [diff] [blame] | 55 | #if FULL_SYSTEM |
| 56 | #include "cpu/quiesce_event.hh" |
| 57 | #include "sim/system.hh" |
| 58 | #endif |
| 59 | |
| 60 | #if THE_ISA == ALPHA_ISA |
| 61 | #include "arch/alpha/osfpal.hh" |
| 62 | #endif |
| 63 | |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 64 | using namespace std; |
| 65 | using namespace TheISA; |
| 66 | using namespace ThePipeline; |
| 67 | |
| 68 | InOrderCPU::TickEvent::TickEvent(InOrderCPU *c) |
| 69 | : Event(CPU_Tick_Pri), cpu(c) |
| 70 | { } |
| 71 | |
| 72 | |
| 73 | void |
| 74 | InOrderCPU::TickEvent::process() |
| 75 | { |
| 76 | cpu->tick(); |
| 77 | } |
| 78 | |
| 79 | |
| 80 | const char * |
| 81 | InOrderCPU::TickEvent::description() |
| 82 | { |
| 83 | return "InOrderCPU tick event"; |
| 84 | } |
| 85 | |
| 86 | InOrderCPU::CPUEvent::CPUEvent(InOrderCPU *_cpu, CPUEventType e_type, |
Korey Sewell | d8e0935 | 2010-01-31 18:26:03 -0500 | [diff] [blame^] | 87 | Fault fault, ThreadID _tid, DynInstPtr inst) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 88 | : Event(CPU_Tick_Pri), cpu(_cpu) |
| 89 | { |
Korey Sewell | d8e0935 | 2010-01-31 18:26:03 -0500 | [diff] [blame^] | 90 | setEvent(e_type, fault, _tid, inst); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 91 | } |
| 92 | |
Korey Sewell | 3a057bd | 2009-05-12 15:01:16 -0400 | [diff] [blame] | 93 | |
| 94 | std::string InOrderCPU::eventNames[NumCPUEvents] = |
| 95 | { |
| 96 | "ActivateThread", |
| 97 | "DeallocateThread", |
| 98 | "SuspendThread", |
| 99 | "DisableThreads", |
| 100 | "EnableThreads", |
| 101 | "DisableVPEs", |
| 102 | "EnableVPEs", |
| 103 | "Trap", |
| 104 | "InstGraduated", |
| 105 | "SquashAll", |
| 106 | "UpdatePCs" |
| 107 | }; |
| 108 | |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 109 | void |
| 110 | InOrderCPU::CPUEvent::process() |
| 111 | { |
| 112 | switch (cpuEventType) |
| 113 | { |
| 114 | case ActivateThread: |
| 115 | cpu->activateThread(tid); |
| 116 | break; |
| 117 | |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 118 | //@TODO: Consider Implementing "Suspend Thread" as Separate from |
| 119 | //Deallocate |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 120 | case SuspendThread: // Suspend & Deallocate are same for now. |
| 121 | //cpu->suspendThread(tid); |
| 122 | //break; |
| 123 | case DeallocateThread: |
| 124 | cpu->deallocateThread(tid); |
| 125 | break; |
| 126 | |
| 127 | case EnableVPEs: |
| 128 | cpu->enableVPEs(vpe); |
| 129 | break; |
| 130 | |
| 131 | case DisableVPEs: |
| 132 | cpu->disableVPEs(tid, vpe); |
| 133 | break; |
| 134 | |
| 135 | case EnableThreads: |
| 136 | cpu->enableThreads(vpe); |
| 137 | break; |
| 138 | |
| 139 | case DisableThreads: |
| 140 | cpu->disableThreads(tid, vpe); |
| 141 | break; |
| 142 | |
| 143 | case Trap: |
| 144 | cpu->trapCPU(fault, tid); |
| 145 | break; |
| 146 | |
| 147 | default: |
| 148 | fatal("Unrecognized Event Type %d", cpuEventType); |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 149 | |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 150 | } |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 151 | |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 152 | cpu->cpuEventRemoveList.push(this); |
| 153 | } |
| 154 | |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 155 | |
| 156 | |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 157 | const char * |
| 158 | InOrderCPU::CPUEvent::description() |
| 159 | { |
| 160 | return "InOrderCPU event"; |
| 161 | } |
| 162 | |
| 163 | void |
| 164 | InOrderCPU::CPUEvent::scheduleEvent(int delay) |
| 165 | { |
| 166 | if (squashed()) |
| 167 | mainEventQueue.reschedule(this,curTick + cpu->ticks(delay)); |
| 168 | else if (!scheduled()) |
| 169 | mainEventQueue.schedule(this,curTick + cpu->ticks(delay)); |
| 170 | } |
| 171 | |
| 172 | void |
| 173 | InOrderCPU::CPUEvent::unscheduleEvent() |
| 174 | { |
| 175 | if (scheduled()) |
| 176 | squash(); |
| 177 | } |
| 178 | |
| 179 | InOrderCPU::InOrderCPU(Params *params) |
| 180 | : BaseCPU(params), |
| 181 | cpu_id(params->cpu_id), |
Korey Sewell | 9e1dc7f | 2009-03-04 22:37:45 -0500 | [diff] [blame] | 182 | coreType("default"), |
| 183 | _status(Idle), |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 184 | tickEvent(this), |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 185 | timeBuffer(2 , 2), |
| 186 | removeInstsThisCycle(false), |
| 187 | activityRec(params->name, NumStages, 10, params->activity), |
Korey Sewell | badb238 | 2009-09-15 01:44:48 -0400 | [diff] [blame] | 188 | #if FULL_SYSTEM |
| 189 | system(params->system), |
| 190 | physmem(system->physmem), |
| 191 | #endif // FULL_SYSTEM |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 192 | #ifdef DEBUG |
| 193 | cpuEventNum(0), |
| 194 | resReqCount(0), |
| 195 | #endif // DEBUG |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 196 | switchCount(0), |
| 197 | deferRegistration(false/*params->deferRegistration*/), |
| 198 | stageTracing(params->stageTracing), |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 199 | numVirtProcs(1) |
Korey Sewell | 0e96798 | 2010-01-31 18:25:13 -0500 | [diff] [blame] | 200 | { |
Korey Sewell | badb238 | 2009-09-15 01:44:48 -0400 | [diff] [blame] | 201 | ThreadID active_threads; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 202 | cpu_params = params; |
| 203 | |
| 204 | resPool = new ResourcePool(this, params); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 205 | |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 206 | // Resize for Multithreading CPUs |
| 207 | thread.resize(numThreads); |
| 208 | |
Korey Sewell | badb238 | 2009-09-15 01:44:48 -0400 | [diff] [blame] | 209 | #if FULL_SYSTEM |
| 210 | active_threads = 1; |
| 211 | #else |
| 212 | active_threads = params->workload.size(); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 213 | |
| 214 | if (active_threads > MaxThreads) { |
| 215 | panic("Workload Size too large. Increase the 'MaxThreads'" |
| 216 | "in your InOrder implementation or " |
| 217 | "edit your workload size."); |
| 218 | } |
Korey Sewell | 0e96798 | 2010-01-31 18:25:13 -0500 | [diff] [blame] | 219 | |
| 220 | if (active_threads > 1) { |
| 221 | threadModel = (InOrderCPU::ThreadModel) params->threadModel; |
| 222 | } else { |
| 223 | threadModel = Single; |
| 224 | } |
| 225 | |
| 226 | |
| 227 | |
Korey Sewell | badb238 | 2009-09-15 01:44:48 -0400 | [diff] [blame] | 228 | #endif |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 229 | |
| 230 | // Bind the fetch & data ports from the resource pool. |
| 231 | fetchPortIdx = resPool->getPortIdx(params->fetchMemPort); |
| 232 | if (fetchPortIdx == 0) { |
Korey Sewell | 1c8dfd9 | 2009-05-12 15:01:13 -0400 | [diff] [blame] | 233 | fatal("Unable to find port to fetch instructions from.\n"); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | dataPortIdx = resPool->getPortIdx(params->dataMemPort); |
| 237 | if (dataPortIdx == 0) { |
Korey Sewell | 1c8dfd9 | 2009-05-12 15:01:13 -0400 | [diff] [blame] | 238 | fatal("Unable to find port for data.\n"); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 239 | } |
| 240 | |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 241 | for (ThreadID tid = 0; tid < numThreads; ++tid) { |
Korey Sewell | badb238 | 2009-09-15 01:44:48 -0400 | [diff] [blame] | 242 | #if FULL_SYSTEM |
| 243 | // SMT is not supported in FS mode yet. |
Korey Sewell | f09f84d | 2009-10-01 09:35:06 -0400 | [diff] [blame] | 244 | assert(numThreads == 1); |
| 245 | thread[tid] = new Thread(this, 0); |
Korey Sewell | badb238 | 2009-09-15 01:44:48 -0400 | [diff] [blame] | 246 | #else |
Nathan Binkert | 6faf377 | 2009-06-04 23:21:12 -0700 | [diff] [blame] | 247 | if (tid < (ThreadID)params->workload.size()) { |
Korey Sewell | 30cd2d2 | 2009-03-04 13:17:08 -0500 | [diff] [blame] | 248 | DPRINTF(InOrderCPU, "Workload[%i] process is %#x\n", |
Korey Sewell | f09f84d | 2009-10-01 09:35:06 -0400 | [diff] [blame] | 249 | tid, params->workload[tid]->prog_fname); |
| 250 | thread[tid] = |
Gabe Black | c9a27d8 | 2009-07-08 23:02:22 -0700 | [diff] [blame] | 251 | new Thread(this, tid, params->workload[tid]); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 252 | } else { |
| 253 | //Allocate Empty thread so M5 can use later |
| 254 | //when scheduling threads to CPU |
Korey Sewell | 30cd2d2 | 2009-03-04 13:17:08 -0500 | [diff] [blame] | 255 | Process* dummy_proc = params->workload[0]; |
Korey Sewell | f09f84d | 2009-10-01 09:35:06 -0400 | [diff] [blame] | 256 | thread[tid] = new Thread(this, tid, dummy_proc); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 257 | } |
Korey Sewell | badb238 | 2009-09-15 01:44:48 -0400 | [diff] [blame] | 258 | #endif |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 259 | |
| 260 | // Setup the TC that will serve as the interface to the threads/CPU. |
| 261 | InOrderThreadContext *tc = new InOrderThreadContext; |
| 262 | tc->cpu = this; |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 263 | tc->thread = thread[tid]; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 264 | |
| 265 | // Give the thread the TC. |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 266 | thread[tid]->tc = tc; |
| 267 | thread[tid]->setFuncExeInst(0); |
| 268 | globalSeqNum[tid] = 1; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 269 | |
| 270 | // Add the TC to the CPU's list of TC's. |
| 271 | this->threadContexts.push_back(tc); |
| 272 | } |
| 273 | |
| 274 | // Initialize TimeBuffer Stage Queues |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 275 | for (int stNum=0; stNum < NumStages - 1; stNum++) { |
| 276 | stageQueue[stNum] = new StageQueue(NumStages, NumStages); |
Korey Sewell | 846f953 | 2009-03-04 13:16:49 -0500 | [diff] [blame] | 277 | stageQueue[stNum]->id(stNum); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | |
| 281 | // Set Up Pipeline Stages |
| 282 | for (int stNum=0; stNum < NumStages; stNum++) { |
| 283 | if (stNum == 0) |
| 284 | pipelineStage[stNum] = new FirstStage(params, stNum); |
| 285 | else |
| 286 | pipelineStage[stNum] = new PipelineStage(params, stNum); |
| 287 | |
| 288 | pipelineStage[stNum]->setCPU(this); |
| 289 | pipelineStage[stNum]->setActiveThreads(&activeThreads); |
| 290 | pipelineStage[stNum]->setTimeBuffer(&timeBuffer); |
| 291 | |
| 292 | // Take Care of 1st/Nth stages |
| 293 | if (stNum > 0) |
| 294 | pipelineStage[stNum]->setPrevStageQueue(stageQueue[stNum - 1]); |
Korey Sewell | f69b018 | 2009-03-04 13:17:07 -0500 | [diff] [blame] | 295 | if (stNum < NumStages - 1) |
| 296 | pipelineStage[stNum]->setNextStageQueue(stageQueue[stNum]); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | // Initialize thread specific variables |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 300 | for (ThreadID tid = 0; tid < numThreads; tid++) { |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 301 | archRegDepMap[tid].setCPU(this); |
| 302 | |
| 303 | nonSpecInstActive[tid] = false; |
| 304 | nonSpecSeqNum[tid] = 0; |
| 305 | |
| 306 | squashSeqNum[tid] = MaxAddr; |
| 307 | lastSquashCycle[tid] = 0; |
| 308 | |
Gabe Black | a480ba0 | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 309 | memset(intRegs[tid], 0, sizeof(intRegs[tid])); |
Gabe Black | 0cb180e | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 310 | memset(floatRegs.i[tid], 0, sizeof(floatRegs.i[tid])); |
Gabe Black | 32daf6f | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 311 | isa[tid].clear(); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 312 | |
Gabe Black | 32daf6f | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 313 | isa[tid].expandForMultithreading(numThreads, numVirtProcs); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 314 | } |
| 315 | |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 316 | lastRunningCycle = curTick; |
| 317 | contextSwitch = false; |
| 318 | |
| 319 | // Define dummy instructions and resource requests to be used. |
Korey Sewell | d8e0935 | 2010-01-31 18:26:03 -0500 | [diff] [blame^] | 320 | dummyInst = new InOrderDynInst(this, NULL, 0, 0); |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 321 | dummyReq = new ResourceRequest(resPool->getResource(0), NULL, 0, 0, 0, 0); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 322 | |
| 323 | // Reset CPU to reset state. |
| 324 | #if FULL_SYSTEM |
| 325 | Fault resetFault = new ResetFault(); |
| 326 | resetFault->invoke(tcBase()); |
| 327 | #else |
| 328 | reset(); |
| 329 | #endif |
| 330 | |
| 331 | // Schedule First Tick Event, CPU will reschedule itself from here on out. |
| 332 | scheduleTickEvent(0); |
| 333 | } |
| 334 | |
| 335 | |
| 336 | void |
| 337 | InOrderCPU::regStats() |
| 338 | { |
| 339 | /* Register the Resource Pool's stats here.*/ |
| 340 | resPool->regStats(); |
| 341 | |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 342 | #ifdef DEBUG |
| 343 | maxResReqCount |
| 344 | .name(name() + ".maxResReqCount") |
| 345 | .desc("Maximum number of live resource requests in CPU") |
| 346 | .prereq(maxResReqCount); |
| 347 | #endif |
| 348 | |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 349 | /* Register any of the InOrderCPU's stats here.*/ |
| 350 | timesIdled |
| 351 | .name(name() + ".timesIdled") |
| 352 | .desc("Number of times that the entire CPU went into an idle state and" |
| 353 | " unscheduled itself") |
| 354 | .prereq(timesIdled); |
| 355 | |
| 356 | idleCycles |
| 357 | .name(name() + ".idleCycles") |
| 358 | .desc("Total number of cycles that the CPU has spent unscheduled due " |
| 359 | "to idling") |
| 360 | .prereq(idleCycles); |
| 361 | |
| 362 | threadCycles |
| 363 | .init(numThreads) |
| 364 | .name(name() + ".threadCycles") |
| 365 | .desc("Total Number of Cycles A Thread Was Active in CPU (Per-Thread)"); |
| 366 | |
| 367 | smtCycles |
| 368 | .name(name() + ".smtCycles") |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 369 | .desc("Total number of cycles that the CPU was in SMT-mode"); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 370 | |
| 371 | committedInsts |
| 372 | .init(numThreads) |
| 373 | .name(name() + ".committedInsts") |
| 374 | .desc("Number of Instructions Simulated (Per-Thread)"); |
| 375 | |
| 376 | smtCommittedInsts |
| 377 | .init(numThreads) |
| 378 | .name(name() + ".smtCommittedInsts") |
| 379 | .desc("Number of SMT Instructions Simulated (Per-Thread)"); |
| 380 | |
| 381 | totalCommittedInsts |
| 382 | .name(name() + ".committedInsts_total") |
| 383 | .desc("Number of Instructions Simulated (Total)"); |
| 384 | |
| 385 | cpi |
| 386 | .name(name() + ".cpi") |
| 387 | .desc("CPI: Cycles Per Instruction (Per-Thread)") |
| 388 | .precision(6); |
| 389 | cpi = threadCycles / committedInsts; |
| 390 | |
| 391 | smtCpi |
| 392 | .name(name() + ".smt_cpi") |
| 393 | .desc("CPI: Total SMT-CPI") |
| 394 | .precision(6); |
| 395 | smtCpi = smtCycles / smtCommittedInsts; |
| 396 | |
| 397 | totalCpi |
| 398 | .name(name() + ".cpi_total") |
| 399 | .desc("CPI: Total CPI of All Threads") |
| 400 | .precision(6); |
Korey Sewell | e4aa4ca | 2009-03-04 13:16:48 -0500 | [diff] [blame] | 401 | totalCpi = numCycles / totalCommittedInsts; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 402 | |
| 403 | ipc |
| 404 | .name(name() + ".ipc") |
| 405 | .desc("IPC: Instructions Per Cycle (Per-Thread)") |
| 406 | .precision(6); |
| 407 | ipc = committedInsts / threadCycles; |
| 408 | |
| 409 | smtIpc |
| 410 | .name(name() + ".smt_ipc") |
| 411 | .desc("IPC: Total SMT-IPC") |
| 412 | .precision(6); |
| 413 | smtIpc = smtCommittedInsts / smtCycles; |
| 414 | |
| 415 | totalIpc |
| 416 | .name(name() + ".ipc_total") |
| 417 | .desc("IPC: Total IPC of All Threads") |
| 418 | .precision(6); |
Korey Sewell | e4aa4ca | 2009-03-04 13:16:48 -0500 | [diff] [blame] | 419 | totalIpc = totalCommittedInsts / numCycles; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 420 | |
| 421 | BaseCPU::regStats(); |
| 422 | } |
| 423 | |
| 424 | |
| 425 | void |
| 426 | InOrderCPU::tick() |
| 427 | { |
| 428 | DPRINTF(InOrderCPU, "\n\nInOrderCPU: Ticking main, InOrderCPU.\n"); |
| 429 | |
| 430 | ++numCycles; |
| 431 | |
| 432 | //Tick each of the stages |
| 433 | for (int stNum=NumStages - 1; stNum >= 0 ; stNum--) { |
| 434 | pipelineStage[stNum]->tick(); |
| 435 | } |
| 436 | |
| 437 | // Now advance the time buffers one tick |
| 438 | timeBuffer.advance(); |
| 439 | for (int sqNum=0; sqNum < NumStages - 1; sqNum++) { |
| 440 | stageQueue[sqNum]->advance(); |
| 441 | } |
| 442 | activityRec.advance(); |
| 443 | |
| 444 | // Any squashed requests, events, or insts then remove them now |
| 445 | cleanUpRemovedReqs(); |
| 446 | cleanUpRemovedEvents(); |
| 447 | cleanUpRemovedInsts(); |
| 448 | |
| 449 | // Re-schedule CPU for this cycle |
| 450 | if (!tickEvent.scheduled()) { |
| 451 | if (_status == SwitchedOut) { |
| 452 | // increment stat |
| 453 | lastRunningCycle = curTick; |
| 454 | } else if (!activityRec.active()) { |
| 455 | DPRINTF(InOrderCPU, "sleeping CPU.\n"); |
| 456 | lastRunningCycle = curTick; |
| 457 | timesIdled++; |
| 458 | } else { |
| 459 | //Tick next_tick = curTick + cycles(1); |
| 460 | //tickEvent.schedule(next_tick); |
| 461 | mainEventQueue.schedule(&tickEvent, nextCycle(curTick + 1)); |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 462 | DPRINTF(InOrderCPU, "Scheduled CPU for next tick @ %i.\n", |
| 463 | nextCycle(curTick + 1)); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 464 | } |
| 465 | } |
| 466 | |
| 467 | tickThreadStats(); |
| 468 | updateThreadPriority(); |
| 469 | } |
| 470 | |
| 471 | |
| 472 | void |
| 473 | InOrderCPU::init() |
| 474 | { |
| 475 | if (!deferRegistration) { |
| 476 | registerThreadContexts(); |
| 477 | } |
| 478 | |
| 479 | // Set inSyscall so that the CPU doesn't squash when initially |
| 480 | // setting up registers. |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 481 | for (ThreadID tid = 0; tid < numThreads; ++tid) |
| 482 | thread[tid]->inSyscall = true; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 483 | |
Steve Reinhardt | 14808ec | 2009-04-17 16:54:58 -0700 | [diff] [blame] | 484 | #if FULL_SYSTEM |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 485 | for (ThreadID tid = 0; tid < numThreads; tid++) { |
Steve Reinhardt | 14808ec | 2009-04-17 16:54:58 -0700 | [diff] [blame] | 486 | ThreadContext *src_tc = threadContexts[tid]; |
| 487 | TheISA::initCPU(src_tc, src_tc->contextId()); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 488 | } |
Steve Reinhardt | 14808ec | 2009-04-17 16:54:58 -0700 | [diff] [blame] | 489 | #endif |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 490 | |
| 491 | // Clear inSyscall. |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 492 | for (ThreadID tid = 0; tid < numThreads; ++tid) |
| 493 | thread[tid]->inSyscall = false; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 494 | |
| 495 | // Call Initializiation Routine for Resource Pool |
| 496 | resPool->init(); |
| 497 | } |
| 498 | |
| 499 | void |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 500 | InOrderCPU::reset() |
| 501 | { |
Gabe Black | 32daf6f | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 502 | for (int i = 0; i < numThreads; i++) { |
| 503 | isa[i].reset(coreType, numThreads, |
| 504 | numVirtProcs, dynamic_cast<BaseCPU*>(this)); |
| 505 | } |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 506 | } |
| 507 | |
| 508 | Port* |
| 509 | InOrderCPU::getPort(const std::string &if_name, int idx) |
| 510 | { |
| 511 | return resPool->getPort(if_name, idx); |
| 512 | } |
| 513 | |
Korey Sewell | badb238 | 2009-09-15 01:44:48 -0400 | [diff] [blame] | 514 | #if FULL_SYSTEM |
| 515 | Fault |
| 516 | InOrderCPU::hwrei(ThreadID tid) |
| 517 | { |
| 518 | panic("hwrei: Unimplemented"); |
| 519 | |
| 520 | return NoFault; |
| 521 | } |
| 522 | |
| 523 | |
| 524 | bool |
| 525 | InOrderCPU::simPalCheck(int palFunc, ThreadID tid) |
| 526 | { |
| 527 | panic("simPalCheck: Unimplemented"); |
| 528 | |
| 529 | return true; |
| 530 | } |
| 531 | |
| 532 | |
| 533 | Fault |
| 534 | InOrderCPU::getInterrupts() |
| 535 | { |
| 536 | // Check if there are any outstanding interrupts |
| 537 | return this->interrupts->getInterrupt(this->threadContexts[0]); |
| 538 | } |
| 539 | |
| 540 | |
| 541 | void |
| 542 | InOrderCPU::processInterrupts(Fault interrupt) |
| 543 | { |
| 544 | // Check for interrupts here. For now can copy the code that |
| 545 | // exists within isa_fullsys_traits.hh. Also assume that thread 0 |
| 546 | // is the one that handles the interrupts. |
| 547 | // @todo: Possibly consolidate the interrupt checking code. |
| 548 | // @todo: Allow other threads to handle interrupts. |
| 549 | |
| 550 | assert(interrupt != NoFault); |
| 551 | this->interrupts->updateIntrInfo(this->threadContexts[0]); |
| 552 | |
| 553 | DPRINTF(InOrderCPU, "Interrupt %s being handled\n", interrupt->name()); |
| 554 | this->trap(interrupt, 0); |
| 555 | } |
| 556 | |
| 557 | |
| 558 | void |
| 559 | InOrderCPU::updateMemPorts() |
| 560 | { |
| 561 | // Update all ThreadContext's memory ports (Functional/Virtual |
| 562 | // Ports) |
| 563 | ThreadID size = thread.size(); |
| 564 | for (ThreadID i = 0; i < size; ++i) |
| 565 | thread[i]->connectMemPorts(thread[i]->getTC()); |
| 566 | } |
| 567 | #endif |
| 568 | |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 569 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 570 | InOrderCPU::trap(Fault fault, ThreadID tid, int delay) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 571 | { |
Korey Sewell | db2b721 | 2009-05-12 15:01:16 -0400 | [diff] [blame] | 572 | //@ Squash Pipeline during TRAP |
Korey Sewell | d8e0935 | 2010-01-31 18:26:03 -0500 | [diff] [blame^] | 573 | scheduleCpuEvent(Trap, fault, tid, dummyInst, delay); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 577 | InOrderCPU::trapCPU(Fault fault, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 578 | { |
| 579 | fault->invoke(tcBase(tid)); |
| 580 | } |
| 581 | |
| 582 | void |
| 583 | InOrderCPU::scheduleCpuEvent(CPUEventType c_event, Fault fault, |
Korey Sewell | d8e0935 | 2010-01-31 18:26:03 -0500 | [diff] [blame^] | 584 | ThreadID tid, DynInstPtr inst, |
| 585 | unsigned delay) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 586 | { |
Korey Sewell | d8e0935 | 2010-01-31 18:26:03 -0500 | [diff] [blame^] | 587 | CPUEvent *cpu_event = new CPUEvent(this, c_event, fault, tid, inst); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 588 | |
| 589 | if (delay >= 0) { |
Korey Sewell | db2b721 | 2009-05-12 15:01:16 -0400 | [diff] [blame] | 590 | DPRINTF(InOrderCPU, "Scheduling CPU Event (%s) for cycle %i.\n", |
Korey Sewell | 3a057bd | 2009-05-12 15:01:16 -0400 | [diff] [blame] | 591 | eventNames[c_event], curTick + delay); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 592 | mainEventQueue.schedule(cpu_event,curTick + delay); |
| 593 | } else { |
| 594 | cpu_event->process(); |
| 595 | cpuEventRemoveList.push(cpu_event); |
| 596 | } |
| 597 | |
| 598 | // Broadcast event to the Resource Pool |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 599 | DynInstPtr dummy_inst = |
| 600 | new InOrderDynInst(this, NULL, getNextEventNum(), tid); |
Korey Sewell | d8e0935 | 2010-01-31 18:26:03 -0500 | [diff] [blame^] | 601 | resPool->scheduleEvent(c_event, inst, 0, 0, tid); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | inline bool |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 605 | InOrderCPU::isThreadActive(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 606 | { |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 607 | list<ThreadID>::iterator isActive = |
| 608 | std::find(activeThreads.begin(), activeThreads.end(), tid); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 609 | |
| 610 | return (isActive != activeThreads.end()); |
| 611 | } |
| 612 | |
| 613 | |
| 614 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 615 | InOrderCPU::activateThread(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 616 | { |
| 617 | if (!isThreadActive(tid)) { |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 618 | DPRINTF(InOrderCPU, |
| 619 | "Adding Thread %i to active threads list in CPU.\n", tid); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 620 | activeThreads.push_back(tid); |
| 621 | |
| 622 | wakeCPU(); |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 627 | InOrderCPU::deactivateThread(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 628 | { |
| 629 | DPRINTF(InOrderCPU, "[tid:%i]: Calling deactivate thread.\n", tid); |
| 630 | |
| 631 | if (isThreadActive(tid)) { |
| 632 | DPRINTF(InOrderCPU,"[tid:%i]: Removing from active threads list\n", |
| 633 | tid); |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 634 | list<ThreadID>::iterator thread_it = |
| 635 | std::find(activeThreads.begin(), activeThreads.end(), tid); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 636 | |
| 637 | removePipelineStalls(*thread_it); |
| 638 | |
| 639 | //@TODO: change stage status' to Idle? |
| 640 | |
| 641 | activeThreads.erase(thread_it); |
| 642 | } |
| 643 | } |
| 644 | |
| 645 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 646 | InOrderCPU::removePipelineStalls(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 647 | { |
| 648 | DPRINTF(InOrderCPU,"[tid:%i]: Removing all pipeline stalls\n", |
| 649 | tid); |
| 650 | |
| 651 | for (int stNum = 0; stNum < NumStages ; stNum++) { |
| 652 | pipelineStage[stNum]->removeStalls(tid); |
| 653 | } |
| 654 | |
| 655 | } |
| 656 | bool |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 657 | InOrderCPU::isThreadInCPU(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 658 | { |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 659 | list<ThreadID>::iterator isCurrent = |
| 660 | std::find(currentThreads.begin(), currentThreads.end(), tid); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 661 | |
| 662 | return (isCurrent != currentThreads.end()); |
| 663 | } |
| 664 | |
| 665 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 666 | InOrderCPU::addToCurrentThreads(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 667 | { |
| 668 | if (!isThreadInCPU(tid)) { |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 669 | DPRINTF(InOrderCPU, "Adding Thread %i to current threads list in CPU." |
| 670 | "\n", tid); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 671 | currentThreads.push_back(tid); |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 676 | InOrderCPU::removeFromCurrentThreads(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 677 | { |
| 678 | if (isThreadInCPU(tid)) { |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 679 | DPRINTF(InOrderCPU, |
| 680 | "Adding Thread %i to current threads list in CPU.\n", tid); |
| 681 | list<ThreadID>::iterator isCurrent = |
| 682 | std::find(currentThreads.begin(), currentThreads.end(), tid); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 683 | currentThreads.erase(isCurrent); |
| 684 | } |
| 685 | } |
| 686 | |
| 687 | bool |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 688 | InOrderCPU::isThreadSuspended(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 689 | { |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 690 | list<ThreadID>::iterator isSuspended = |
| 691 | std::find(suspendedThreads.begin(), suspendedThreads.end(), tid); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 692 | |
| 693 | return (isSuspended!= suspendedThreads.end()); |
| 694 | } |
| 695 | |
| 696 | void |
| 697 | InOrderCPU::enableVirtProcElement(unsigned vpe) |
| 698 | { |
| 699 | DPRINTF(InOrderCPU, "[vpe:%i]: Scheduling " |
| 700 | "Enabling of concurrent virtual processor execution", |
| 701 | vpe); |
| 702 | |
Korey Sewell | d8e0935 | 2010-01-31 18:26:03 -0500 | [diff] [blame^] | 703 | scheduleCpuEvent(EnableVPEs, NoFault, 0/*tid*/, dummyInst); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | void |
| 707 | InOrderCPU::enableVPEs(unsigned vpe) |
| 708 | { |
| 709 | DPRINTF(InOrderCPU, "[vpe:%i]: Enabling Concurrent Execution " |
| 710 | "virtual processors %i", vpe); |
| 711 | |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 712 | list<ThreadID>::iterator thread_it = currentThreads.begin(); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 713 | |
| 714 | while (thread_it != currentThreads.end()) { |
| 715 | if (!isThreadSuspended(*thread_it)) { |
| 716 | activateThread(*thread_it); |
| 717 | } |
| 718 | thread_it++; |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 723 | InOrderCPU::disableVirtProcElement(ThreadID tid, unsigned vpe) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 724 | { |
| 725 | DPRINTF(InOrderCPU, "[vpe:%i]: Scheduling " |
| 726 | "Disabling of concurrent virtual processor execution", |
| 727 | vpe); |
| 728 | |
Korey Sewell | d8e0935 | 2010-01-31 18:26:03 -0500 | [diff] [blame^] | 729 | scheduleCpuEvent(DisableVPEs, NoFault, 0/*tid*/, dummyInst); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 730 | } |
| 731 | |
| 732 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 733 | InOrderCPU::disableVPEs(ThreadID tid, unsigned vpe) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 734 | { |
| 735 | DPRINTF(InOrderCPU, "[vpe:%i]: Disabling Concurrent Execution of " |
| 736 | "virtual processors %i", vpe); |
| 737 | |
| 738 | unsigned base_vpe = TheISA::getVirtProcNum(tcBase(tid)); |
| 739 | |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 740 | list<ThreadID>::iterator thread_it = activeThreads.begin(); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 741 | |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 742 | vector<list<ThreadID>::iterator> removeList; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 743 | |
| 744 | while (thread_it != activeThreads.end()) { |
| 745 | if (base_vpe != vpe) { |
| 746 | removeList.push_back(thread_it); |
| 747 | } |
| 748 | thread_it++; |
| 749 | } |
| 750 | |
| 751 | for (int i = 0; i < removeList.size(); i++) { |
| 752 | activeThreads.erase(removeList[i]); |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | void |
| 757 | InOrderCPU::enableMultiThreading(unsigned vpe) |
| 758 | { |
| 759 | // Schedule event to take place at end of cycle |
| 760 | DPRINTF(InOrderCPU, "[vpe:%i]: Scheduling Enable Multithreading on " |
| 761 | "virtual processor %i", vpe); |
| 762 | |
Korey Sewell | d8e0935 | 2010-01-31 18:26:03 -0500 | [diff] [blame^] | 763 | scheduleCpuEvent(EnableThreads, NoFault, 0/*tid*/, dummyInst); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 764 | } |
| 765 | |
| 766 | void |
| 767 | InOrderCPU::enableThreads(unsigned vpe) |
| 768 | { |
| 769 | DPRINTF(InOrderCPU, "[vpe:%i]: Enabling Multithreading on " |
| 770 | "virtual processor %i", vpe); |
| 771 | |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 772 | list<ThreadID>::iterator thread_it = currentThreads.begin(); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 773 | |
| 774 | while (thread_it != currentThreads.end()) { |
| 775 | if (TheISA::getVirtProcNum(tcBase(*thread_it)) == vpe) { |
| 776 | if (!isThreadSuspended(*thread_it)) { |
| 777 | activateThread(*thread_it); |
| 778 | } |
| 779 | } |
| 780 | thread_it++; |
| 781 | } |
| 782 | } |
| 783 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 784 | InOrderCPU::disableMultiThreading(ThreadID tid, unsigned vpe) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 785 | { |
| 786 | // Schedule event to take place at end of cycle |
| 787 | DPRINTF(InOrderCPU, "[tid:%i]: Scheduling Disable Multithreading on " |
| 788 | "virtual processor %i", tid, vpe); |
| 789 | |
Korey Sewell | d8e0935 | 2010-01-31 18:26:03 -0500 | [diff] [blame^] | 790 | scheduleCpuEvent(DisableThreads, NoFault, tid, dummyInst); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 791 | } |
| 792 | |
| 793 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 794 | InOrderCPU::disableThreads(ThreadID tid, unsigned vpe) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 795 | { |
| 796 | DPRINTF(InOrderCPU, "[tid:%i]: Disabling Multithreading on " |
| 797 | "virtual processor %i", tid, vpe); |
| 798 | |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 799 | list<ThreadID>::iterator thread_it = activeThreads.begin(); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 800 | |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 801 | vector<list<ThreadID>::iterator> removeList; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 802 | |
| 803 | while (thread_it != activeThreads.end()) { |
| 804 | if (TheISA::getVirtProcNum(tcBase(*thread_it)) == vpe) { |
| 805 | removeList.push_back(thread_it); |
| 806 | } |
| 807 | thread_it++; |
| 808 | } |
| 809 | |
| 810 | for (int i = 0; i < removeList.size(); i++) { |
| 811 | activeThreads.erase(removeList[i]); |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | void |
| 816 | InOrderCPU::updateThreadPriority() |
| 817 | { |
| 818 | if (activeThreads.size() > 1) |
| 819 | { |
| 820 | //DEFAULT TO ROUND ROBIN SCHEME |
| 821 | //e.g. Move highest priority to end of thread list |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 822 | list<ThreadID>::iterator list_begin = activeThreads.begin(); |
| 823 | list<ThreadID>::iterator list_end = activeThreads.end(); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 824 | |
| 825 | unsigned high_thread = *list_begin; |
| 826 | |
| 827 | activeThreads.erase(list_begin); |
| 828 | |
| 829 | activeThreads.push_back(high_thread); |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | inline void |
| 834 | InOrderCPU::tickThreadStats() |
| 835 | { |
| 836 | /** Keep track of cycles that each thread is active */ |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 837 | list<ThreadID>::iterator thread_it = activeThreads.begin(); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 838 | while (thread_it != activeThreads.end()) { |
| 839 | threadCycles[*thread_it]++; |
| 840 | thread_it++; |
| 841 | } |
| 842 | |
| 843 | // Keep track of cycles where SMT is active |
| 844 | if (activeThreads.size() > 1) { |
| 845 | smtCycles++; |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 850 | InOrderCPU::activateContext(ThreadID tid, int delay) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 851 | { |
| 852 | DPRINTF(InOrderCPU,"[tid:%i]: Activating ...\n", tid); |
| 853 | |
Korey Sewell | d8e0935 | 2010-01-31 18:26:03 -0500 | [diff] [blame^] | 854 | scheduleCpuEvent(ActivateThread, NoFault, tid, dummyInst, delay); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 855 | |
| 856 | // Be sure to signal that there's some activity so the CPU doesn't |
| 857 | // deschedule itself. |
| 858 | activityRec.activity(); |
| 859 | |
| 860 | _status = Running; |
| 861 | } |
| 862 | |
| 863 | |
| 864 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 865 | InOrderCPU::suspendContext(ThreadID tid, int delay) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 866 | { |
Korey Sewell | d8e0935 | 2010-01-31 18:26:03 -0500 | [diff] [blame^] | 867 | scheduleCpuEvent(SuspendThread, NoFault, tid, dummyInst, delay); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 868 | //_status = Idle; |
| 869 | } |
| 870 | |
| 871 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 872 | InOrderCPU::suspendThread(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 873 | { |
| 874 | DPRINTF(InOrderCPU,"[tid: %i]: Suspended ...\n", tid); |
| 875 | deactivateThread(tid); |
| 876 | } |
| 877 | |
| 878 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 879 | InOrderCPU::deallocateContext(ThreadID tid, int delay) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 880 | { |
Korey Sewell | d8e0935 | 2010-01-31 18:26:03 -0500 | [diff] [blame^] | 881 | scheduleCpuEvent(DeallocateThread, NoFault, tid, dummyInst, delay); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 882 | } |
| 883 | |
| 884 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 885 | InOrderCPU::deallocateThread(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 886 | { |
| 887 | DPRINTF(InOrderCPU,"[tid:%i]: Deallocating ...", tid); |
| 888 | |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 889 | removeFromCurrentThreads(tid); |
| 890 | |
| 891 | deactivateThread(tid); |
| 892 | |
| 893 | squashThreadInPipeline(tid); |
| 894 | } |
| 895 | |
| 896 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 897 | InOrderCPU::squashThreadInPipeline(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 898 | { |
| 899 | //Squash all instructions in each stage |
| 900 | for (int stNum=NumStages - 1; stNum >= 0 ; stNum--) { |
| 901 | pipelineStage[stNum]->squash(0 /*seq_num*/, tid); |
| 902 | } |
| 903 | } |
| 904 | |
| 905 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 906 | InOrderCPU::haltContext(ThreadID tid, int delay) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 907 | { |
| 908 | DPRINTF(InOrderCPU, "[tid:%i]: Halt context called.\n", tid); |
| 909 | |
| 910 | // Halt is same thing as deallocate for now |
| 911 | // @TODO: Differentiate between halt & deallocate in the CPU |
| 912 | // model |
| 913 | deallocateContext(tid, delay); |
| 914 | } |
| 915 | |
| 916 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 917 | InOrderCPU::insertThread(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 918 | { |
| 919 | panic("Unimplemented Function\n."); |
| 920 | } |
| 921 | |
| 922 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 923 | InOrderCPU::removeThread(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 924 | { |
| 925 | DPRINTF(InOrderCPU, "Removing Thread %i from CPU.\n", tid); |
| 926 | |
| 927 | /** Broadcast to CPU resources*/ |
| 928 | } |
| 929 | |
Korey Sewell | 1c8dfd9 | 2009-05-12 15:01:13 -0400 | [diff] [blame] | 930 | PipelineStage* |
| 931 | InOrderCPU::getPipeStage(int stage_num) |
| 932 | { |
| 933 | return pipelineStage[stage_num]; |
| 934 | } |
| 935 | |
| 936 | |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 937 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 938 | InOrderCPU::activateWhenReady(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 939 | { |
| 940 | panic("Unimplemented Function\n."); |
| 941 | } |
| 942 | |
| 943 | |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 944 | uint64_t |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 945 | InOrderCPU::readPC(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 946 | { |
| 947 | return PC[tid]; |
| 948 | } |
| 949 | |
| 950 | |
| 951 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 952 | InOrderCPU::setPC(Addr new_PC, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 953 | { |
| 954 | PC[tid] = new_PC; |
| 955 | } |
| 956 | |
| 957 | |
| 958 | uint64_t |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 959 | InOrderCPU::readNextPC(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 960 | { |
| 961 | return nextPC[tid]; |
| 962 | } |
| 963 | |
| 964 | |
| 965 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 966 | InOrderCPU::setNextPC(uint64_t new_NPC, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 967 | { |
| 968 | nextPC[tid] = new_NPC; |
| 969 | } |
| 970 | |
| 971 | |
| 972 | uint64_t |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 973 | InOrderCPU::readNextNPC(ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 974 | { |
| 975 | return nextNPC[tid]; |
| 976 | } |
| 977 | |
| 978 | |
| 979 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 980 | InOrderCPU::setNextNPC(uint64_t new_NNPC, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 981 | { |
| 982 | nextNPC[tid] = new_NNPC; |
| 983 | } |
| 984 | |
| 985 | uint64_t |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 986 | InOrderCPU::readIntReg(int reg_idx, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 987 | { |
Gabe Black | a480ba0 | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 988 | return intRegs[tid][reg_idx]; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 989 | } |
| 990 | |
| 991 | FloatReg |
Gabe Black | 25884a8 | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 992 | InOrderCPU::readFloatReg(int reg_idx, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 993 | { |
Gabe Black | 0cb180e | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 994 | return floatRegs.f[tid][reg_idx]; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 995 | } |
| 996 | |
| 997 | FloatRegBits |
Gabe Black | 25884a8 | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 998 | InOrderCPU::readFloatRegBits(int reg_idx, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 999 | {; |
Gabe Black | 0cb180e | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 1000 | return floatRegs.i[tid][reg_idx]; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1001 | } |
| 1002 | |
| 1003 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1004 | InOrderCPU::setIntReg(int reg_idx, uint64_t val, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1005 | { |
Gabe Black | a480ba0 | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 1006 | intRegs[tid][reg_idx] = val; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1007 | } |
| 1008 | |
| 1009 | |
| 1010 | void |
Gabe Black | 25884a8 | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 1011 | InOrderCPU::setFloatReg(int reg_idx, FloatReg val, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1012 | { |
Gabe Black | 0cb180e | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 1013 | floatRegs.f[tid][reg_idx] = val; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1014 | } |
| 1015 | |
| 1016 | |
| 1017 | void |
Gabe Black | 25884a8 | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 1018 | InOrderCPU::setFloatRegBits(int reg_idx, FloatRegBits val, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1019 | { |
Gabe Black | 0cb180e | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 1020 | floatRegs.i[tid][reg_idx] = val; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1021 | } |
| 1022 | |
| 1023 | uint64_t |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1024 | InOrderCPU::readRegOtherThread(unsigned reg_idx, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1025 | { |
| 1026 | // If Default value is set, then retrieve target thread |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1027 | if (tid == InvalidThreadID) { |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1028 | tid = TheISA::getTargetThread(tcBase(tid)); |
| 1029 | } |
| 1030 | |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 1031 | if (reg_idx < FP_Base_DepTag) { |
| 1032 | // Integer Register File |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1033 | return readIntReg(reg_idx, tid); |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 1034 | } else if (reg_idx < Ctrl_Base_DepTag) { |
| 1035 | // Float Register File |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1036 | reg_idx -= FP_Base_DepTag; |
| 1037 | return readFloatRegBits(reg_idx, tid); |
| 1038 | } else { |
| 1039 | reg_idx -= Ctrl_Base_DepTag; |
| 1040 | return readMiscReg(reg_idx, tid); // Misc. Register File |
| 1041 | } |
| 1042 | } |
| 1043 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1044 | InOrderCPU::setRegOtherThread(unsigned reg_idx, const MiscReg &val, |
| 1045 | ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1046 | { |
| 1047 | // If Default value is set, then retrieve target thread |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1048 | if (tid == InvalidThreadID) { |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1049 | tid = TheISA::getTargetThread(tcBase(tid)); |
| 1050 | } |
| 1051 | |
| 1052 | if (reg_idx < FP_Base_DepTag) { // Integer Register File |
| 1053 | setIntReg(reg_idx, val, tid); |
| 1054 | } else if (reg_idx < Ctrl_Base_DepTag) { // Float Register File |
| 1055 | reg_idx -= FP_Base_DepTag; |
| 1056 | setFloatRegBits(reg_idx, val, tid); |
| 1057 | } else { |
| 1058 | reg_idx -= Ctrl_Base_DepTag; |
| 1059 | setMiscReg(reg_idx, val, tid); // Misc. Register File |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | MiscReg |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1064 | InOrderCPU::readMiscRegNoEffect(int misc_reg, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1065 | { |
Gabe Black | 32daf6f | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 1066 | return isa[tid].readMiscRegNoEffect(misc_reg); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1067 | } |
| 1068 | |
| 1069 | MiscReg |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1070 | InOrderCPU::readMiscReg(int misc_reg, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1071 | { |
Gabe Black | 32daf6f | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 1072 | return isa[tid].readMiscReg(misc_reg, tcBase(tid)); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1073 | } |
| 1074 | |
| 1075 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1076 | InOrderCPU::setMiscRegNoEffect(int misc_reg, const MiscReg &val, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1077 | { |
Gabe Black | 32daf6f | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 1078 | isa[tid].setMiscRegNoEffect(misc_reg, val); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1079 | } |
| 1080 | |
| 1081 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1082 | InOrderCPU::setMiscReg(int misc_reg, const MiscReg &val, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1083 | { |
Gabe Black | 32daf6f | 2009-07-08 23:02:20 -0700 | [diff] [blame] | 1084 | isa[tid].setMiscReg(misc_reg, val, tcBase(tid)); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1085 | } |
| 1086 | |
| 1087 | |
| 1088 | InOrderCPU::ListIt |
| 1089 | InOrderCPU::addInst(DynInstPtr &inst) |
| 1090 | { |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1091 | ThreadID tid = inst->readTid(); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1092 | |
| 1093 | instList[tid].push_back(inst); |
| 1094 | |
| 1095 | return --(instList[tid].end()); |
| 1096 | } |
| 1097 | |
| 1098 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1099 | InOrderCPU::instDone(DynInstPtr inst, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1100 | { |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 1101 | // Set the CPU's PCs - This contributes to the precise state of the CPU |
| 1102 | // which can be used when restoring a thread to the CPU after a fork or |
| 1103 | // after an exception |
| 1104 | // ================= |
| 1105 | // @TODO: Set-Up Grad-Info/Committed-Info to let ThreadState know if |
| 1106 | // it's a branch or not |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1107 | setPC(inst->readPC(), tid); |
| 1108 | setNextPC(inst->readNextPC(), tid); |
| 1109 | setNextNPC(inst->readNextNPC(), tid); |
| 1110 | |
| 1111 | // Finalize Trace Data For Instruction |
| 1112 | if (inst->traceData) { |
| 1113 | //inst->traceData->setCycle(curTick); |
| 1114 | inst->traceData->setFetchSeq(inst->seqNum); |
| 1115 | //inst->traceData->setCPSeq(cpu->tcBase(tid)->numInst); |
| 1116 | inst->traceData->dump(); |
| 1117 | delete inst->traceData; |
| 1118 | inst->traceData = NULL; |
| 1119 | } |
| 1120 | |
| 1121 | // Set Last Graduated Instruction In Thread State |
| 1122 | //thread[tid]->lastGradInst = inst; |
| 1123 | |
| 1124 | // Increment thread-state's instruction count |
| 1125 | thread[tid]->numInst++; |
| 1126 | |
| 1127 | // Increment thread-state's instruction stats |
| 1128 | thread[tid]->numInsts++; |
| 1129 | |
| 1130 | // Count committed insts per thread stats |
| 1131 | committedInsts[tid]++; |
| 1132 | |
| 1133 | // Count total insts committed stat |
| 1134 | totalCommittedInsts++; |
| 1135 | |
| 1136 | // Count SMT-committed insts per thread stat |
| 1137 | if (numActiveThreads() > 1) { |
| 1138 | smtCommittedInsts[tid]++; |
| 1139 | } |
| 1140 | |
| 1141 | // Check for instruction-count-based events. |
| 1142 | comInstEventQueue[tid]->serviceEvents(thread[tid]->numInst); |
| 1143 | |
| 1144 | // Broadcast to other resources an instruction |
| 1145 | // has been completed |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 1146 | resPool->scheduleEvent((CPUEventType)ResourcePool::InstGraduated, inst, |
| 1147 | tid); |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1148 | |
| 1149 | // Finally, remove instruction from CPU |
| 1150 | removeInst(inst); |
| 1151 | } |
| 1152 | |
| 1153 | void |
| 1154 | InOrderCPU::addToRemoveList(DynInstPtr &inst) |
| 1155 | { |
| 1156 | removeInstsThisCycle = true; |
| 1157 | |
| 1158 | removeList.push(inst->getInstListIt()); |
| 1159 | } |
| 1160 | |
| 1161 | void |
| 1162 | InOrderCPU::removeInst(DynInstPtr &inst) |
| 1163 | { |
| 1164 | DPRINTF(InOrderCPU, "Removing graduated instruction [tid:%i] PC %#x " |
| 1165 | "[sn:%lli]\n", |
| 1166 | inst->threadNumber, inst->readPC(), inst->seqNum); |
| 1167 | |
| 1168 | removeInstsThisCycle = true; |
| 1169 | |
| 1170 | // Remove the instruction. |
| 1171 | removeList.push(inst->getInstListIt()); |
| 1172 | } |
| 1173 | |
| 1174 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1175 | InOrderCPU::removeInstsUntil(const InstSeqNum &seq_num, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1176 | { |
| 1177 | //assert(!instList[tid].empty()); |
| 1178 | |
| 1179 | removeInstsThisCycle = true; |
| 1180 | |
| 1181 | ListIt inst_iter = instList[tid].end(); |
| 1182 | |
| 1183 | inst_iter--; |
| 1184 | |
| 1185 | DPRINTF(InOrderCPU, "Deleting instructions from CPU instruction " |
| 1186 | "list that are from [tid:%i] and above [sn:%lli] (end=%lli).\n", |
| 1187 | tid, seq_num, (*inst_iter)->seqNum); |
| 1188 | |
| 1189 | while ((*inst_iter)->seqNum > seq_num) { |
| 1190 | |
| 1191 | bool break_loop = (inst_iter == instList[tid].begin()); |
| 1192 | |
| 1193 | squashInstIt(inst_iter, tid); |
| 1194 | |
| 1195 | inst_iter--; |
| 1196 | |
| 1197 | if (break_loop) |
| 1198 | break; |
| 1199 | } |
| 1200 | } |
| 1201 | |
| 1202 | |
| 1203 | inline void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1204 | InOrderCPU::squashInstIt(const ListIt &instIt, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1205 | { |
| 1206 | if ((*instIt)->threadNumber == tid) { |
| 1207 | DPRINTF(InOrderCPU, "Squashing instruction, " |
| 1208 | "[tid:%i] [sn:%lli] PC %#x\n", |
| 1209 | (*instIt)->threadNumber, |
| 1210 | (*instIt)->seqNum, |
| 1211 | (*instIt)->readPC()); |
| 1212 | |
| 1213 | (*instIt)->setSquashed(); |
| 1214 | |
| 1215 | removeList.push(instIt); |
| 1216 | } |
| 1217 | } |
| 1218 | |
| 1219 | |
| 1220 | void |
| 1221 | InOrderCPU::cleanUpRemovedInsts() |
| 1222 | { |
| 1223 | while (!removeList.empty()) { |
| 1224 | DPRINTF(InOrderCPU, "Removing instruction, " |
| 1225 | "[tid:%i] [sn:%lli] PC %#x\n", |
| 1226 | (*removeList.front())->threadNumber, |
| 1227 | (*removeList.front())->seqNum, |
| 1228 | (*removeList.front())->readPC()); |
| 1229 | |
| 1230 | DynInstPtr inst = *removeList.front(); |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1231 | ThreadID tid = inst->threadNumber; |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1232 | |
| 1233 | // Make Sure Resource Schedule Is Emptied Out |
| 1234 | ThePipeline::ResSchedule *inst_sched = &inst->resSched; |
| 1235 | while (!inst_sched->empty()) { |
| 1236 | ThePipeline::ScheduleEntry* sch_entry = inst_sched->top(); |
| 1237 | inst_sched->pop(); |
| 1238 | delete sch_entry; |
| 1239 | } |
| 1240 | |
| 1241 | // Remove From Register Dependency Map, If Necessary |
| 1242 | archRegDepMap[(*removeList.front())->threadNumber]. |
| 1243 | remove((*removeList.front())); |
| 1244 | |
| 1245 | |
| 1246 | // Clear if Non-Speculative |
| 1247 | if (inst->staticInst && |
| 1248 | inst->seqNum == nonSpecSeqNum[tid] && |
| 1249 | nonSpecInstActive[tid] == true) { |
| 1250 | nonSpecInstActive[tid] = false; |
| 1251 | } |
| 1252 | |
| 1253 | instList[tid].erase(removeList.front()); |
| 1254 | |
| 1255 | removeList.pop(); |
| 1256 | |
| 1257 | DPRINTF(RefCount, "pop from remove list: [sn:%i]: Refcount = %i.\n", |
| 1258 | inst->seqNum, |
| 1259 | 0/*inst->curCount()*/); |
| 1260 | |
| 1261 | } |
| 1262 | |
| 1263 | removeInstsThisCycle = false; |
| 1264 | } |
| 1265 | |
| 1266 | void |
| 1267 | InOrderCPU::cleanUpRemovedReqs() |
| 1268 | { |
| 1269 | while (!reqRemoveList.empty()) { |
| 1270 | ResourceRequest *res_req = reqRemoveList.front(); |
| 1271 | |
| 1272 | DPRINTF(RefCount, "[tid:%i]: Removing Request, " |
| 1273 | "[sn:%lli] [slot:%i] [stage_num:%i] [res:%s] [refcount:%i].\n", |
| 1274 | res_req->inst->threadNumber, |
| 1275 | res_req->inst->seqNum, |
| 1276 | res_req->getSlot(), |
| 1277 | res_req->getStageNum(), |
| 1278 | res_req->res->name(), |
| 1279 | 0/*res_req->inst->curCount()*/); |
| 1280 | |
| 1281 | reqRemoveList.pop(); |
| 1282 | |
| 1283 | delete res_req; |
| 1284 | |
| 1285 | DPRINTF(RefCount, "after remove request: [sn:%i]: Refcount = %i.\n", |
| 1286 | res_req->inst->seqNum, |
| 1287 | 0/*res_req->inst->curCount()*/); |
| 1288 | } |
| 1289 | } |
| 1290 | |
| 1291 | void |
| 1292 | InOrderCPU::cleanUpRemovedEvents() |
| 1293 | { |
| 1294 | while (!cpuEventRemoveList.empty()) { |
| 1295 | Event *cpu_event = cpuEventRemoveList.front(); |
| 1296 | cpuEventRemoveList.pop(); |
| 1297 | delete cpu_event; |
| 1298 | } |
| 1299 | } |
| 1300 | |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1301 | |
| 1302 | void |
| 1303 | InOrderCPU::dumpInsts() |
| 1304 | { |
| 1305 | int num = 0; |
| 1306 | |
| 1307 | ListIt inst_list_it = instList[0].begin(); |
| 1308 | |
| 1309 | cprintf("Dumping Instruction List\n"); |
| 1310 | |
| 1311 | while (inst_list_it != instList[0].end()) { |
| 1312 | cprintf("Instruction:%i\nPC:%#x\n[tid:%i]\n[sn:%lli]\nIssued:%i\n" |
| 1313 | "Squashed:%i\n\n", |
| 1314 | num, (*inst_list_it)->readPC(), (*inst_list_it)->threadNumber, |
| 1315 | (*inst_list_it)->seqNum, (*inst_list_it)->isIssued(), |
| 1316 | (*inst_list_it)->isSquashed()); |
| 1317 | inst_list_it++; |
| 1318 | ++num; |
| 1319 | } |
| 1320 | } |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1321 | |
| 1322 | void |
| 1323 | InOrderCPU::wakeCPU() |
| 1324 | { |
| 1325 | if (/*activityRec.active() || */tickEvent.scheduled()) { |
| 1326 | DPRINTF(Activity, "CPU already running.\n"); |
| 1327 | return; |
| 1328 | } |
| 1329 | |
| 1330 | DPRINTF(Activity, "Waking up CPU\n"); |
| 1331 | |
Korey Sewell | 30cd2d2 | 2009-03-04 13:17:08 -0500 | [diff] [blame] | 1332 | //@todo: figure out how to count idleCycles correctly |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1333 | //idleCycles += (curTick - 1) - lastRunningCycle; |
| 1334 | |
| 1335 | mainEventQueue.schedule(&tickEvent, curTick); |
| 1336 | } |
| 1337 | |
Korey Sewell | badb238 | 2009-09-15 01:44:48 -0400 | [diff] [blame] | 1338 | #if FULL_SYSTEM |
| 1339 | |
| 1340 | void |
| 1341 | InOrderCPU::wakeup() |
| 1342 | { |
| 1343 | if (this->thread[0]->status() != ThreadContext::Suspended) |
| 1344 | return; |
| 1345 | |
| 1346 | this->wakeCPU(); |
| 1347 | |
| 1348 | DPRINTF(Quiesce, "Suspended Processor woken\n"); |
| 1349 | this->threadContexts[0]->activate(); |
| 1350 | } |
| 1351 | #endif |
| 1352 | |
| 1353 | #if !FULL_SYSTEM |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1354 | void |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 1355 | InOrderCPU::syscall(int64_t callnum, ThreadID tid) |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1356 | { |
| 1357 | DPRINTF(InOrderCPU, "[tid:%i] Executing syscall().\n\n", tid); |
| 1358 | |
| 1359 | DPRINTF(Activity,"Activity: syscall() called.\n"); |
| 1360 | |
| 1361 | // Temporarily increase this by one to account for the syscall |
| 1362 | // instruction. |
| 1363 | ++(this->thread[tid]->funcExeInst); |
| 1364 | |
| 1365 | // Execute the actual syscall. |
| 1366 | this->thread[tid]->syscall(callnum); |
| 1367 | |
| 1368 | // Decrease funcExeInst by one as the normal commit will handle |
| 1369 | // incrementing it. |
| 1370 | --(this->thread[tid]->funcExeInst); |
| 1371 | |
| 1372 | // Clear Non-Speculative Block Variable |
| 1373 | nonSpecInstActive[tid] = false; |
| 1374 | } |
Korey Sewell | badb238 | 2009-09-15 01:44:48 -0400 | [diff] [blame] | 1375 | #endif |
Korey Sewell | 973d8b8 | 2009-02-10 15:49:29 -0800 | [diff] [blame] | 1376 | |
Korey Sewell | 1c7e988 | 2009-05-12 15:01:15 -0400 | [diff] [blame] | 1377 | void |
| 1378 | InOrderCPU::prefetch(DynInstPtr inst) |
| 1379 | { |
| 1380 | Resource *mem_res = resPool->getResource(dataPortIdx); |
| 1381 | return mem_res->prefetch(inst); |
| 1382 | } |
| 1383 | |
| 1384 | void |
| 1385 | InOrderCPU::writeHint(DynInstPtr inst) |
| 1386 | { |
| 1387 | Resource *mem_res = resPool->getResource(dataPortIdx); |
| 1388 | return mem_res->writeHint(inst); |
| 1389 | } |
| 1390 | |
| 1391 | |
Korey Sewell | 5127ea2 | 2009-05-12 15:01:14 -0400 | [diff] [blame] | 1392 | TheISA::TLB* |
Korey Sewell | 1c8dfd9 | 2009-05-12 15:01:13 -0400 | [diff] [blame] | 1393 | InOrderCPU::getITBPtr() |
| 1394 | { |
Korey Sewell | db2b721 | 2009-05-12 15:01:16 -0400 | [diff] [blame] | 1395 | CacheUnit *itb_res = |
| 1396 | dynamic_cast<CacheUnit*>(resPool->getResource(fetchPortIdx)); |
Korey Sewell | 5127ea2 | 2009-05-12 15:01:14 -0400 | [diff] [blame] | 1397 | return itb_res->tlb(); |
Korey Sewell | 1c8dfd9 | 2009-05-12 15:01:13 -0400 | [diff] [blame] | 1398 | } |
| 1399 | |
| 1400 | |
Korey Sewell | 5127ea2 | 2009-05-12 15:01:14 -0400 | [diff] [blame] | 1401 | TheISA::TLB* |
Korey Sewell | 1c8dfd9 | 2009-05-12 15:01:13 -0400 | [diff] [blame] | 1402 | InOrderCPU::getDTBPtr() |
| 1403 | { |
Korey Sewell | db2b721 | 2009-05-12 15:01:16 -0400 | [diff] [blame] | 1404 | CacheUnit *dtb_res = |
| 1405 | dynamic_cast<CacheUnit*>(resPool->getResource(dataPortIdx)); |
Korey Sewell | 5127ea2 | 2009-05-12 15:01:14 -0400 | [diff] [blame] | 1406 | return dtb_res->tlb(); |
Korey Sewell | 1c8dfd9 | 2009-05-12 15:01:13 -0400 | [diff] [blame] | 1407 | } |
Korey Sewell | db2b721 | 2009-05-12 15:01:16 -0400 | [diff] [blame] | 1408 | |
| 1409 | template <class T> |
| 1410 | Fault |
| 1411 | InOrderCPU::read(DynInstPtr inst, Addr addr, T &data, unsigned flags) |
| 1412 | { |
| 1413 | //@TODO: Generalize name "CacheUnit" to "MemUnit" just in case |
| 1414 | // you want to run w/out caches? |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 1415 | CacheUnit *cache_res = |
| 1416 | dynamic_cast<CacheUnit*>(resPool->getResource(dataPortIdx)); |
Korey Sewell | db2b721 | 2009-05-12 15:01:16 -0400 | [diff] [blame] | 1417 | |
| 1418 | return cache_res->read(inst, addr, data, flags); |
| 1419 | } |
| 1420 | |
| 1421 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 1422 | |
| 1423 | template |
| 1424 | Fault |
| 1425 | InOrderCPU::read(DynInstPtr inst, Addr addr, Twin32_t &data, unsigned flags); |
| 1426 | |
| 1427 | template |
| 1428 | Fault |
| 1429 | InOrderCPU::read(DynInstPtr inst, Addr addr, Twin64_t &data, unsigned flags); |
| 1430 | |
| 1431 | template |
| 1432 | Fault |
| 1433 | InOrderCPU::read(DynInstPtr inst, Addr addr, uint64_t &data, unsigned flags); |
| 1434 | |
| 1435 | template |
| 1436 | Fault |
| 1437 | InOrderCPU::read(DynInstPtr inst, Addr addr, uint32_t &data, unsigned flags); |
| 1438 | |
| 1439 | template |
| 1440 | Fault |
| 1441 | InOrderCPU::read(DynInstPtr inst, Addr addr, uint16_t &data, unsigned flags); |
| 1442 | |
| 1443 | template |
| 1444 | Fault |
| 1445 | InOrderCPU::read(DynInstPtr inst, Addr addr, uint8_t &data, unsigned flags); |
| 1446 | |
| 1447 | #endif //DOXYGEN_SHOULD_SKIP_THIS |
| 1448 | |
| 1449 | template<> |
| 1450 | Fault |
| 1451 | InOrderCPU::read(DynInstPtr inst, Addr addr, double &data, unsigned flags) |
| 1452 | { |
| 1453 | return read(inst, addr, *(uint64_t*)&data, flags); |
| 1454 | } |
| 1455 | |
| 1456 | template<> |
| 1457 | Fault |
| 1458 | InOrderCPU::read(DynInstPtr inst, Addr addr, float &data, unsigned flags) |
| 1459 | { |
| 1460 | return read(inst, addr, *(uint32_t*)&data, flags); |
| 1461 | } |
| 1462 | |
| 1463 | |
| 1464 | template<> |
| 1465 | Fault |
| 1466 | InOrderCPU::read(DynInstPtr inst, Addr addr, int32_t &data, unsigned flags) |
| 1467 | { |
| 1468 | return read(inst, addr, (uint32_t&)data, flags); |
| 1469 | } |
| 1470 | |
| 1471 | template <class T> |
| 1472 | Fault |
| 1473 | InOrderCPU::write(DynInstPtr inst, T data, Addr addr, unsigned flags, |
| 1474 | uint64_t *write_res) |
| 1475 | { |
| 1476 | //@TODO: Generalize name "CacheUnit" to "MemUnit" just in case |
| 1477 | // you want to run w/out caches? |
| 1478 | CacheUnit *cache_res = |
| 1479 | dynamic_cast<CacheUnit*>(resPool->getResource(dataPortIdx)); |
| 1480 | return cache_res->write(inst, data, addr, flags, write_res); |
| 1481 | } |
| 1482 | |
| 1483 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 1484 | |
| 1485 | template |
| 1486 | Fault |
| 1487 | InOrderCPU::write(DynInstPtr inst, Twin32_t data, Addr addr, |
| 1488 | unsigned flags, uint64_t *res); |
| 1489 | |
| 1490 | template |
| 1491 | Fault |
| 1492 | InOrderCPU::write(DynInstPtr inst, Twin64_t data, Addr addr, |
| 1493 | unsigned flags, uint64_t *res); |
| 1494 | |
| 1495 | template |
| 1496 | Fault |
| 1497 | InOrderCPU::write(DynInstPtr inst, uint64_t data, Addr addr, |
| 1498 | unsigned flags, uint64_t *res); |
| 1499 | |
| 1500 | template |
| 1501 | Fault |
| 1502 | InOrderCPU::write(DynInstPtr inst, uint32_t data, Addr addr, |
| 1503 | unsigned flags, uint64_t *res); |
| 1504 | |
| 1505 | template |
| 1506 | Fault |
| 1507 | InOrderCPU::write(DynInstPtr inst, uint16_t data, Addr addr, |
| 1508 | unsigned flags, uint64_t *res); |
| 1509 | |
| 1510 | template |
| 1511 | Fault |
| 1512 | InOrderCPU::write(DynInstPtr inst, uint8_t data, Addr addr, |
| 1513 | unsigned flags, uint64_t *res); |
| 1514 | |
| 1515 | #endif //DOXYGEN_SHOULD_SKIP_THIS |
| 1516 | |
| 1517 | template<> |
| 1518 | Fault |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 1519 | InOrderCPU::write(DynInstPtr inst, double data, Addr addr, unsigned flags, |
| 1520 | uint64_t *res) |
Korey Sewell | db2b721 | 2009-05-12 15:01:16 -0400 | [diff] [blame] | 1521 | { |
| 1522 | return write(inst, *(uint64_t*)&data, addr, flags, res); |
| 1523 | } |
| 1524 | |
| 1525 | template<> |
| 1526 | Fault |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 1527 | InOrderCPU::write(DynInstPtr inst, float data, Addr addr, unsigned flags, |
| 1528 | uint64_t *res) |
Korey Sewell | db2b721 | 2009-05-12 15:01:16 -0400 | [diff] [blame] | 1529 | { |
| 1530 | return write(inst, *(uint32_t*)&data, addr, flags, res); |
| 1531 | } |
| 1532 | |
| 1533 | |
| 1534 | template<> |
| 1535 | Fault |
Korey Sewell | 7b3b362 | 2010-01-31 17:18:15 -0500 | [diff] [blame] | 1536 | InOrderCPU::write(DynInstPtr inst, int32_t data, Addr addr, unsigned flags, |
| 1537 | uint64_t *res) |
Korey Sewell | db2b721 | 2009-05-12 15:01:16 -0400 | [diff] [blame] | 1538 | { |
| 1539 | return write(inst, (uint32_t)data, addr, flags, res); |
| 1540 | } |