gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lsq_unit.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2014 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) 2004-2006 The Regents of The University of Michigan
15  * Copyright (c) 2013 Advanced Micro Devices, Inc.
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  * Authors: Kevin Lim
42  * Korey Sewell
43  */
44 
45 #ifndef __CPU_O3_LSQ_UNIT_HH__
46 #define __CPU_O3_LSQ_UNIT_HH__
47 
48 #include <algorithm>
49 #include <cstring>
50 #include <map>
51 #include <queue>
52 
54 #include "arch/isa_traits.hh"
55 #include "arch/locked_mem.hh"
56 #include "arch/mmapped_ipr.hh"
57 #include "config/the_isa.hh"
58 #include "cpu/inst_seq.hh"
59 #include "cpu/timebuf.hh"
60 #include "debug/LSQUnit.hh"
61 #include "mem/packet.hh"
62 #include "mem/port.hh"
63 
64 struct DerivO3CPUParams;
65 
78 template <class Impl>
79 class LSQUnit {
80  public:
81  typedef typename Impl::O3CPU O3CPU;
82  typedef typename Impl::DynInstPtr DynInstPtr;
83  typedef typename Impl::CPUPol::IEW IEW;
84  typedef typename Impl::CPUPol::LSQ LSQ;
85  typedef typename Impl::CPUPol::IssueStruct IssueStruct;
86 
87  public:
89  LSQUnit();
90 
92  void init(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params,
93  LSQ *lsq_ptr, unsigned maxLQEntries, unsigned maxSQEntries,
94  unsigned id);
95 
97  std::string name() const;
98 
100  void regStats();
101 
103  void setDcachePort(MasterPort *dcache_port);
104 
106  void drainSanityCheck() const;
107 
109  void takeOverFrom();
110 
116  void tick() { usedStorePorts = 0; }
117 
119  void insert(DynInstPtr &inst);
121  void insertLoad(DynInstPtr &load_inst);
123  void insertStore(DynInstPtr &store_inst);
124 
131  Fault checkViolations(int load_idx, DynInstPtr &inst);
132 
137  void checkSnoop(PacketPtr pkt);
138 
141 
142  Fault executeLoad(int lq_idx) { panic("Not implemented"); return NoFault; }
145 
147  void commitLoad();
149  void commitLoads(InstSeqNum &youngest_inst);
150 
152  void commitStores(InstSeqNum &youngest_inst);
153 
155  void writebackStores();
156 
159  void completeDataAccess(PacketPtr pkt);
160 
162  void clearLQ();
163 
165  void clearSQ();
166 
168  void resizeLQ(unsigned size);
169 
171  void resizeSQ(unsigned size);
172 
174  void squash(const InstSeqNum &squashed_num);
175 
179  bool violation() { return memDepViolator; }
180 
183 
185  unsigned numFreeLoadEntries();
186 
188  unsigned numFreeStoreEntries();
189 
191  int numLoads() { return loads; }
192 
194  int numStores() { return stores; }
195 
197  bool isFull() { return lqFull() || sqFull(); }
198 
200  bool isEmpty() const { return lqEmpty() && sqEmpty(); }
201 
203  bool lqFull() { return loads >= (LQEntries - 1); }
204 
206  bool sqFull() { return stores >= (SQEntries - 1); }
207 
209  bool lqEmpty() const { return loads == 0; }
210 
212  bool sqEmpty() const { return stores == 0; }
213 
215  unsigned getCount() { return loads + stores; }
216 
218  bool hasStoresToWB() { return storesToWB; }
219 
221  int numStoresToWB() { return storesToWB; }
222 
224  bool willWB() { return storeQueue[storeWBIdx].canWB &&
225  !storeQueue[storeWBIdx].completed &&
226  !isStoreBlocked; }
227 
229  void recvRetry();
230 
231  private:
233  void resetState();
234 
236  void writeback(DynInstPtr &inst, PacketPtr pkt);
237 
239  void writebackPendingStore();
240 
242  void storePostSend(PacketPtr pkt);
243 
245  void completeStore(int store_idx);
246 
248  bool sendStore(PacketPtr data_pkt);
249 
251  inline void incrStIdx(int &store_idx) const;
253  inline void decrStIdx(int &store_idx) const;
255  inline void incrLdIdx(int &load_idx) const;
257  inline void decrLdIdx(int &load_idx) const;
258 
259  public:
261  void dumpInsts() const;
262 
263  private:
266 
269 
272 
275 
278  {
279  public:
282  : mainPkt(NULL), pendingPacket(NULL), idx(0), outstanding(1),
283  isLoad(false), noWB(false), isSplit(false),
284  pktToSend(false), cacheBlocked(false)
285  { }
286 
294  uint8_t idx;
296  uint8_t outstanding;
298  bool isLoad;
300  bool noWB;
302  bool isSplit;
304  bool pktToSend;
307 
309  inline bool complete() { return --outstanding == 0; }
310  };
311 
313  class WritebackEvent : public Event {
314  public:
316  WritebackEvent(DynInstPtr &_inst, PacketPtr pkt, LSQUnit *lsq_ptr);
317 
319  void process();
320 
322  const char *description() const;
323 
324  private:
327 
330 
333  };
334 
335  public:
336  struct SQEntry {
339  : inst(NULL), req(NULL), size(0),
340  canWB(0), committed(0), completed(0)
341  {
342  std::memset(data, 0, sizeof(data));
343  }
344 
346  {
347  inst = NULL;
348  }
349 
352  : inst(_inst), req(NULL), sreqLow(NULL), sreqHigh(NULL), size(0),
353  isSplit(0), canWB(0), committed(0), completed(0), isAllZeros(0)
354  {
355  std::memset(data, 0, sizeof(data));
356  }
358  char data[16];
367  uint8_t size;
369  bool isSplit;
371  bool canWB;
373  bool committed;
375  bool completed;
381  };
382 
383  private:
386 
389 
392 
396  unsigned LQEntries;
400  unsigned SQEntries;
401 
405  unsigned depCheckShift;
406 
409 
411  int loads;
413  int stores;
416 
418  int loadHead;
420  int loadTail;
421 
430 
432 
434 
437 
438  //list<InstSeqNum> mshrSeqNums;
439 
442 
445 
447  bool stalled;
454 
457 
460 
463 
466 
470 
473 
475  bool needsTSO;
476 
477  // Will also need how many read/write ports the Dcache has. Or keep track
478  // of that in stage that is one level up, and only call executeLoad/Store
479  // the appropriate number of times.
482 
485 
488 
492 
495 
498 
501 
504 
507 
510 
511  public:
513  Fault read(Request *req, Request *sreqLow, Request *sreqHigh,
514  int load_idx);
515 
517  Fault write(Request *req, Request *sreqLow, Request *sreqHigh,
518  uint8_t *data, int store_idx);
519 
521  int getLoadHead() { return loadHead; }
524  {
525  if (loadQueue[loadHead]) {
526  return loadQueue[loadHead]->seqNum;
527  } else {
528  return 0;
529  }
530 
531  }
532 
534  int getStoreHead() { return storeHead; }
537  {
538  if (storeQueue[storeHead].inst) {
539  return storeQueue[storeHead].inst->seqNum;
540  } else {
541  return 0;
542  }
543 
544  }
545 
547  bool isStalled() { return stalled; }
548 };
549 
550 template <class Impl>
551 Fault
552 LSQUnit<Impl>::read(Request *req, Request *sreqLow, Request *sreqHigh,
553  int load_idx)
554 {
555  DynInstPtr load_inst = loadQueue[load_idx];
556 
557  assert(load_inst);
558 
559  assert(!load_inst->isExecuted());
560 
561  // Make sure this isn't a strictly ordered load
562  // A bit of a hackish way to get strictly ordered accesses to work
563  // only if they're at the head of the LSQ and are ready to commit
564  // (at the head of the ROB too).
565  if (req->isStrictlyOrdered() &&
566  (load_idx != loadHead || !load_inst->isAtCommit())) {
567  iewStage->rescheduleMemInst(load_inst);
568  ++lsqRescheduledLoads;
569  DPRINTF(LSQUnit, "Strictly ordered load [sn:%lli] PC %s\n",
570  load_inst->seqNum, load_inst->pcState());
571 
572  // Must delete request now that it wasn't handed off to
573  // memory. This is quite ugly. @todo: Figure out the proper
574  // place to really handle request deletes.
575  delete req;
576  if (TheISA::HasUnalignedMemAcc && sreqLow) {
577  delete sreqLow;
578  delete sreqHigh;
579  }
580  return std::make_shared<GenericISA::M5PanicFault>(
581  "Strictly ordered load [sn:%llx] PC %s\n",
582  load_inst->seqNum, load_inst->pcState());
583  }
584 
585  // Check the SQ for any previous stores that might lead to forwarding
586  int store_idx = load_inst->sqIdx;
587 
588  int store_size = 0;
589 
590  DPRINTF(LSQUnit, "Read called, load idx: %i, store idx: %i, "
591  "storeHead: %i addr: %#x%s\n",
592  load_idx, store_idx, storeHead, req->getPaddr(),
593  sreqLow ? " split" : "");
594 
595  if (req->isLLSC()) {
596  assert(!sreqLow);
597  // Disable recording the result temporarily. Writing to misc
598  // regs normally updates the result, but this is not the
599  // desired behavior when handling store conditionals.
600  load_inst->recordResult(false);
601  TheISA::handleLockedRead(load_inst.get(), req);
602  load_inst->recordResult(true);
603  }
604 
605  if (req->isMmappedIpr()) {
606  assert(!load_inst->memData);
607  load_inst->memData = new uint8_t[64];
608 
609  ThreadContext *thread = cpu->tcBase(lsqID);
610  Cycles delay(0);
611  PacketPtr data_pkt = new Packet(req, MemCmd::ReadReq);
612 
613  if (!TheISA::HasUnalignedMemAcc || !sreqLow) {
614  data_pkt->dataStatic(load_inst->memData);
615  delay = TheISA::handleIprRead(thread, data_pkt);
616  } else {
617  assert(sreqLow->isMmappedIpr() && sreqHigh->isMmappedIpr());
618  PacketPtr fst_data_pkt = new Packet(sreqLow, MemCmd::ReadReq);
619  PacketPtr snd_data_pkt = new Packet(sreqHigh, MemCmd::ReadReq);
620 
621  fst_data_pkt->dataStatic(load_inst->memData);
622  snd_data_pkt->dataStatic(load_inst->memData + sreqLow->getSize());
623 
624  delay = TheISA::handleIprRead(thread, fst_data_pkt);
625  Cycles delay2 = TheISA::handleIprRead(thread, snd_data_pkt);
626  if (delay2 > delay)
627  delay = delay2;
628 
629  delete sreqLow;
630  delete sreqHigh;
631  delete fst_data_pkt;
632  delete snd_data_pkt;
633  }
634  WritebackEvent *wb = new WritebackEvent(load_inst, data_pkt, this);
635  cpu->schedule(wb, cpu->clockEdge(delay));
636  return NoFault;
637  }
638 
639  while (store_idx != -1) {
640  // End once we've reached the top of the LSQ
641  if (store_idx == storeWBIdx) {
642  break;
643  }
644 
645  // Move the index to one younger
646  if (--store_idx < 0)
647  store_idx += SQEntries;
648 
649  assert(storeQueue[store_idx].inst);
650 
651  store_size = storeQueue[store_idx].size;
652 
653  if (store_size == 0)
654  continue;
655  else if (storeQueue[store_idx].inst->strictlyOrdered())
656  continue;
657 
658  assert(storeQueue[store_idx].inst->effAddrValid());
659 
660  // Check if the store data is within the lower and upper bounds of
661  // addresses that the request needs.
662  bool store_has_lower_limit =
663  req->getVaddr() >= storeQueue[store_idx].inst->effAddr;
664  bool store_has_upper_limit =
665  (req->getVaddr() + req->getSize()) <=
666  (storeQueue[store_idx].inst->effAddr + store_size);
667  bool lower_load_has_store_part =
668  req->getVaddr() < (storeQueue[store_idx].inst->effAddr +
669  store_size);
670  bool upper_load_has_store_part =
671  (req->getVaddr() + req->getSize()) >
672  storeQueue[store_idx].inst->effAddr;
673 
674  // If the store's data has all of the data needed and the load isn't
675  // LLSC, we can forward.
676  if (store_has_lower_limit && store_has_upper_limit && !req->isLLSC()) {
677  // Get shift amount for offset into the store's data.
678  int shift_amt = req->getVaddr() - storeQueue[store_idx].inst->effAddr;
679 
680  // Allocate memory if this is the first time a load is issued.
681  if (!load_inst->memData) {
682  load_inst->memData = new uint8_t[req->getSize()];
683  }
684  if (storeQueue[store_idx].isAllZeros)
685  memset(load_inst->memData, 0, req->getSize());
686  else
687  memcpy(load_inst->memData,
688  storeQueue[store_idx].data + shift_amt, req->getSize());
689 
690  DPRINTF(LSQUnit, "Forwarding from store idx %i to load to "
691  "addr %#x\n", store_idx, req->getVaddr());
692 
693  PacketPtr data_pkt = new Packet(req, MemCmd::ReadReq);
694  data_pkt->dataStatic(load_inst->memData);
695 
696  WritebackEvent *wb = new WritebackEvent(load_inst, data_pkt, this);
697 
698  // We'll say this has a 1 cycle load-store forwarding latency
699  // for now.
700  // @todo: Need to make this a parameter.
701  cpu->schedule(wb, curTick());
702 
703  // Don't need to do anything special for split loads.
704  if (TheISA::HasUnalignedMemAcc && sreqLow) {
705  delete sreqLow;
706  delete sreqHigh;
707  }
708 
709  ++lsqForwLoads;
710  return NoFault;
711  } else if (
712  (!req->isLLSC() &&
713  ((store_has_lower_limit && lower_load_has_store_part) ||
714  (store_has_upper_limit && upper_load_has_store_part) ||
715  (lower_load_has_store_part && upper_load_has_store_part))) ||
716  (req->isLLSC() &&
717  ((store_has_lower_limit || upper_load_has_store_part) &&
718  (store_has_upper_limit || lower_load_has_store_part)))) {
719  // This is the partial store-load forwarding case where a store
720  // has only part of the load's data and the load isn't LLSC or
721  // the load is LLSC and the store has all or part of the load's
722  // data
723 
724  // If it's already been written back, then don't worry about
725  // stalling on it.
726  if (storeQueue[store_idx].completed) {
727  panic("Should not check one of these");
728  continue;
729  }
730 
731  // Must stall load and force it to retry, so long as it's the oldest
732  // load that needs to do so.
733  if (!stalled ||
734  (stalled &&
735  load_inst->seqNum <
736  loadQueue[stallingLoadIdx]->seqNum)) {
737  stalled = true;
738  stallingStoreIsn = storeQueue[store_idx].inst->seqNum;
739  stallingLoadIdx = load_idx;
740  }
741 
742  // Tell IQ/mem dep unit that this instruction will need to be
743  // rescheduled eventually
744  iewStage->rescheduleMemInst(load_inst);
745  load_inst->clearIssued();
746  ++lsqRescheduledLoads;
747 
748  // Do not generate a writeback event as this instruction is not
749  // complete.
750  DPRINTF(LSQUnit, "Load-store forwarding mis-match. "
751  "Store idx %i to load addr %#x\n",
752  store_idx, req->getVaddr());
753 
754  // Must delete request now that it wasn't handed off to
755  // memory. This is quite ugly. @todo: Figure out the
756  // proper place to really handle request deletes.
757  delete req;
758  if (TheISA::HasUnalignedMemAcc && sreqLow) {
759  delete sreqLow;
760  delete sreqHigh;
761  }
762 
763  return NoFault;
764  }
765  }
766 
767  // If there's no forwarding case, then go access memory
768  DPRINTF(LSQUnit, "Doing memory access for inst [sn:%lli] PC %s\n",
769  load_inst->seqNum, load_inst->pcState());
770 
771  // Allocate memory if this is the first time a load is issued.
772  if (!load_inst->memData) {
773  load_inst->memData = new uint8_t[req->getSize()];
774  }
775 
776  // if we the cache is not blocked, do cache access
777  bool completedFirst = false;
778  PacketPtr data_pkt = Packet::createRead(req);
779  PacketPtr fst_data_pkt = NULL;
780  PacketPtr snd_data_pkt = NULL;
781 
782  data_pkt->dataStatic(load_inst->memData);
783 
784  LSQSenderState *state = new LSQSenderState;
785  state->isLoad = true;
786  state->idx = load_idx;
787  state->inst = load_inst;
788  data_pkt->senderState = state;
789 
790  if (!TheISA::HasUnalignedMemAcc || !sreqLow) {
791  // Point the first packet at the main data packet.
792  fst_data_pkt = data_pkt;
793  } else {
794  // Create the split packets.
795  fst_data_pkt = Packet::createRead(sreqLow);
796  snd_data_pkt = Packet::createRead(sreqHigh);
797 
798  fst_data_pkt->dataStatic(load_inst->memData);
799  snd_data_pkt->dataStatic(load_inst->memData + sreqLow->getSize());
800 
801  fst_data_pkt->senderState = state;
802  snd_data_pkt->senderState = state;
803 
804  state->isSplit = true;
805  state->outstanding = 2;
806  state->mainPkt = data_pkt;
807  }
808 
809  // For now, load throughput is constrained by the number of
810  // load FUs only, and loads do not consume a cache port (only
811  // stores do).
812  // @todo We should account for cache port contention
813  // and arbitrate between loads and stores.
814  bool successful_load = true;
815  if (!dcachePort->sendTimingReq(fst_data_pkt)) {
816  successful_load = false;
817  } else if (TheISA::HasUnalignedMemAcc && sreqLow) {
818  completedFirst = true;
819 
820  // The first packet was sent without problems, so send this one
821  // too. If there is a problem with this packet then the whole
822  // load will be squashed, so indicate this to the state object.
823  // The first packet will return in completeDataAccess and be
824  // handled there.
825  // @todo We should also account for cache port contention
826  // here.
827  if (!dcachePort->sendTimingReq(snd_data_pkt)) {
828  // The main packet will be deleted in completeDataAccess.
829  state->complete();
830  // Signify to 1st half that the 2nd half was blocked via state
831  state->cacheBlocked = true;
832  successful_load = false;
833  }
834  }
835 
836  // If the cache was blocked, or has become blocked due to the access,
837  // handle it.
838  if (!successful_load) {
839  if (!sreqLow) {
840  // Packet wasn't split, just delete main packet info
841  delete state;
842  delete req;
843  delete data_pkt;
844  }
845 
846  if (TheISA::HasUnalignedMemAcc && sreqLow) {
847  if (!completedFirst) {
848  // Split packet, but first failed. Delete all state.
849  delete state;
850  delete req;
851  delete data_pkt;
852  delete fst_data_pkt;
853  delete snd_data_pkt;
854  delete sreqLow;
855  delete sreqHigh;
856  sreqLow = NULL;
857  sreqHigh = NULL;
858  } else {
859  // Can't delete main packet data or state because first packet
860  // was sent to the memory system
861  delete data_pkt;
862  delete req;
863  delete sreqHigh;
864  delete snd_data_pkt;
865  sreqHigh = NULL;
866  }
867  }
868 
869  ++lsqCacheBlocked;
870 
871  iewStage->blockMemInst(load_inst);
872 
873  // No fault occurred, even though the interface is blocked.
874  return NoFault;
875  }
876 
877  return NoFault;
878 }
879 
880 template <class Impl>
881 Fault
882 LSQUnit<Impl>::write(Request *req, Request *sreqLow, Request *sreqHigh,
883  uint8_t *data, int store_idx)
884 {
885  assert(storeQueue[store_idx].inst);
886 
887  DPRINTF(LSQUnit, "Doing write to store idx %i, addr %#x"
888  " | storeHead:%i [sn:%i]\n",
889  store_idx, req->getPaddr(), storeHead,
890  storeQueue[store_idx].inst->seqNum);
891 
892  storeQueue[store_idx].req = req;
893  storeQueue[store_idx].sreqLow = sreqLow;
894  storeQueue[store_idx].sreqHigh = sreqHigh;
895  unsigned size = req->getSize();
896  storeQueue[store_idx].size = size;
897  storeQueue[store_idx].isAllZeros = req->getFlags() & Request::CACHE_BLOCK_ZERO;
898  assert(size <= sizeof(storeQueue[store_idx].data) ||
900 
901  // Split stores can only occur in ISAs with unaligned memory accesses. If
902  // a store request has been split, sreqLow and sreqHigh will be non-null.
903  if (TheISA::HasUnalignedMemAcc && sreqLow) {
904  storeQueue[store_idx].isSplit = true;
905  }
906 
907  if (!(req->getFlags() & Request::CACHE_BLOCK_ZERO))
908  memcpy(storeQueue[store_idx].data, data, size);
909 
910  // This function only writes the data to the store queue, so no fault
911  // can happen here.
912  return NoFault;
913 }
914 
915 #endif // __CPU_O3_LSQ_UNIT_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:167
#define DPRINTF(x,...)
Definition: trace.hh:212
int getStoreHead()
Returns the index of the head store instruction.
Definition: lsq_unit.hh:534
unsigned LQEntries
The number of LQ entries, plus a sentinel entry (circular queue).
Definition: lsq_unit.hh:396
MasterPort * dcachePort
Pointer to the dcache port.
Definition: lsq_unit.hh:274
unsigned numFreeLoadEntries()
Returns the number of free LQ entries.
void squash(const InstSeqNum &squashed_num)
Squashes all instructions younger than a specific sequence number.
bool isEmpty() const
Returns if both the LQ and SQ are empty.
Definition: lsq_unit.hh:200
Impl::DynInstPtr DynInstPtr
Definition: lsq_unit.hh:82
Fault checkViolations(int load_idx, DynInstPtr &inst)
Check for ordering violations in the LSQ.
int usedStorePorts
The number of used cache ports in this cycle by stores.
Definition: lsq_unit.hh:436
int getLoadHead()
Returns the index of the head load instruction.
Definition: lsq_unit.hh:521
decltype(nullptr) constexpr NoFault
Definition: types.hh:189
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
Stats::Scalar invAddrSwpfs
Total number of software prefetches ignored due to invalid addresses.
Definition: lsq_unit.hh:500
bool hasStoresToWB()
Returns if there are any stores to writeback.
Definition: lsq_unit.hh:218
void resizeSQ(unsigned size)
Resizes the SQ to a given size.
uint8_t idx
The LQ/SQ index of the instruction.
Definition: lsq_unit.hh:294
DynInstPtr memDepViolator
The oldest load that caused a memory ordering violation.
Definition: lsq_unit.hh:465
LSQSenderState()
Default constructor.
Definition: lsq_unit.hh:281
int numStores()
Returns the number of stores in the SQ.
Definition: lsq_unit.hh:194
Stats::Scalar lsqForwLoads
Total number of loads forwaded from LSQ stores.
Definition: lsq_unit.hh:481
bool isStoreBlocked
Whehter or not a store is blocked due to the memory system.
Definition: lsq_unit.hh:459
WritebackEvent(DynInstPtr &_inst, PacketPtr pkt, LSQUnit *lsq_ptr)
Constructs a writeback event.
#define panic(...)
Definition: misc.hh:153
void drainSanityCheck() const
Perform sanity checks after a drain.
std::vector< SQEntry > storeQueue
The store queue.
Definition: lsq_unit.hh:388
bool violation()
Returns if there is a memory ordering violation.
Definition: lsq_unit.hh:179
bool sqEmpty() const
Returns if the SQ is empty.
Definition: lsq_unit.hh:212
bool isStrictlyOrdered() const
Definition: request.hh:768
DynInstPtr getMemDepViolator()
Returns the memory ordering violator.
void decrStIdx(int &store_idx) const
Decrements the given store index (circular queue).
void completeStore(int store_idx)
Completes the store at the specified index.
int cacheStorePorts
The number of cache ports available each cycle (stores only).
Definition: lsq_unit.hh:433
Writeback event, specifically for when stores forward data to loads.
Definition: lsq_unit.hh:313
TimeBuffer< IssueStruct >::wire fromIssue
Wire to read information from the issue stage time queue.
Definition: lsq_unit.hh:444
const bool HasUnalignedMemAcc
Definition: isa_traits.hh:119
char data[16]
The store data.
Definition: lsq_unit.hh:358
bool isMmappedIpr() const
Definition: request.hh:776
bool isStalled()
Returns whether or not the LSQ unit is stalled.
Definition: lsq_unit.hh:547
Stats::Scalar lsqRescheduledLoads
Number of loads that were rescheduled.
Definition: lsq_unit.hh:506
int storeTail
The index of the tail instruction in the SQ.
Definition: lsq_unit.hh:429
void resetState()
Reset the LSQ state.
Port Object Declaration.
Derived class to hold any sender state the LSQ needs.
Definition: lsq_unit.hh:277
void writebackPendingStore()
Writes back a store that couldn't be completed the previous cycle.
SQEntry()
Constructs an empty store queue entry.
Definition: lsq_unit.hh:338
This is a write that is targeted and zeroing an entire cache block.
Definition: request.hh:134
void resizeLQ(unsigned size)
Resizes the LQ to a given size.
void regStats()
Registers statistics.
bool isFull()
Returns if either the LQ or SQ is full.
Definition: lsq_unit.hh:197
int numLoads()
Returns the number of loads in the LQ.
Definition: lsq_unit.hh:191
Definition: lsq.hh:58
Cycles handleIprRead(ThreadContext *xc, Packet *pkt)
Helper function to handle IPRs when the target architecture doesn't need its own IPR handling...
Definition: mmapped_ipr.hh:139
Stats::Scalar invAddrLoads
Total number of loads ignored due to invalid addresses.
Definition: lsq_unit.hh:484
ThreadContext is the external interface to all thread state for anything outside of the CPU...
void insertLoad(DynInstPtr &load_inst)
Inserts a load instruction.
Stats::Scalar lsqIgnoredResponses
Total number of responses from the memory system that are ignored due to the instruction already bein...
Definition: lsq_unit.hh:491
Stats::Scalar lsqSquashedLoads
Total number of squashed loads.
Definition: lsq_unit.hh:487
void recvRetry()
Handles doing the retry.
Fault read(Request *req, Request *sreqLow, Request *sreqHigh, int load_idx)
Executes the load at the given index.
Definition: lsq_unit.hh:552
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
int loadTail
The index of the tail instruction in the LQ.
Definition: lsq_unit.hh:420
DynInstPtr inst
Instruction whose results are being written back.
Definition: lsq_unit.hh:326
STL vector class.
Definition: stl.hh:40
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
Definition: packet.hh:909
void takeOverFrom()
Takes over from another CPU's thread.
const char data[]
Definition: circlebuf.cc:43
void commitStores(InstSeqNum &youngest_inst)
Commits stores older than a specific sequence number.
std::string name() const
Returns the name of the LSQ unit.
void decrLdIdx(int &load_idx) const
Decrements the given load index (circular queue).
ThreadID lsqID
The LSQUnit thread id.
Definition: lsq_unit.hh:385
bool cacheBlocked
Whether or not the second packet of this split load was blocked.
Definition: lsq_unit.hh:306
void init(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params, LSQ *lsq_ptr, unsigned maxLQEntries, unsigned maxSQEntries, unsigned id)
Initializes the LSQ unit with the specified number of entries.
InstSeqNum getStoreHeadSeqNum()
Returns the sequence number of the head store instruction.
Definition: lsq_unit.hh:536
bool hasPendingPkt
Whether or not there is a packet that couldn't be sent because of a lack of cache ports...
Definition: lsq_unit.hh:469
bool storeInFlight
Whether or not a store is in flight.
Definition: lsq_unit.hh:462
void incrLdIdx(int &load_idx) const
Increments the given load index (circular queue).
Tick curTick()
The current simulated tick.
Definition: core.hh:47
bool willWB()
Returns if the LSQ unit will writeback on this cycle.
Definition: lsq_unit.hh:224
SQEntry(DynInstPtr &_inst)
Constructs a store queue entry for a given instruction.
Definition: lsq_unit.hh:351
bool noWB
Whether or not the instruction will need to writeback.
Definition: lsq_unit.hh:300
void checkSnoop(PacketPtr pkt)
Check if an incoming invalidate hits in the lsq on a load that might have issued out of order wrt ano...
IEW * iewStage
Pointer to the IEW stage.
Definition: lsq_unit.hh:268
bool pktToSend
Whether or not there is a packet that needs sending.
Definition: lsq_unit.hh:304
bool isLLSC() const
Definition: request.hh:771
bool lqFull()
Returns if the LQ is full.
Definition: lsq_unit.hh:203
void dumpInsts() const
Debugging function to dump instructions in the LSQ.
bool isAllZeros
Does this request write all zeros and thus doesn't have any data attached to it.
Definition: lsq_unit.hh:380
void storePostSend(PacketPtr pkt)
Handles completing the send of a store to memory.
bool completed
Whether or not the store is completed.
Definition: lsq_unit.hh:375
bool stalled
Whether or not the LSQ is stalled.
Definition: lsq_unit.hh:447
void commitLoads(InstSeqNum &youngest_inst)
Commits loads older than a specific sequence number.
bool isLoad
Whether or not it is a load.
Definition: lsq_unit.hh:298
bool complete()
Completes a packet and returns whether the access is finished.
Definition: lsq_unit.hh:309
Addr getPaddr() const
Definition: request.hh:519
void commitLoad()
Commits the head load.
void insert(DynInstPtr &inst)
Inserts an instruction.
int stallingLoadIdx
The index of the above store.
Definition: lsq_unit.hh:453
void completeDataAccess(PacketPtr pkt)
Completes the data access that has been returned from the memory system.
InstSeqNum getLoadHeadSeqNum()
Returns the sequence number of the head load instruction.
Definition: lsq_unit.hh:523
uint64_t InstSeqNum
Definition: inst_seq.hh:40
int loadHead
The index of the head instruction in the LQ.
Definition: lsq_unit.hh:418
LSQUnit()
Constructs an LSQ unit.
Fault executeLoad(int lq_idx)
Definition: lsq_unit.hh:142
void setDcachePort(MasterPort *dcache_port)
Sets the pointer to the dcache port.
int storeHead
The index of the head instruction in the SQ.
Definition: lsq_unit.hh:423
PacketPtr pendingPkt
The packet that is pending free cache ports.
Definition: lsq_unit.hh:472
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
RequestPtr sreqLow
The split requests for the store.
Definition: lsq_unit.hh:364
LSQUnit< Impl > * lsqPtr
The pointer to the LSQ unit that issued the store.
Definition: lsq_unit.hh:332
bool isSplit
Whether or not this access is split in two.
Definition: lsq_unit.hh:302
Fault write(Request *req, Request *sreqLow, Request *sreqHigh, uint8_t *data, int store_idx)
Executes the store at the given index.
Definition: lsq_unit.hh:882
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
bool isSplit
Whether or not the store is split into two requests.
Definition: lsq_unit.hh:369
PacketPtr retryPkt
The packet that needs to be retried.
Definition: lsq_unit.hh:456
InstSeqNum stallingStoreIsn
The store that causes the stall due to partial store to load forwarding.
Definition: lsq_unit.hh:451
A virtual base opaque structure used to hold state associated with the packet (e.g., an MSHR), specific to a MemObject that sees the packet.
Definition: packet.hh:377
Fault executeLoad(DynInstPtr &inst)
Executes a load instruction.
Stats::Scalar lsqSquashedStores
Total number of squashed stores.
Definition: lsq_unit.hh:497
bool sqFull()
Returns if the SQ is full.
Definition: lsq_unit.hh:206
void clearSQ()
Clears all the entries in the SQ.
Fault executeStore(DynInstPtr &inst)
Executes a store instruction.
Flags getFlags()
Accessor for flags.
Definition: request.hh:584
LSQ * lsq
Pointer to the LSQ.
Definition: lsq_unit.hh:271
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:171
int stores
The number of store instructions in the SQ.
Definition: lsq_unit.hh:413
DynInstPtr inst
The store instruction.
Definition: lsq_unit.hh:360
void incrStIdx(int &store_idx) const
Increments the given store index (circular queue).
int size()
Definition: pagetable.hh:146
bool checkLoads
Should loads be checked for dependency issues.
Definition: lsq_unit.hh:408
Declaration of the Packet class.
std::vector< DynInstPtr > loadQueue
The load queue.
Definition: lsq_unit.hh:391
PacketPtr pkt
The packet that would have been sent to memory.
Definition: lsq_unit.hh:329
unsigned numFreeStoreEntries()
Returns the number of free SQ entries.
unsigned getCount()
Returns the number of instructions in the LSQ.
Definition: lsq_unit.hh:215
SenderState * senderState
This packet's sender state.
Definition: packet.hh:454
Definition: eventq.hh:185
void process()
Processes the writeback event.
int storeWBIdx
The index of the first instruction that may be ready to be written back, and has not yet been written...
Definition: lsq_unit.hh:427
Addr getVaddr() const
Definition: request.hh:616
int storesToWB
The number of store instructions in the SQ waiting to writeback.
Definition: lsq_unit.hh:415
RequestPtr req
The request for the store.
Definition: lsq_unit.hh:362
void writebackStores()
Writes back stores.
bool sendStore(PacketPtr data_pkt)
Attempts to send a store to the cache.
PacketPtr pendingPacket
A second packet from a split store that needs sending.
Definition: lsq_unit.hh:292
bool needsTSO
Flag for memory model.
Definition: lsq_unit.hh:475
int loads
The number of load instructions in the LQ.
Definition: lsq_unit.hh:411
static PacketPtr createRead(const RequestPtr req)
Constructor-like methods that return Packets based on Request objects.
Definition: packet.hh:809
O3CPU * cpu
Pointer to the CPU.
Definition: lsq_unit.hh:265
void insertStore(DynInstPtr &store_inst)
Inserts a store instruction.
Stats::Scalar lsqBlockedLoads
Ready loads blocked due to partial store-forwarding.
Definition: lsq_unit.hh:503
PacketPtr mainPkt
The main packet from a split load, used during writeback.
Definition: lsq_unit.hh:290
const char * description() const
Returns the description of this event.
bool canWB
Whether or not the store can writeback.
Definition: lsq_unit.hh:371
Stats::Scalar lsqCacheBlocked
Number of times the LSQ is blocked due to the cache.
Definition: lsq_unit.hh:509
unsigned SQEntries
The number of SQ entries, plus a sentinel entry (circular queue).
Definition: lsq_unit.hh:400
unsigned depCheckShift
The number of places to shift addresses in the LSQ before checking for dependency violations...
Definition: lsq_unit.hh:405
void clearLQ()
Clears all the entries in the LQ.
uint8_t outstanding
Number of outstanding packets to complete.
Definition: lsq_unit.hh:296
Class that implements the actual LQ and SQ for each specific thread.
Definition: lsq_unit.hh:79
Impl::CPUPol::IssueStruct IssueStruct
Definition: lsq_unit.hh:85
unsigned getSize() const
Definition: request.hh:552
Impl::CPUPol::LSQ LSQ
Definition: lsq_unit.hh:84
void writeback(DynInstPtr &inst, PacketPtr pkt)
Writes back the instruction, sending it to IEW.
bool committed
Whether or not the store is committed.
Definition: lsq_unit.hh:373
Impl::O3CPU O3CPU
Definition: lsq_unit.hh:81
DynInstPtr inst
Instruction who initiated the access to memory.
Definition: lsq_unit.hh:288
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
uint8_t size
The size of the store.
Definition: lsq_unit.hh:367
bool lqEmpty() const
Returns if the LQ is empty.
Definition: lsq_unit.hh:209
if(it_gpu==gpuTypeMap.end())
Definition: gpu_nomali.cc:75
Impl::CPUPol::IEW IEW
Definition: lsq_unit.hh:83
void handleLockedRead(XC *xc, Request *req)
Definition: locked_mem.hh:88
Stats::Scalar lsqMemOrderViolation
Tota number of memory ordering violations.
Definition: lsq_unit.hh:494
int numStoresToWB()
Returns the number of stores to writeback.
Definition: lsq_unit.hh:221
ProbePointArg< PacketInfo > Packet
Packet probe point.
Definition: mem.hh:102
RequestPtr sreqHigh
Definition: lsq_unit.hh:365
void tick()
Ticks the LSQ unit, which in this case only resets the number of used cache ports.
Definition: lsq_unit.hh:116
Addr cacheBlockMask
Address Mask for a cache block (e.g.
Definition: lsq_unit.hh:441

Generated on Fri Jun 9 2017 13:03:43 for gem5 by doxygen 1.8.6