gem5 v24.0.0.0
Loading...
Searching...
No Matches
timing.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2013,2015,2018,2020-2021 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2002-2005 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#ifndef __CPU_SIMPLE_TIMING_HH__
42#define __CPU_SIMPLE_TIMING_HH__
43
44#include "arch/generic/mmu.hh"
45#include "cpu/simple/base.hh"
47#include "cpu/translation.hh"
48#include "params/BaseTimingSimpleCPU.hh"
49
50namespace gem5
51{
52
54{
55 public:
56
57 TimingSimpleCPU(const BaseTimingSimpleCPUParams &params);
58 virtual ~TimingSimpleCPU();
59
60 void init() override;
61
62 private:
63
64 /*
65 * If an access needs to be broken into fragments, currently at most two,
66 * the the following two classes are used as the sender state of the
67 * packets so the CPU can keep track of everything. In the main packet
68 * sender state, there's an array with a spot for each fragment. If a
69 * fragment has already been accepted by the CPU, aka isn't waiting for
70 * a retry, it's pointer is NULL. After each fragment has successfully
71 * been processed, the "outstanding" counter is decremented. Once the
72 * count is zero, the entire larger access is complete.
73 */
75 {
76 public:
79
80 int
82 {
83 if (fragments[0]) {
84 return 0;
85 } else if (fragments[1]) {
86 return 1;
87 } else {
88 return -1;
89 }
90 }
91 };
92
94 {
95 public:
96 SplitFragmentSenderState(PacketPtr _bigPkt, int _index) :
97 bigPkt(_bigPkt), index(_index)
98 {}
100 int index;
101
102 void
104 {
105 SplitMainSenderState * main_send_state =
106 dynamic_cast<SplitMainSenderState *>(bigPkt->senderState);
107 main_send_state->fragments[index] = NULL;
108 }
109 };
110
112 {
113 protected:
115
116 public:
118 : cpu(_cpu)
119 {}
120
121 void
127
128 void
129 finish(const Fault &fault, const RequestPtr &req, ThreadContext *tc,
131 {
132 cpu->sendFetch(fault, req, tc);
133 }
134 };
136
137 void threadSnoop(PacketPtr pkt, ThreadID sender);
138 void sendData(const RequestPtr &req,
139 uint8_t *data, uint64_t *res, bool read);
140 void sendSplitData(const RequestPtr &req1, const RequestPtr &req2,
141 const RequestPtr &req,
142 uint8_t *data, bool read);
143
144 void translationFault(const Fault &fault);
145
146 PacketPtr buildPacket(const RequestPtr &req, bool read);
147 void buildSplitPacket(PacketPtr &pkt1, PacketPtr &pkt2,
148 const RequestPtr &req1, const RequestPtr &req2,
149 const RequestPtr &req,
150 uint8_t *data, bool read);
151
152 bool handleReadPacket(PacketPtr pkt);
153 // This function always implicitly uses dcache_pkt.
154 bool handleWritePacket();
155
163 {
164 public:
165
166 TimingCPUPort(const std::string& _name, TimingSimpleCPU* _cpu)
167 : RequestPort(_name), cpu(_cpu),
168 retryRespEvent([this]{ sendRetryResp(); }, name())
169 { }
170
171 protected:
172
174
175 struct TickEvent : public Event
176 {
179
180 TickEvent(TimingSimpleCPU *_cpu) : pkt(NULL), cpu(_cpu) {}
181 const char *description() const { return "Timing CPU tick"; }
182 void schedule(PacketPtr _pkt, Tick t);
183 };
184
186 };
187
189 {
190 public:
191
193 : TimingCPUPort(_cpu->name() + ".icache_port", _cpu),
194 tickEvent(_cpu)
195 { }
196
197 protected:
198
199 virtual bool recvTimingResp(PacketPtr pkt);
200
201 virtual void recvReqRetry();
202
203 struct ITickEvent : public TickEvent
204 {
205
207 : TickEvent(_cpu) {}
208 void process();
209 const char *description() const { return "Timing CPU icache tick"; }
210 };
211
213
214 };
215
217 {
218 public:
219
221 : TimingCPUPort(_cpu->name() + ".dcache_port", _cpu),
222 tickEvent(_cpu)
223 {
224 cacheBlockMask = ~(cpu->cacheLineSize() - 1);
225 }
226
228 protected:
229
233 virtual void recvTimingSnoopReq(PacketPtr pkt);
234 virtual void recvFunctionalSnoop(PacketPtr pkt);
235
236 virtual bool recvTimingResp(PacketPtr pkt);
237
238 virtual void recvReqRetry();
239
240 virtual bool isSnooping() const {
241 return true;
242 }
243
244 struct DTickEvent : public TickEvent
245 {
247 : TickEvent(_cpu) {}
248 void process();
249 const char *description() const { return "Timing CPU dcache tick"; }
250 };
251
253
254 };
255
256 void updateCycleCounts();
257
260
263
265
266 protected:
267
269 Port &getDataPort() override { return dcachePort; }
270
272 Port &getInstPort() override { return icachePort; }
273
274 public:
275
276 DrainState drain() override;
277 void drainResume() override;
278
279 void switchOut() override;
280 void takeOverFrom(BaseCPU *oldCPU) override;
281
282 void verifyMemoryMode() const override;
283
284 void activateContext(ThreadID thread_num) override;
285 void suspendContext(ThreadID thread_num) override;
286
287 Fault initiateMemRead(Addr addr, unsigned size,
289 const std::vector<bool>& byte_enable =std::vector<bool>())
290 override;
291
292 Fault writeMem(uint8_t *data, unsigned size,
293 Addr addr, Request::Flags flags, uint64_t *res,
294 const std::vector<bool>& byte_enable = std::vector<bool>())
295 override;
296
298 AtomicOpFunctorPtr amo_op) override;
299
300 void fetch();
301 void sendFetch(const Fault &fault,
302 const RequestPtr &req, ThreadContext *tc);
305 void advanceInst(const Fault &fault);
306
313 bool isSquashed() const { return false; }
314
319 void printAddr(Addr a);
320
326
329
330 void htmSendAbortSignal(ThreadID tid, uint64_t htm_uid,
331 HtmFailureFaultCause) override;
332
333 private:
334
336
338 {
341 IprEvent(Packet *_pkt, TimingSimpleCPU *_cpu, Tick t);
342 virtual void process();
343 virtual const char *description() const;
344 };
345
362 bool isCpuDrained() const {
364 SimpleThread* thread = t_info.thread;
365
366 return thread->pcState().microPC() == 0 && !t_info.stayAtPC &&
368 }
369
375 bool tryCompleteDrain();
376};
377
378} // namespace gem5
379
380#endif // __CPU_SIMPLE_TIMING_HH__
const char data[]
Addr cacheLineSize() const
Get the cache line size of the system.
Definition base.hh:397
ThreadID curThread
Definition base.hh:86
std::vector< SimpleExecContext * > threadInfo
Definition base.hh:100
Cycles is a wrapper class for representing cycle counts, i.e.
Definition types.hh:79
const std::string _name
Definition named.hh:41
MicroPC microPC() const
Returns the current micropc.
Definition pcstate.hh:119
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
SenderState * senderState
This packet's sender state.
Definition packet.hh:545
Ports are used to interface objects to each other.
Definition port.hh:62
const std::string name() const
Return port name (for DPRINTF).
Definition port.hh:111
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition port.hh:136
virtual void sendRetryResp()
Send a retry to the response port that previously attempted a sendTimingResp to this request port and...
Definition port.hh:637
The SimpleThread object provides a combination of the ThreadState object and the ThreadContext interf...
const PCStateBase & pcState() const override
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition timing.cc:1165
virtual void recvTimingSnoopReq(PacketPtr pkt)
Snoop a coherence request, we need to check if this causes a wakeup event on a cpu that is monitoring...
Definition timing.cc:1090
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition timing.cc:1138
virtual void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the peer.
Definition timing.cc:1128
DcachePort(TimingSimpleCPU *_cpu)
Definition timing.hh:220
virtual bool isSnooping() const
Determine if this request port is snooping or not.
Definition timing.hh:240
FetchTranslation(TimingSimpleCPU *_cpu)
Definition timing.hh:117
void markDelayed()
Signal that the translation has been delayed due to a hw page table walk.
Definition timing.hh:122
void finish(const Fault &fault, const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode)
Definition timing.hh:129
virtual void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition timing.cc:929
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition timing.cc:907
IcachePort(TimingSimpleCPU *_cpu)
Definition timing.hh:192
SplitFragmentSenderState(PacketPtr _bigPkt, int _index)
Definition timing.hh:96
A TimingCPUPort overrides the default behaviour of the recvTiming and recvRetry and implements events...
Definition timing.hh:163
TimingCPUPort(const std::string &_name, TimingSimpleCPU *_cpu)
Definition timing.hh:166
EventFunctionWrapper retryRespEvent
Definition timing.hh:185
bool tryCompleteDrain()
Try to complete a drain request.
Definition timing.cc:153
Fault initiateMemMgmtCmd(Request::Flags flags) override
hardware transactional memory & TLBI operations
Definition timing.cc:1235
bool isCpuDrained() const
Check if a system is in a drained state.
Definition timing.hh:362
void advanceInst(const Fault &fault)
Definition timing.cc:753
void switchOut() override
Prepare for another CPU to take over execution.
Definition timing.cc:169
PacketPtr ifetch_pkt
Definition timing.hh:261
EventFunctionWrapper fetchEvent
Definition timing.hh:335
DrainState drain() override
Provide a default implementation of the drain interface for objects that don't need draining.
Definition timing.cc:91
void suspendContext(ThreadID thread_num) override
Notify the CPU that the indicated context is now suspended.
Definition timing.cc:232
void threadSnoop(PacketPtr pkt, ThreadID sender)
Definition timing.cc:637
void drainResume() override
Resume execution after a successful drain.
Definition timing.cc:118
Fault initiateMemRead(Addr addr, unsigned size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >()) override
Definition timing.cc:451
void htmSendAbortSignal(ThreadID tid, uint64_t htm_uid, HtmFailureFaultCause) override
This function is used to instruct the memory subsystem that a transaction should be aborted and the s...
Definition timing.cc:1285
bool handleReadPacket(PacketPtr pkt)
Definition timing.cc:262
Port & getDataPort() override
Return a reference to the data port.
Definition timing.hh:269
PacketPtr buildPacket(const RequestPtr &req, bool read)
Definition timing.cc:413
Fault writeMem(uint8_t *data, unsigned size, Addr addr, Request::Flags flags, uint64_t *res, const std::vector< bool > &byte_enable=std::vector< bool >()) override
Definition timing.cc:525
void sendSplitData(const RequestPtr &req1, const RequestPtr &req2, const RequestPtr &req, uint8_t *data, bool read)
Definition timing.cc:346
void translationFault(const Fault &fault)
Definition timing.cc:396
void sendData(const RequestPtr &req, uint8_t *data, uint64_t *res, bool read)
Definition timing.cc:297
FetchTranslation fetchTranslation
Definition timing.hh:135
void printAddr(Addr a)
Print state of address in memory system via PrintReq (for debugging).
Definition timing.cc:1229
PacketPtr dcache_pkt
Definition timing.hh:262
void verifyMemoryMode() const override
Verify that the system is in a memory mode supported by the CPU.
Definition timing.cc:199
void finishTranslation(WholeTranslationState *state)
Finish a DTB translation.
Definition timing.cc:651
void activateContext(ThreadID thread_num) override
Notify the CPU that the indicated context is now active.
Definition timing.cc:208
void completeIfetch(PacketPtr)
Definition timing.cc:819
TimingSimpleCPU(const BaseTimingSimpleCPUParams &params)
Definition timing.cc:76
void completeDataAccess(PacketPtr pkt)
Definition timing.cc:943
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition timing.cc:64
bool isSquashed() const
This function is used by the page table walker to determine if it could translate the a pending reque...
Definition timing.hh:313
Port & getInstPort() override
Return a reference to the instruction port.
Definition timing.hh:272
Fault initiateMemAMO(Addr addr, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op) override
Definition timing.cc:589
DcachePort dcachePort
Definition timing.hh:259
void buildSplitPacket(PacketPtr &pkt1, PacketPtr &pkt2, const RequestPtr &req1, const RequestPtr &req2, const RequestPtr &req, uint8_t *data, bool read)
Definition timing.cc:419
IcachePort icachePort
Definition timing.hh:258
virtual ~TimingSimpleCPU()
Definition timing.cc:86
void takeOverFrom(BaseCPU *oldCPU) override
Load the state of a CPU from the previous CPU object, invoked on all new CPUs that are about to be sw...
Definition timing.cc:191
void sendFetch(const Fault &fault, const RequestPtr &req, ThreadContext *tc)
Definition timing.cc:719
This class captures the state of an address translation.
STL vector class.
Definition stl.hh:37
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
Definition amo.hh:269
DrainState
Object drain/handover states.
Definition drain.hh:75
bool scheduled() const
Determine if the current event is scheduled.
Definition eventq.hh:458
const Params & params() const
atomic_var_t state
Definition helpers.cc:211
uint8_t flags
Definition helpers.cc:87
Bitfield< 4, 0 > mode
Definition misc_types.hh:74
Bitfield< 5 > t
Definition misc_types.hh:71
Bitfield< 8 > a
Definition misc_types.hh:66
Bitfield< 3 > addr
Definition types.hh:84
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
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58
HtmFailureFaultCause
Definition htm.hh:48
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition packet.hh:469
const char * description() const
Return a C string describing the event.
Definition timing.hh:249
const char * description() const
Return a C string describing the event.
Definition timing.hh:209
virtual const char * description() const
Return a C string describing the event.
Definition timing.cc:1222
IprEvent(Packet *_pkt, TimingSimpleCPU *_cpu, Tick t)
Definition timing.cc:1208
void schedule(PacketPtr _pkt, Tick t)
Definition timing.cc:70
const char * description() const
Return a C string describing the event.
Definition timing.hh:181

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