2 * Copyright (c) 2011-2012, 2014, 2018 ARM Limited
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
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.
15 * Copyright (c) 2004-2006 The Regents of The University of Michigan
16 * All rights reserved.
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.
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.
41 * Authors: Korey Sewell
44 #ifndef __CPU_O3_LSQ_HH__
45 #define __CPU_O3_LSQ_HH__
50 #include "arch/generic/tlb.hh"
51 #include "cpu/inst_seq.hh"
52 #include "cpu/o3/lsq_unit.hh"
53 #include "enums/SMTQueuePolicy.hh"
54 #include "mem/port.hh"
55 #include "sim/sim_object.hh"
57 struct DerivO3CPUParams;
64 typedef typename Impl::O3CPU O3CPU;
65 typedef typename Impl::DynInstPtr DynInstPtr;
66 typedef typename Impl::CPUPol::IEW IEW;
67 typedef typename Impl::CPUPol::LSQUnit LSQUnit;
70 /** Derived class to hold any sender state the LSQ needs. */
71 class LSQSenderState : public Packet::SenderState
74 /** The senderState needs to know the LSQRequest who owns it. */
77 /** Default constructor. */
78 LSQSenderState(LSQRequest* request, bool isLoad_)
79 : _request(request), mainPkt(nullptr), pendingPacket(nullptr),
80 outstanding(0), isLoad(isLoad_), needWB(isLoad_), isSplit(false),
81 pktToSend(false), deleted(false)
85 /** Instruction which initiated the access to memory. */
87 /** The main packet from a split load, used during writeback. */
89 /** A second packet from a split store that needs sending. */
90 PacketPtr pendingPacket;
91 /** Number of outstanding packets to complete. */
93 /** Whether or not it is a load. */
95 /** Whether or not the instruction will need to writeback. */
97 /** Whether or not this access is split in two. */
99 /** Whether or not there is a packet that needs sending. */
101 /** Has the request been deleted?
102 * LSQ entries can be squashed before the response comes back. in that
103 * case the SenderState knows.
106 ContextID contextId() { return inst->contextId(); }
108 /** Completes a packet and returns whether the access is finished. */
109 inline bool isComplete() { return outstanding == 0; }
110 inline void deleteRequest() { deleted = true; }
111 inline bool alive() { return !deleted; }
112 LSQRequest* request() { return _request; }
113 virtual void complete() = 0;
114 void writebackDone() { _request->writebackDone(); }
117 /** Memory operation metadata.
118 * This class holds the information about a memory operation. It lives
119 * from initiateAcc to resource deallocation at commit or squash.
120 * LSQRequest objects are owned by the LQ/SQ Entry in the LSQUnit that
121 * holds the operation. It is also used by the LSQSenderState. In addition,
122 * the LSQRequest is a TranslationState, therefore, upon squash, there must
123 * be a defined ownership transferal in case the LSQ resources are
124 * deallocated before the TLB is done using the TranslationState. If that
125 * happens, the LSQRequest will be self-owned, and responsible to detect
126 * that its services are no longer required and self-destruct.
128 * Lifetime of a LSQRequest:
129 * +--------------------+
130 * |LSQ creates and owns|
131 * +--------------------+
133 * +--------------------+
134 * | Initate translation|
135 * +--------------------+
139 * ______/ Squashed? \
144 * | +--------------------+
145 * | | Translation done |
146 * | +--------------------+
148 * | +--------------------+
149 * | | Send packet |<------+
150 * | +--------------------+ |
154 * | ____/ Squashed? \ |
161 * | | / Done? \__________|
166 * | | +--------------------+
167 * | | | Manage stuff |
168 * | | | Free resources |
169 * | | +--------------------+
171 * | | +--------------------+
172 * | | | senderState owns |
173 * | +->| onRecvTimingResp |
174 * | | free resources |
175 * | +--------------------+
177 * | +----------------------+
178 * | | self owned (Trans) |
179 * +-->| on TranslationFinish |
181 * +----------------------+
185 class LSQRequest : public BaseTLB::Translation
188 typedef uint32_t FlagsStorage;
189 typedef ::Flags<FlagsStorage> FlagsType;
191 enum Flag : FlagsStorage
194 /** True if this is a store/atomic that writes registers (SC). */
195 WbStore = 0x00000002,
196 Delayed = 0x00000004,
197 IsSplit = 0x00000008,
198 /** True if any translation has been sent to TLB. */
199 TranslationStarted = 0x00000010,
200 /** True if there are un-replied outbound translations.. */
201 TranslationFinished = 0x00000020,
204 Complete = 0x00000100,
205 /** Ownership tracking flags. */
206 /** Translation squashed. */
207 TranslationSquashed = 0x00000200,
208 /** Request discarded */
209 Discarded = 0x00000400,
210 /** LSQ resources freed. */
211 LSQEntryFreed = 0x00000800,
212 /** Store written back. */
213 WritebackScheduled = 0x00001000,
214 WritebackDone = 0x00002000,
215 /** True if this is an atomic request */
216 IsAtomic = 0x00004000
230 LSQSenderState* _senderState;
231 void setState(const State& newState) { _state = newState; }
233 uint32_t numTranslatedFragments;
234 uint32_t numInTranslationFragments;
236 /** LQ/SQ entry idx. */
239 void markDelayed() override { flags.set(Flag::Delayed); }
240 bool isDelayed() { return flags.isSet(Flag::Delayed); }
244 const DynInstPtr _inst;
247 std::vector<PacketPtr> _packets;
248 std::vector<RequestPtr> _requests;
249 std::vector<Fault> _fault;
252 const uint32_t _size;
253 const Request::Flags _flags;
254 uint32_t _numOutstandingPackets;
255 AtomicOpFunctor *_amo_op;
257 LSQUnit* lsqUnit() { return &_port; }
258 LSQRequest(LSQUnit* port, const DynInstPtr& inst, bool isLoad) :
259 _state(State::NotIssued), _senderState(nullptr),
260 _port(*port), _inst(inst), _data(nullptr),
261 _res(nullptr), _addr(0), _size(0), _flags(0),
262 _numOutstandingPackets(0), _amo_op(nullptr)
264 flags.set(Flag::IsLoad, isLoad);
265 flags.set(Flag::WbStore,
266 _inst->isStoreConditional() || _inst->isAtomic());
267 flags.set(Flag::IsAtomic, _inst->isAtomic());
270 LSQRequest(LSQUnit* port, const DynInstPtr& inst, bool isLoad,
271 const Addr& addr, const uint32_t& size,
272 const Request::Flags& flags_,
273 PacketDataPtr data = nullptr, uint64_t* res = nullptr,
274 AtomicOpFunctor* amo_op = nullptr)
275 : _state(State::NotIssued), _senderState(nullptr),
276 numTranslatedFragments(0),
277 numInTranslationFragments(0),
278 _port(*port), _inst(inst), _data(data),
279 _res(res), _addr(addr), _size(size),
281 _numOutstandingPackets(0),
284 flags.set(Flag::IsLoad, isLoad);
285 flags.set(Flag::WbStore,
286 _inst->isStoreConditional() || _inst->isAtomic());
287 flags.set(Flag::IsAtomic, _inst->isAtomic());
294 return flags.isSet(Flag::IsLoad);
300 return flags.isSet(Flag::IsAtomic);
303 /** Install the request in the LQ/SQ. */
307 _port.loadQueue[_inst->lqIdx].setRequest(this);
309 // Store, StoreConditional, and Atomic requests are pushed
310 // to this storeQueue
311 _port.storeQueue[_inst->sqIdx].setRequest(this);
315 squashed() const override
317 return _inst->isSquashed();
321 * Test if the LSQRequest has been released, i.e. self-owned.
322 * An LSQRequest manages itself when the resources on the LSQ are freed
323 * but the translation is still going on and the LSQEntry was freed.
328 return flags.isSet(Flag::LSQEntryFreed) ||
329 flags.isSet(Flag::Discarded);
332 /** Release the LSQRequest.
333 * Notify the sender state that the request it points to is not valid
334 * anymore. Understand if the request is orphan (self-managed) and if
335 * so, mark it as freed, else destroy it, as this means
336 * the end of its life cycle.
337 * An LSQRequest is orphan when its resources are released
338 * but there is any in-flight translation request to the TLB or access
339 * request to the memory.
341 void release(Flag reason)
343 assert(reason == Flag::LSQEntryFreed || reason == Flag::Discarded);
344 if (!isAnyOutstandingRequest()) {
348 _senderState->deleteRequest();
355 * The LSQRequest owns the request. If the packet has already been
356 * sent, the sender state will be deleted upon receiving the reply.
358 virtual ~LSQRequest()
360 assert(!isAnyOutstandingRequest());
361 _inst->savedReq = nullptr;
365 for (auto r: _packets)
371 /** Convenience getters/setters. */
373 /** Set up Context numbers. */
375 setContext(const ContextID& context_id)
377 request()->setContext(context_id);
386 /** Set up virtual request.
387 * For a previously allocated Request objects.
390 setVirt(int asid, Addr vaddr, unsigned size, Request::Flags flags_,
391 MasterID mid, Addr pc)
393 request()->setVirt(asid, vaddr, size, flags_, mid, pc);
397 taskId(const uint32_t& v)
400 for (auto& r: _requests)
404 uint32_t taskId() const { return _taskId; }
405 RequestPtr request(int idx = 0) { return _requests.at(idx); }
408 request(int idx = 0) const
410 return _requests.at(idx);
413 Addr getVaddr(int idx = 0) const { return request(idx)->getVaddr(); }
414 virtual void initiateTranslation() = 0;
416 PacketPtr packet(int idx = 0) { return _packets.at(idx); }
421 assert (_packets.size() == 1);
428 assert (_requests.size() == 1);
433 senderState(LSQSenderState* st)
436 for (auto& pkt: _packets) {
438 pkt->senderState = st;
442 const LSQSenderState*
449 * Mark senderState as discarded. This will cause to discard response
450 * packets from the cache.
455 assert(_senderState);
456 _senderState->deleteRequest();
460 * Test if there is any in-flight translation or mem access request
463 isAnyOutstandingRequest()
465 return numInTranslationFragments > 0 ||
466 _numOutstandingPackets > 0 ||
467 (flags.isSet(Flag::WritebackScheduled) &&
468 !flags.isSet(Flag::WritebackDone));
474 return flags.isSet(Flag::IsSplit);
477 virtual bool recvTimingResp(PacketPtr pkt) = 0;
478 virtual void sendPacketToCache() = 0;
479 virtual void buildPackets() = 0;
482 * Memory mapped IPR accesses
484 virtual void handleIprWrite(ThreadContext *thread, PacketPtr pkt) = 0;
485 virtual Cycles handleIprRead(ThreadContext *thread, PacketPtr pkt) = 0;
488 * Test if the request accesses a particular cache line.
490 virtual bool isCacheBlockHit(Addr blockAddr, Addr cacheBlockMask) = 0;
492 /** Update the status to reflect that a packet was sent. */
496 flags.set(Flag::Sent);
498 /** Update the status to reflect that a packet was not sent.
499 * When a packet fails to be sent, we mark the request as needing a
500 * retry. Note that Retry flag is sticky.
505 flags.set(Flag::Retry);
506 flags.clear(Flag::Sent);
509 void sendFragmentToTranslation(int i);
513 return flags.isSet(Flag::Complete);
519 return _state == State::Translation;
523 isTranslationComplete()
525 return flags.isSet(Flag::TranslationStarted) &&
530 isTranslationBlocked()
532 return _state == State::Translation &&
533 flags.isSet(Flag::TranslationStarted) &&
534 !flags.isSet(Flag::TranslationFinished);
540 return flags.isSet(Flag::Sent);
544 * The LSQ entry is cleared
549 release(Flag::LSQEntryFreed);
553 * The request is discarded (e.g. partial store-load forwarding)
558 release(Flag::Discarded);
564 assert(_numOutstandingPackets > 0);
565 _numOutstandingPackets--;
566 if (_numOutstandingPackets == 0 && isReleased())
573 assert(!flags.isSet(Flag::WritebackScheduled));
574 flags.set(Flag::WritebackScheduled);
580 flags.set(Flag::WritebackDone);
581 /* If the lsq resources are already free */
590 assert(numInTranslationFragments == 0);
591 flags.set(Flag::TranslationSquashed);
592 /* If we are on our own, self-destruct. */
601 flags.set(Flag::Complete);
605 class SingleDataRequest : public LSQRequest
608 /* Given that we are inside templates, children need explicit
609 * declaration of the names in the parent class. */
610 using Flag = typename LSQRequest::Flag;
611 using State = typename LSQRequest::State;
612 using LSQRequest::_fault;
613 using LSQRequest::_inst;
614 using LSQRequest::_packets;
615 using LSQRequest::_port;
616 using LSQRequest::_res;
617 using LSQRequest::_senderState;
618 using LSQRequest::_state;
619 using LSQRequest::flags;
620 using LSQRequest::isLoad;
621 using LSQRequest::isTranslationComplete;
622 using LSQRequest::lsqUnit;
623 using LSQRequest::request;
624 using LSQRequest::sendFragmentToTranslation;
625 using LSQRequest::setState;
626 using LSQRequest::numInTranslationFragments;
627 using LSQRequest::numTranslatedFragments;
628 using LSQRequest::_numOutstandingPackets;
629 using LSQRequest::_amo_op;
631 SingleDataRequest(LSQUnit* port, const DynInstPtr& inst, bool isLoad,
632 const Addr& addr, const uint32_t& size,
633 const Request::Flags& flags_,
634 PacketDataPtr data = nullptr,
635 uint64_t* res = nullptr,
636 AtomicOpFunctor* amo_op = nullptr) :
637 LSQRequest(port, inst, isLoad, addr, size, flags_, data, res,
640 LSQRequest::_requests.push_back(
641 std::make_shared<Request>(inst->getASID(), addr, size,
642 flags_, inst->masterId(), inst->instAddr(),
643 inst->contextId(), amo_op));
644 LSQRequest::_requests.back()->setReqInstSeqNum(inst->seqNum);
646 inline virtual ~SingleDataRequest() {}
647 virtual void initiateTranslation();
648 virtual void finish(const Fault &fault, const RequestPtr &req,
649 ThreadContext* tc, BaseTLB::Mode mode);
650 virtual bool recvTimingResp(PacketPtr pkt);
651 virtual void sendPacketToCache();
652 virtual void buildPackets();
653 virtual void handleIprWrite(ThreadContext *thread, PacketPtr pkt);
654 virtual Cycles handleIprRead(ThreadContext *thread, PacketPtr pkt);
655 virtual bool isCacheBlockHit(Addr blockAddr, Addr cacheBlockMask);
658 class SplitDataRequest : public LSQRequest
661 /* Given that we are inside templates, children need explicit
662 * declaration of the names in the parent class. */
663 using Flag = typename LSQRequest::Flag;
664 using State = typename LSQRequest::State;
665 using LSQRequest::_addr;
666 using LSQRequest::_data;
667 using LSQRequest::_fault;
668 using LSQRequest::_flags;
669 using LSQRequest::_inst;
670 using LSQRequest::_packets;
671 using LSQRequest::_port;
672 using LSQRequest::_requests;
673 using LSQRequest::_res;
674 using LSQRequest::_senderState;
675 using LSQRequest::_size;
676 using LSQRequest::_state;
677 using LSQRequest::_taskId;
678 using LSQRequest::flags;
679 using LSQRequest::isLoad;
680 using LSQRequest::isTranslationComplete;
681 using LSQRequest::lsqUnit;
682 using LSQRequest::numInTranslationFragments;
683 using LSQRequest::numTranslatedFragments;
684 using LSQRequest::request;
685 using LSQRequest::sendFragmentToTranslation;
686 using LSQRequest::setState;
687 using LSQRequest::_numOutstandingPackets;
689 uint32_t numFragments;
690 uint32_t numReceivedPackets;
692 PacketPtr _mainPacket;
696 SplitDataRequest(LSQUnit* port, const DynInstPtr& inst, bool isLoad,
697 const Addr& addr, const uint32_t& size,
698 const Request::Flags & flags_,
699 PacketDataPtr data = nullptr,
700 uint64_t* res = nullptr) :
701 LSQRequest(port, inst, isLoad, addr, size, flags_, data, res),
703 numReceivedPackets(0),
707 flags.set(Flag::IsSplit);
709 virtual ~SplitDataRequest()
716 _mainPacket = nullptr;
719 virtual void finish(const Fault &fault, const RequestPtr &req,
720 ThreadContext* tc, BaseTLB::Mode mode);
721 virtual bool recvTimingResp(PacketPtr pkt);
722 virtual void initiateTranslation();
723 virtual void sendPacketToCache();
724 virtual void buildPackets();
726 virtual void handleIprWrite(ThreadContext *thread, PacketPtr pkt);
727 virtual Cycles handleIprRead(ThreadContext *thread, PacketPtr pkt);
728 virtual bool isCacheBlockHit(Addr blockAddr, Addr cacheBlockMask);
730 virtual RequestPtr mainRequest();
731 virtual PacketPtr mainPacket();
734 /** Constructs an LSQ with the given parameters. */
735 LSQ(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params);
738 /** Returns the name of the LSQ. */
739 std::string name() const;
741 /** Registers statistics of each LSQ unit. */
744 /** Sets the pointer to the list of active threads. */
745 void setActiveThreads(std::list<ThreadID> *at_ptr);
747 /** Perform sanity checks after a drain. */
748 void drainSanityCheck() const;
749 /** Has the LSQ drained? */
750 bool isDrained() const;
751 /** Takes over execution from another CPU's thread. */
754 /** Number of entries needed for the given amount of threads.*/
755 int entryAmount(ThreadID num_threads);
757 /** Ticks the LSQ. */
760 /** Inserts a load into the LSQ. */
761 void insertLoad(const DynInstPtr &load_inst);
762 /** Inserts a store into the LSQ. */
763 void insertStore(const DynInstPtr &store_inst);
765 /** Executes a load. */
766 Fault executeLoad(const DynInstPtr &inst);
768 /** Executes a store. */
769 Fault executeStore(const DynInstPtr &inst);
772 * Commits loads up until the given sequence number for a specific thread.
774 void commitLoads(InstSeqNum &youngest_inst, ThreadID tid)
775 { thread.at(tid).commitLoads(youngest_inst); }
778 * Commits stores up until the given sequence number for a specific thread.
780 void commitStores(InstSeqNum &youngest_inst, ThreadID tid)
781 { thread.at(tid).commitStores(youngest_inst); }
784 * Attempts to write back stores until all cache ports are used or the
785 * interface becomes blocked.
787 void writebackStores();
788 /** Same as above, but only for one thread. */
789 void writebackStores(ThreadID tid);
792 * Squash instructions from a thread until the specified sequence number.
795 squash(const InstSeqNum &squashed_num, ThreadID tid)
797 thread.at(tid).squash(squashed_num);
800 /** Returns whether or not there was a memory ordering violation. */
803 * Returns whether or not there was a memory ordering violation for a
806 bool violation(ThreadID tid) { return thread.at(tid).violation(); }
808 /** Gets the instruction that caused the memory ordering violation. */
810 getMemDepViolator(ThreadID tid)
812 return thread.at(tid).getMemDepViolator();
815 /** Returns the head index of the load queue for a specific thread. */
816 int getLoadHead(ThreadID tid) { return thread.at(tid).getLoadHead(); }
818 /** Returns the sequence number of the head of the load queue. */
820 getLoadHeadSeqNum(ThreadID tid)
822 return thread.at(tid).getLoadHeadSeqNum();
825 /** Returns the head index of the store queue. */
826 int getStoreHead(ThreadID tid) { return thread.at(tid).getStoreHead(); }
828 /** Returns the sequence number of the head of the store queue. */
830 getStoreHeadSeqNum(ThreadID tid)
832 return thread.at(tid).getStoreHeadSeqNum();
835 /** Returns the number of instructions in all of the queues. */
837 /** Returns the number of instructions in the queues of one thread. */
838 int getCount(ThreadID tid) { return thread.at(tid).getCount(); }
840 /** Returns the total number of loads in the load queue. */
842 /** Returns the total number of loads for a single thread. */
843 int numLoads(ThreadID tid) { return thread.at(tid).numLoads(); }
845 /** Returns the total number of stores in the store queue. */
847 /** Returns the total number of stores for a single thread. */
848 int numStores(ThreadID tid) { return thread.at(tid).numStores(); }
850 /** Returns the number of free load entries. */
851 unsigned numFreeLoadEntries();
853 /** Returns the number of free store entries. */
854 unsigned numFreeStoreEntries();
856 /** Returns the number of free entries for a specific thread. */
857 unsigned numFreeEntries(ThreadID tid);
859 /** Returns the number of free entries in the LQ for a specific thread. */
860 unsigned numFreeLoadEntries(ThreadID tid);
862 /** Returns the number of free entries in the SQ for a specific thread. */
863 unsigned numFreeStoreEntries(ThreadID tid);
865 /** Returns if the LSQ is full (either LQ or SQ is full). */
868 * Returns if the LSQ is full for a specific thread (either LQ or SQ is
871 bool isFull(ThreadID tid);
873 /** Returns if the LSQ is empty (both LQ and SQ are empty). */
874 bool isEmpty() const;
875 /** Returns if all of the LQs are empty. */
876 bool lqEmpty() const;
877 /** Returns if all of the SQs are empty. */
878 bool sqEmpty() const;
880 /** Returns if any of the LQs are full. */
882 /** Returns if the LQ of a given thread is full. */
883 bool lqFull(ThreadID tid);
885 /** Returns if any of the SQs are full. */
887 /** Returns if the SQ of a given thread is full. */
888 bool sqFull(ThreadID tid);
891 * Returns if the LSQ is stalled due to a memory operation that must be
896 * Returns if the LSQ of a specific thread is stalled due to a memory
897 * operation that must be replayed.
899 bool isStalled(ThreadID tid);
901 /** Returns whether or not there are any stores to write back to memory. */
902 bool hasStoresToWB();
904 /** Returns whether or not a specific thread has any stores to write back
907 bool hasStoresToWB(ThreadID tid) { return thread.at(tid).hasStoresToWB(); }
909 /** Returns the number of stores a specific thread has to write back. */
910 int numStoresToWB(ThreadID tid) { return thread.at(tid).numStoresToWB(); }
912 /** Returns if the LSQ will write back to memory this cycle. */
914 /** Returns if the LSQ of a specific thread will write back to memory this
917 bool willWB(ThreadID tid) { return thread.at(tid).willWB(); }
919 /** Debugging function to print out all instructions. */
920 void dumpInsts() const;
921 /** Debugging function to print out instructions from a specific thread. */
922 void dumpInsts(ThreadID tid) const { thread.at(tid).dumpInsts(); }
924 /** Executes a read operation, using the load specified at the load
927 Fault read(LSQRequest* req, int load_idx);
929 /** Executes a store operation, using the store specified at the store
932 Fault write(LSQRequest* req, uint8_t *data, int store_idx);
935 * Retry the previous send that failed.
939 void completeDataAccess(PacketPtr pkt);
941 * Handles writing back and completing the load or store that has
942 * returned from memory.
944 * @param pkt Response packet from the memory sub-system
946 bool recvTimingResp(PacketPtr pkt);
948 void recvTimingSnoopReq(PacketPtr pkt);
950 Fault pushRequest(const DynInstPtr& inst, bool isLoad, uint8_t *data,
951 unsigned int size, Addr addr, Request::Flags flags,
952 uint64_t *res, AtomicOpFunctor *amo_op);
954 /** The CPU pointer. */
957 /** The IEW stage pointer. */
960 /** Is D-cache blocked? */
961 bool cacheBlocked() const;
962 /** Set D-cache blocked status */
963 void cacheBlocked(bool v);
964 /** Is any store port available to use? */
965 bool cachePortAvailable(bool is_load) const;
966 /** Another store port is in use */
967 void cachePortBusy(bool is_load);
970 /** D-cache is blocked */
972 /** The number of cache ports available each cycle (stores only). */
974 /** The number of used cache ports in this cycle by stores. */
976 /** The number of cache ports available each cycle (loads only). */
978 /** The number of used cache ports in this cycle by loads. */
982 /** The LSQ policy for SMT mode. */
983 SMTQueuePolicy lsqPolicy;
985 /** Auxiliary function to calculate per-thread max LSQ allocation limit.
986 * Depending on a policy, number of entries and possibly number of threads
987 * and threshold, this function calculates how many resources each thread
988 * can occupy at most.
991 maxLSQAllocation(SMTQueuePolicy pol, uint32_t entries,
992 uint32_t numThreads, uint32_t SMTThreshold)
994 if (pol == SMTQueuePolicy::Dynamic) {
996 } else if (pol == SMTQueuePolicy::Partitioned) {
997 //@todo:make work if part_amt doesnt divide evenly.
998 return entries / numThreads;
999 } else if (pol == SMTQueuePolicy::Threshold) {
1000 //Divide up by threshold amount
1001 //@todo: Should threads check the max and the total
1003 return SMTThreshold;
1008 /** List of Active Threads in System. */
1009 std::list<ThreadID> *activeThreads;
1011 /** Total Size of LQ Entries. */
1013 /** Total Size of SQ Entries. */
1016 /** Max LQ Size - Used to Enforce Sharing Policies. */
1017 unsigned maxLQEntries;
1019 /** Max SQ Size - Used to Enforce Sharing Policies. */
1020 unsigned maxSQEntries;
1022 /** The LSQ units for individual threads. */
1023 std::vector<LSQUnit> thread;
1025 /** Number of Threads. */
1026 ThreadID numThreads;
1029 template <class Impl>
1031 LSQ<Impl>::read(LSQRequest* req, int load_idx)
1033 ThreadID tid = cpu->contextToThread(req->request()->contextId());
1035 return thread.at(tid).read(req, load_idx);
1038 template <class Impl>
1040 LSQ<Impl>::write(LSQRequest* req, uint8_t *data, int store_idx)
1042 ThreadID tid = cpu->contextToThread(req->request()->contextId());
1044 return thread.at(tid).write(req, data, store_idx);
1047 #endif // __CPU_O3_LSQ_HH__