gem5  v20.0.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
base.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012,2015,2018 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 "base/statistics.hh"
46 #include "config/the_isa.hh"
47 #include "cpu/base.hh"
48 #include "cpu/checker/cpu.hh"
49 #include "cpu/exec_context.hh"
50 #include "cpu/pc_event.hh"
51 #include "cpu/simple_thread.hh"
52 #include "cpu/static_inst.hh"
53 #include "mem/packet.hh"
54 #include "mem/port.hh"
55 #include "mem/request.hh"
56 #include "sim/eventq.hh"
57 #include "sim/full_system.hh"
58 #include "sim/system.hh"
59 
60 // forward declarations
61 class Checkpoint;
62 class Process;
63 class Processor;
64 class ThreadContext;
65 
66 namespace TheISA
67 {
68  class DTB;
69  class ITB;
70 }
71 
72 namespace Trace {
73  class InstRecord;
74 }
75 
76 struct BaseSimpleCPUParams;
77 class BPredUnit;
78 class SimpleExecContext;
79 
80 class BaseSimpleCPU : public BaseCPU
81 {
82  protected:
85 
86  void checkPcEventQueue();
87  void swapActiveThread();
88 
89  public:
90  BaseSimpleCPU(BaseSimpleCPUParams *params);
91  virtual ~BaseSimpleCPU();
92  void wakeup(ThreadID tid) override;
93  void init() override;
94  public:
97 
100 
105 
106  protected:
107  enum Status {
119  };
120 
122 
123  public:
124  void checkForInterrupts();
125  void setupFetchRequest(const RequestPtr &req);
126  void preExecute();
127  void postExecute();
128  void advancePC(const Fault &fault);
129 
130  void haltContext(ThreadID thread_num) override;
131 
132  // statistics
133  void regStats() override;
134  void resetStats() override;
135 
136  void startup() override;
137 
138  virtual Fault readMem(Addr addr, uint8_t* data, unsigned size,
139  Request::Flags flags,
140  const std::vector<bool>& byte_enable =
142  { panic("readMem() is not implemented\n"); }
143 
144  virtual Fault initiateMemRead(Addr addr, unsigned size,
145  Request::Flags flags,
146  const std::vector<bool>& byte_enable =
148  { panic("initiateMemRead() is not implemented\n"); }
149 
150  virtual Fault writeMem(uint8_t* data, unsigned size, Addr addr,
151  Request::Flags flags, uint64_t* res,
152  const std::vector<bool>& byte_enable =
154  { panic("writeMem() is not implemented\n"); }
155 
156  virtual Fault amoMem(Addr addr, uint8_t* data, unsigned size,
157  Request::Flags flags,
158  AtomicOpFunctorPtr amo_op)
159  { panic("amoMem() is not implemented\n"); }
160 
161  virtual Fault initiateMemAMO(Addr addr, unsigned size,
162  Request::Flags flags,
163  AtomicOpFunctorPtr amo_op)
164  { panic("initiateMemAMO() is not implemented\n"); }
165 
166  void countInst();
167  Counter totalInsts() const override;
168  Counter totalOps() const override;
169 
170  void serializeThread(CheckpointOut &cp, ThreadID tid) const override;
171  void unserializeThread(CheckpointIn &cp, ThreadID tid) override;
172 
173 };
174 
175 #endif // __CPU_SIMPLE_BASE_HH__
StaticInstPtr curStaticInst
Definition: base.hh:103
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:163
uint32_t MachInst
Definition: types.hh:52
virtual Fault amoMem(Addr addr, uint8_t *data, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op)
Definition: base.hh:156
std::list< ThreadID > activeThreads
Definition: base.hh:99
CheckerCPU class.
Definition: cpu.hh:85
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
std::shared_ptr< Request > RequestPtr
Definition: request.hh:81
TheISA::MachInst inst
Current instruction.
Definition: base.hh:102
ip6_addr_t addr
Definition: inet.hh:330
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
Definition: amo.hh:228
ThreadID curThread
Definition: base.hh:83
Definition: cprintf.cc:40
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Declaration of Statistics objects.
STL vector class.
Definition: stl.hh:37
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:138
virtual Fault initiateMemAMO(Addr addr, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op)
Definition: base.hh:161
Port Object Declaration.
void advancePC(PCState &pc, const StaticInstPtr &inst)
Definition: utility.hh:393
Status _status
Definition: base.hh:121
StaticInstPtr curMacroStaticInst
Definition: base.hh:104
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
int64_t Counter
Statistics counter type.
Definition: types.hh:56
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:150
CheckerCPU * checker
Definition: base.hh:96
Basically a wrapper class to hold both the branch predictor and the BTB.
Definition: bpred_unit.hh:62
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:225
Declaration of the Packet class.
std::ostream CheckpointOut
Definition: serialize.hh:63
Trace::InstRecord * traceData
Definition: base.hh:95
std::vector< SimpleExecContext * > threadInfo
Definition: base.hh:98
virtual Fault initiateMemRead(Addr addr, unsigned size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >())
Definition: base.hh:144
const char data[]
std::shared_ptr< FaultBase > Fault
Definition: types.hh:238
const FlagsType init
This Stat is Initialized.
Definition: info.hh:45
BPredUnit * branchPred
Definition: base.hh:84

Generated on Mon Jun 8 2020 15:45:07 for gem5 by doxygen 1.8.13