gem5 v24.0.0.0
Loading...
Searching...
No Matches
base.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2012,2015,2018,2020-2021 ARM Limited
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder. You may use the software subject to the license
11 * terms below provided that you ensure that this notice is replicated
12 * unmodified and in its entirety in all distributions of the software,
13 * modified or unmodified, in source code or in binary form.
14 *
15 * Copyright (c) 2002-2005 The Regents of The University of Michigan
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met: redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer;
22 * redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution;
25 * neither the name of the copyright holders nor the names of its
26 * contributors may be used to endorse or promote products derived from
27 * this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 */
41
42#ifndef __CPU_SIMPLE_BASE_HH__
43#define __CPU_SIMPLE_BASE_HH__
44
45#include <memory>
46
48#include "base/statistics.hh"
49#include "cpu/base.hh"
50#include "cpu/checker/cpu.hh"
51#include "cpu/exec_context.hh"
52#include "cpu/pc_event.hh"
53#include "cpu/simple_thread.hh"
54#include "cpu/static_inst.hh"
55#include "mem/packet.hh"
56#include "mem/port.hh"
57#include "mem/request.hh"
58#include "sim/eventq.hh"
59#include "sim/full_system.hh"
60#include "sim/system.hh"
61
62namespace gem5
63{
64
65// forward declarations
66class Checkpoint;
67class Process;
68class Processor;
69class ThreadContext;
70
71namespace trace
72{
73 class InstRecord;
74}
75
76struct BaseSimpleCPUParams;
77namespace branch_prediction
78{
79 class BPredUnit;
80} // namespace branch_prediction
81class SimpleExecContext;
82
83class BaseSimpleCPU : public BaseCPU
84{
85 protected:
88
89 void checkPcEventQueue();
90 void swapActiveThread();
91
92 public:
93 BaseSimpleCPU(const BaseSimpleCPUParams &params);
94 virtual ~BaseSimpleCPU();
95 void wakeup(ThreadID tid) override;
96 public:
99
102
106
107 protected:
122
124
131 void traceFault();
132
133 std::unique_ptr<PCStateBase> preExecuteTempPC;
134
135 public:
136 void checkForInterrupts();
137 void setupFetchRequest(const RequestPtr &req);
139 void preExecute();
140 void postExecute();
141 void advancePC(const Fault &fault);
142
143 void haltContext(ThreadID thread_num) override;
144
145 // statistics
146 void resetStats() override;
147
148 virtual Fault
149 readMem(Addr addr, uint8_t* data, unsigned size, Request::Flags flags,
150 const std::vector<bool>& byte_enable=std::vector<bool>())
151 {
152 panic("readMem() is not implemented");
153 }
154
155 virtual Fault
157 const std::vector<bool>& byte_enable=std::vector<bool>())
158 {
159 panic("initiateMemRead() is not implemented\n");
160 }
161
162 virtual Fault
163 writeMem(uint8_t* data, unsigned size, Addr addr, Request::Flags flags,
164 uint64_t* res,
165 const std::vector<bool>& byte_enable=std::vector<bool>())
166 {
167 panic("writeMem() is not implemented\n");
168 }
169
170 virtual Fault
171 amoMem(Addr addr, uint8_t* data, unsigned size, Request::Flags flags,
172 AtomicOpFunctorPtr amo_op)
173 {
174 panic("amoMem() is not implemented\n");
175 }
176
177 virtual Fault
179 AtomicOpFunctorPtr amo_op)
180 {
181 panic("initiateMemAMO() is not implemented\n");
182 }
183
184 void countInst();
185 void countFetchInst();
186 void countCommitInst();
187 Counter totalInsts() const override;
188 Counter totalOps() const override;
189
190 void serializeThread(CheckpointOut &cp, ThreadID tid) const override;
191 void unserializeThread(CheckpointIn &cp, ThreadID tid) override;
192
201
202};
203
204} // namespace gem5
205
206#endif // __CPU_SIMPLE_BASE_HH__
const char data[]
void preExecute()
Definition base.cc:328
void checkPcEventQueue()
Definition base.cc:123
virtual Fault initiateMemRead(Addr addr, unsigned size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >())
Definition base.hh:156
virtual Fault readMem(Addr addr, uint8_t *data, unsigned size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >())
Definition base.hh:149
BaseSimpleCPU(const BaseSimpleCPUParams &params)
Definition base.cc:83
void serializeThread(CheckpointOut &cp, ThreadID tid) const override
Serialize a single thread.
Definition base.cc:232
void resetStats() override
Callback to reset stats.
Definition base.cc:223
branch_prediction::BPredUnit * branchPred
Definition base.hh:87
virtual ~BaseSimpleCPU()
Definition base.cc:210
ThreadID curThread
Definition base.hh:86
void unserializeThread(CheckpointIn &cp, ThreadID tid) override
Unserialize one thread.
Definition base.cc:240
void wakeup(ThreadID tid) override
Definition base.cc:251
StaticInstPtr curMacroStaticInst
Definition base.hh:105
void checkForInterrupts()
Definition base.cc:273
void traceFault()
Handler used when encountering a fault; its purpose is to tear down the InstRecord.
Definition base.cc:262
void advancePC(const Fault &fault)
Definition base.cc:493
void swapActiveThread()
Definition base.cc:135
void setupFetchRequest(const RequestPtr &req)
Definition base.cc:304
std::unique_ptr< PCStateBase > preExecuteTempPC
Definition base.hh:133
virtual Fault initiateMemMgmtCmd(Request::Flags flags)=0
Memory management commands such as hardware transactional memory commands or TLB invalidation command...
virtual Fault writeMem(uint8_t *data, unsigned size, Addr addr, Request::Flags flags, uint64_t *res, const std::vector< bool > &byte_enable=std::vector< bool >())
Definition base.hh:163
std::list< ThreadID > activeThreads
Definition base.hh:101
std::vector< SimpleExecContext * > threadInfo
Definition base.hh:100
Counter totalOps() const override
Definition base.cc:200
StaticInstPtr curStaticInst
Current instruction.
Definition base.hh:104
virtual Fault amoMem(Addr addr, uint8_t *data, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op)
Definition base.hh:171
Counter totalInsts() const override
Definition base.cc:189
CheckerCPU * checker
Definition base.hh:98
virtual Fault initiateMemAMO(Addr addr, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op)
Definition base.hh:178
void haltContext(ThreadID thread_num) override
Notify the CPU that the indicated context is now halted.
Definition base.cc:215
void postExecute()
Definition base.cc:412
void countCommitInst()
Definition base.cc:175
trace::InstRecord * traceData
Definition base.hh:97
void countFetchInst()
Definition base.cc:162
void serviceInstCountEvents()
Definition base.cc:321
CheckerCPU class.
Definition cpu.hh:85
Basically a wrapper class to hold both the branch predictor and the BTB.
Definition bpred_unit.hh:71
STL list class.
Definition stl.hh:51
STL vector class.
Definition stl.hh:37
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
Definition amo.hh:269
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
const Params & params() const
uint8_t flags
Definition helpers.cc:87
Port Object Declaration.
Bitfield< 3 > addr
Definition types.hh:84
double Counter
All counters are of 64-bit values.
Definition types.hh:46
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
int16_t ThreadID
Thread index/ID type.
Definition types.hh:235
std::shared_ptr< Request > RequestPtr
Definition request.hh:94
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
Declaration of the Packet class.
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
Declaration of Statistics objects.

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0