2006-04-23 00:26:48 +02:00
|
|
|
/*
|
2006-05-19 21:53:17 +02:00
|
|
|
* Copyright (c) 2004-2006 The Regents of The University of Michigan
|
2006-04-23 00:26:48 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2006-06-07 22:02:55 +02:00
|
|
|
*
|
|
|
|
* Authors: Kevin Lim
|
|
|
|
* Korey Sewell
|
2006-04-23 00:26:48 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CPU_O3_LSQ_UNIT_HH__
|
|
|
|
#define __CPU_O3_LSQ_UNIT_HH__
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
#include <algorithm>
|
2007-04-22 01:11:38 +02:00
|
|
|
#include <cstring>
|
2006-04-23 00:26:48 +02:00
|
|
|
#include <map>
|
|
|
|
#include <queue>
|
|
|
|
|
2011-09-27 09:24:43 +02:00
|
|
|
#include "arch/generic/debugfaults.hh"
|
2011-08-16 11:46:57 +02:00
|
|
|
#include "arch/isa_traits.hh"
|
2006-10-23 20:00:07 +02:00
|
|
|
#include "arch/locked_mem.hh"
|
2011-08-01 04:21:17 +02:00
|
|
|
#include "arch/mmapped_ipr.hh"
|
2006-04-23 00:26:48 +02:00
|
|
|
#include "base/hashmap.hh"
|
2011-04-15 19:44:06 +02:00
|
|
|
#include "config/the_isa.hh"
|
2006-04-23 00:26:48 +02:00
|
|
|
#include "cpu/inst_seq.hh"
|
2011-04-15 19:44:14 +02:00
|
|
|
#include "cpu/timebuf.hh"
|
2011-04-15 19:44:32 +02:00
|
|
|
#include "debug/LSQUnit.hh"
|
2006-10-20 08:38:45 +02:00
|
|
|
#include "mem/packet.hh"
|
2006-06-03 00:15:20 +02:00
|
|
|
#include "mem/port.hh"
|
2012-02-07 13:43:21 +01:00
|
|
|
#include "sim/fault_fwd.hh"
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2012-01-31 18:05:52 +01:00
|
|
|
struct DerivO3CPUParams;
|
2008-08-11 21:22:16 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
/**
|
2006-05-19 21:53:17 +02:00
|
|
|
* Class that implements the actual LQ and SQ for each specific
|
|
|
|
* thread. Both are circular queues; load entries are freed upon
|
|
|
|
* committing, while store entries are freed once they writeback. The
|
|
|
|
* LSQUnit tracks if there are memory ordering violations, and also
|
|
|
|
* detects partial load to store forwarding cases (a store only has
|
|
|
|
* part of a load's data) that requires the load to wait until the
|
|
|
|
* store writes back. In the former case it holds onto the instruction
|
|
|
|
* until the dependence unit looks at it, and in the latter it stalls
|
|
|
|
* the LSQ until the store writes back. At that point the load is
|
|
|
|
* replayed.
|
2006-04-23 00:26:48 +02:00
|
|
|
*/
|
|
|
|
template <class Impl>
|
|
|
|
class LSQUnit {
|
|
|
|
public:
|
2006-06-16 23:08:47 +02:00
|
|
|
typedef typename Impl::O3CPU O3CPU;
|
2006-04-23 00:26:48 +02:00
|
|
|
typedef typename Impl::DynInstPtr DynInstPtr;
|
|
|
|
typedef typename Impl::CPUPol::IEW IEW;
|
2006-07-13 19:12:51 +02:00
|
|
|
typedef typename Impl::CPUPol::LSQ LSQ;
|
2006-04-23 00:26:48 +02:00
|
|
|
typedef typename Impl::CPUPol::IssueStruct IssueStruct;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Constructs an LSQ unit. init() must be called prior to use. */
|
|
|
|
LSQUnit();
|
|
|
|
|
|
|
|
/** Initializes the LSQ unit with the specified number of entries. */
|
2008-08-11 21:22:16 +02:00
|
|
|
void init(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params,
|
|
|
|
LSQ *lsq_ptr, unsigned maxLQEntries, unsigned maxSQEntries,
|
|
|
|
unsigned id);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
/** Returns the name of the LSQ unit. */
|
|
|
|
std::string name() const;
|
|
|
|
|
2006-06-14 04:35:05 +02:00
|
|
|
/** Registers statistics. */
|
|
|
|
void regStats();
|
|
|
|
|
2006-07-13 19:12:51 +02:00
|
|
|
/** Sets the pointer to the dcache port. */
|
MEM: Introduce the master/slave port sub-classes in C++
This patch introduces the notion of a master and slave port in the C++
code, thus bringing the previous classification from the Python
classes into the corresponding simulation objects and memory objects.
The patch enables us to classify behaviours into the two bins and add
assumptions and enfore compliance, also simplifying the two
interfaces. As a starting point, isSnooping is confined to a master
port, and getAddrRanges to slave ports. More of these specilisations
are to come in later patches.
The getPort function is not getMasterPort and getSlavePort, and
returns a port reference rather than a pointer as NULL would never be
a valid return value. The default implementation of these two
functions is placed in MemObject, and calls fatal.
The one drawback with this specific patch is that it requires some
code duplication, e.g. QueuedPort becomes QueuedMasterPort and
QueuedSlavePort, and BusPort becomes BusMasterPort and BusSlavePort
(avoiding multiple inheritance). With the later introduction of the
port interfaces, moving the functionality outside the port itself, a
lot of the duplicated code will disappear again.
2012-03-30 15:40:11 +02:00
|
|
|
void setDcachePort(MasterPort *dcache_port);
|
2006-07-13 19:12:51 +02:00
|
|
|
|
2006-05-31 17:45:02 +02:00
|
|
|
/** Switches out LSQ unit. */
|
2006-05-04 17:36:20 +02:00
|
|
|
void switchOut();
|
|
|
|
|
2006-05-31 17:45:02 +02:00
|
|
|
/** Takes over from another CPU's thread. */
|
2006-05-04 17:36:20 +02:00
|
|
|
void takeOverFrom();
|
|
|
|
|
2006-05-31 17:45:02 +02:00
|
|
|
/** Returns if the LSQ is switched out. */
|
2006-05-04 17:36:20 +02:00
|
|
|
bool isSwitchedOut() { return switchedOut; }
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
/** Ticks the LSQ unit, which in this case only resets the number of
|
|
|
|
* used cache ports.
|
|
|
|
* @todo: Move the number of used ports up to the LSQ level so it can
|
|
|
|
* be shared by all LSQ units.
|
|
|
|
*/
|
|
|
|
void tick() { usedPorts = 0; }
|
|
|
|
|
|
|
|
/** Inserts an instruction. */
|
|
|
|
void insert(DynInstPtr &inst);
|
|
|
|
/** Inserts a load instruction. */
|
|
|
|
void insertLoad(DynInstPtr &load_inst);
|
|
|
|
/** Inserts a store instruction. */
|
|
|
|
void insertStore(DynInstPtr &store_inst);
|
|
|
|
|
2011-09-13 18:58:08 +02:00
|
|
|
/** Check for ordering violations in the LSQ. For a store squash if we
|
|
|
|
* ever find a conflicting load. For a load, only squash if we
|
|
|
|
* an external snoop invalidate has been seen for that load address
|
2011-04-04 18:42:23 +02:00
|
|
|
* @param load_idx index to start checking at
|
|
|
|
* @param inst the instruction to check
|
|
|
|
*/
|
|
|
|
Fault checkViolations(int load_idx, DynInstPtr &inst);
|
|
|
|
|
2011-09-13 18:58:08 +02:00
|
|
|
/** Check if an incoming invalidate hits in the lsq on a load
|
|
|
|
* that might have issued out of order wrt another load beacuse
|
|
|
|
* of the intermediate invalidate.
|
|
|
|
*/
|
|
|
|
void checkSnoop(PacketPtr pkt);
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
/** Executes a load instruction. */
|
|
|
|
Fault executeLoad(DynInstPtr &inst);
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
Fault executeLoad(int lq_idx) { panic("Not implemented"); return NoFault; }
|
2006-04-23 00:26:48 +02:00
|
|
|
/** Executes a store instruction. */
|
|
|
|
Fault executeStore(DynInstPtr &inst);
|
|
|
|
|
|
|
|
/** Commits the head load. */
|
|
|
|
void commitLoad();
|
|
|
|
/** Commits loads older than a specific sequence number. */
|
|
|
|
void commitLoads(InstSeqNum &youngest_inst);
|
|
|
|
|
|
|
|
/** Commits stores older than a specific sequence number. */
|
|
|
|
void commitStores(InstSeqNum &youngest_inst);
|
|
|
|
|
|
|
|
/** Writes back stores. */
|
|
|
|
void writebackStores();
|
|
|
|
|
2006-06-23 00:09:31 +02:00
|
|
|
/** Completes the data access that has been returned from the
|
|
|
|
* memory system. */
|
2006-06-03 00:15:20 +02:00
|
|
|
void completeDataAccess(PacketPtr pkt);
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
/** Clears all the entries in the LQ. */
|
|
|
|
void clearLQ();
|
|
|
|
|
|
|
|
/** Clears all the entries in the SQ. */
|
|
|
|
void clearSQ();
|
|
|
|
|
|
|
|
/** Resizes the LQ to a given size. */
|
|
|
|
void resizeLQ(unsigned size);
|
|
|
|
|
|
|
|
/** Resizes the SQ to a given size. */
|
|
|
|
void resizeSQ(unsigned size);
|
|
|
|
|
|
|
|
/** Squashes all instructions younger than a specific sequence number. */
|
|
|
|
void squash(const InstSeqNum &squashed_num);
|
|
|
|
|
|
|
|
/** Returns if there is a memory ordering violation. Value is reset upon
|
|
|
|
* call to getMemDepViolator().
|
|
|
|
*/
|
|
|
|
bool violation() { return memDepViolator; }
|
|
|
|
|
|
|
|
/** Returns the memory ordering violator. */
|
|
|
|
DynInstPtr getMemDepViolator();
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
/** Returns if a load became blocked due to the memory system. */
|
2006-04-23 00:26:48 +02:00
|
|
|
bool loadBlocked()
|
|
|
|
{ return isLoadBlocked; }
|
|
|
|
|
2006-05-31 17:45:02 +02:00
|
|
|
/** Clears the signal that a load became blocked. */
|
2006-04-23 00:26:48 +02:00
|
|
|
void clearLoadBlocked()
|
|
|
|
{ isLoadBlocked = false; }
|
|
|
|
|
2006-05-31 17:45:02 +02:00
|
|
|
/** Returns if the blocked load was handled. */
|
2006-04-23 00:26:48 +02:00
|
|
|
bool isLoadBlockedHandled()
|
|
|
|
{ return loadBlockedHandled; }
|
|
|
|
|
2006-05-31 17:45:02 +02:00
|
|
|
/** Records the blocked load as being handled. */
|
2006-04-23 00:26:48 +02:00
|
|
|
void setLoadBlockedHandled()
|
|
|
|
{ loadBlockedHandled = true; }
|
|
|
|
|
|
|
|
/** Returns the number of free entries (min of free LQ and SQ entries). */
|
|
|
|
unsigned numFreeEntries();
|
|
|
|
|
|
|
|
/** Returns the number of loads ready to execute. */
|
|
|
|
int numLoadsReady();
|
|
|
|
|
|
|
|
/** Returns the number of loads in the LQ. */
|
|
|
|
int numLoads() { return loads; }
|
|
|
|
|
|
|
|
/** Returns the number of stores in the SQ. */
|
|
|
|
int numStores() { return stores; }
|
|
|
|
|
|
|
|
/** Returns if either the LQ or SQ is full. */
|
|
|
|
bool isFull() { return lqFull() || sqFull(); }
|
|
|
|
|
|
|
|
/** Returns if the LQ is full. */
|
|
|
|
bool lqFull() { return loads >= (LQEntries - 1); }
|
|
|
|
|
|
|
|
/** Returns if the SQ is full. */
|
|
|
|
bool sqFull() { return stores >= (SQEntries - 1); }
|
|
|
|
|
|
|
|
/** Returns the number of instructions in the LSQ. */
|
|
|
|
unsigned getCount() { return loads + stores; }
|
|
|
|
|
|
|
|
/** Returns if there are any stores to writeback. */
|
|
|
|
bool hasStoresToWB() { return storesToWB; }
|
|
|
|
|
|
|
|
/** Returns the number of stores to writeback. */
|
|
|
|
int numStoresToWB() { return storesToWB; }
|
|
|
|
|
|
|
|
/** Returns if the LSQ unit will writeback on this cycle. */
|
|
|
|
bool willWB() { return storeQueue[storeWBIdx].canWB &&
|
2006-06-06 00:14:39 +02:00
|
|
|
!storeQueue[storeWBIdx].completed &&
|
|
|
|
!isStoreBlocked; }
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-07-13 19:12:51 +02:00
|
|
|
/** Handles doing the retry. */
|
|
|
|
void recvRetry();
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
private:
|
2006-06-09 22:28:17 +02:00
|
|
|
/** Writes back the instruction, sending it to IEW. */
|
2006-06-06 00:14:39 +02:00
|
|
|
void writeback(DynInstPtr &inst, PacketPtr pkt);
|
|
|
|
|
2010-02-12 20:53:20 +01:00
|
|
|
/** Writes back a store that couldn't be completed the previous cycle. */
|
|
|
|
void writebackPendingStore();
|
|
|
|
|
2006-06-09 22:28:17 +02:00
|
|
|
/** Handles completing the send of a store to memory. */
|
2006-10-20 09:10:12 +02:00
|
|
|
void storePostSend(PacketPtr pkt);
|
2006-06-09 17:46:35 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
/** Completes the store at the specified index. */
|
|
|
|
void completeStore(int store_idx);
|
|
|
|
|
2010-02-12 20:53:20 +01:00
|
|
|
/** Attempts to send a store to the cache. */
|
|
|
|
bool sendStore(PacketPtr data_pkt);
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
/** Increments the given store index (circular queue). */
|
|
|
|
inline void incrStIdx(int &store_idx);
|
|
|
|
/** Decrements the given store index (circular queue). */
|
|
|
|
inline void decrStIdx(int &store_idx);
|
|
|
|
/** Increments the given load index (circular queue). */
|
|
|
|
inline void incrLdIdx(int &load_idx);
|
|
|
|
/** Decrements the given load index (circular queue). */
|
|
|
|
inline void decrLdIdx(int &load_idx);
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
public:
|
|
|
|
/** Debugging function to dump instructions in the LSQ. */
|
|
|
|
void dumpInsts();
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
private:
|
|
|
|
/** Pointer to the CPU. */
|
2006-06-16 23:08:47 +02:00
|
|
|
O3CPU *cpu;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
/** Pointer to the IEW stage. */
|
|
|
|
IEW *iewStage;
|
|
|
|
|
2006-07-13 19:12:51 +02:00
|
|
|
/** Pointer to the LSQ. */
|
|
|
|
LSQ *lsq;
|
2006-06-03 00:15:20 +02:00
|
|
|
|
2006-07-13 19:12:51 +02:00
|
|
|
/** Pointer to the dcache port. Used only for sending. */
|
MEM: Introduce the master/slave port sub-classes in C++
This patch introduces the notion of a master and slave port in the C++
code, thus bringing the previous classification from the Python
classes into the corresponding simulation objects and memory objects.
The patch enables us to classify behaviours into the two bins and add
assumptions and enfore compliance, also simplifying the two
interfaces. As a starting point, isSnooping is confined to a master
port, and getAddrRanges to slave ports. More of these specilisations
are to come in later patches.
The getPort function is not getMasterPort and getSlavePort, and
returns a port reference rather than a pointer as NULL would never be
a valid return value. The default implementation of these two
functions is placed in MemObject, and calls fatal.
The one drawback with this specific patch is that it requires some
code duplication, e.g. QueuedPort becomes QueuedMasterPort and
QueuedSlavePort, and BusPort becomes BusMasterPort and BusSlavePort
(avoiding multiple inheritance). With the later introduction of the
port interfaces, moving the functionality outside the port itself, a
lot of the duplicated code will disappear again.
2012-03-30 15:40:11 +02:00
|
|
|
MasterPort *dcachePort;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-06-09 22:28:17 +02:00
|
|
|
/** Derived class to hold any sender state the LSQ needs. */
|
2012-06-05 07:23:08 +02:00
|
|
|
class LSQSenderState : public Packet::SenderState
|
2006-06-06 00:14:39 +02:00
|
|
|
{
|
|
|
|
public:
|
2006-06-09 22:28:17 +02:00
|
|
|
/** Default constructor. */
|
2006-06-06 00:14:39 +02:00
|
|
|
LSQSenderState()
|
2012-06-05 07:23:09 +02:00
|
|
|
: mainPkt(NULL), pendingPacket(NULL), outstanding(1),
|
|
|
|
noWB(false), isSplit(false), pktToSend(false)
|
|
|
|
{ }
|
2006-06-06 00:14:39 +02:00
|
|
|
|
2006-06-09 22:28:17 +02:00
|
|
|
/** Instruction who initiated the access to memory. */
|
2006-06-06 00:14:39 +02:00
|
|
|
DynInstPtr inst;
|
2012-06-05 07:23:09 +02:00
|
|
|
/** The main packet from a split load, used during writeback. */
|
|
|
|
PacketPtr mainPkt;
|
|
|
|
/** A second packet from a split store that needs sending. */
|
|
|
|
PacketPtr pendingPacket;
|
|
|
|
/** The LQ/SQ index of the instruction. */
|
|
|
|
uint8_t idx;
|
|
|
|
/** Number of outstanding packets to complete. */
|
|
|
|
uint8_t outstanding;
|
2006-06-09 22:28:17 +02:00
|
|
|
/** Whether or not it is a load. */
|
2006-06-06 00:14:39 +02:00
|
|
|
bool isLoad;
|
2006-06-09 22:28:17 +02:00
|
|
|
/** Whether or not the instruction will need to writeback. */
|
2006-06-06 00:14:39 +02:00
|
|
|
bool noWB;
|
2010-02-12 20:53:20 +01:00
|
|
|
/** Whether or not this access is split in two. */
|
|
|
|
bool isSplit;
|
|
|
|
/** Whether or not there is a packet that needs sending. */
|
|
|
|
bool pktToSend;
|
|
|
|
|
|
|
|
/** Completes a packet and returns whether the access is finished. */
|
|
|
|
inline bool complete() { return --outstanding == 0; }
|
2006-06-06 00:14:39 +02:00
|
|
|
};
|
|
|
|
|
2006-06-09 22:28:17 +02:00
|
|
|
/** Writeback event, specifically for when stores forward data to loads. */
|
2006-06-06 00:14:39 +02:00
|
|
|
class WritebackEvent : public Event {
|
|
|
|
public:
|
|
|
|
/** Constructs a writeback event. */
|
|
|
|
WritebackEvent(DynInstPtr &_inst, PacketPtr pkt, LSQUnit *lsq_ptr);
|
|
|
|
|
|
|
|
/** Processes the writeback event. */
|
|
|
|
void process();
|
|
|
|
|
|
|
|
/** Returns the description of this event. */
|
2008-02-06 22:32:40 +01:00
|
|
|
const char *description() const;
|
2006-06-06 00:14:39 +02:00
|
|
|
|
|
|
|
private:
|
2006-06-09 22:28:17 +02:00
|
|
|
/** Instruction whose results are being written back. */
|
2006-06-06 00:14:39 +02:00
|
|
|
DynInstPtr inst;
|
|
|
|
|
2006-06-09 22:28:17 +02:00
|
|
|
/** The packet that would have been sent to memory. */
|
2006-06-06 00:14:39 +02:00
|
|
|
PacketPtr pkt;
|
|
|
|
|
|
|
|
/** The pointer to the LSQ unit that issued the store. */
|
|
|
|
LSQUnit<Impl> *lsqPtr;
|
|
|
|
};
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
public:
|
|
|
|
struct SQEntry {
|
|
|
|
/** Constructs an empty store queue entry. */
|
|
|
|
SQEntry()
|
2007-04-04 00:53:26 +02:00
|
|
|
: inst(NULL), req(NULL), size(0),
|
2006-04-23 00:26:48 +02:00
|
|
|
canWB(0), committed(0), completed(0)
|
2007-04-04 00:53:26 +02:00
|
|
|
{
|
2007-04-22 01:11:38 +02:00
|
|
|
std::memset(data, 0, sizeof(data));
|
2007-04-04 00:53:26 +02:00
|
|
|
}
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2012-08-15 16:38:08 +02:00
|
|
|
~SQEntry()
|
|
|
|
{
|
|
|
|
inst = NULL;
|
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
/** Constructs a store queue entry for a given instruction. */
|
|
|
|
SQEntry(DynInstPtr &_inst)
|
2010-02-12 20:53:20 +01:00
|
|
|
: inst(_inst), req(NULL), sreqLow(NULL), sreqHigh(NULL), size(0),
|
|
|
|
isSplit(0), canWB(0), committed(0), completed(0)
|
2007-04-04 00:53:26 +02:00
|
|
|
{
|
2007-04-22 01:11:38 +02:00
|
|
|
std::memset(data, 0, sizeof(data));
|
2007-04-04 00:53:26 +02:00
|
|
|
}
|
2012-06-05 07:23:09 +02:00
|
|
|
/** The store data. */
|
|
|
|
char data[16];
|
2006-04-23 00:26:48 +02:00
|
|
|
/** The store instruction. */
|
|
|
|
DynInstPtr inst;
|
2006-06-03 00:15:20 +02:00
|
|
|
/** The request for the store. */
|
|
|
|
RequestPtr req;
|
2010-02-12 20:53:20 +01:00
|
|
|
/** The split requests for the store. */
|
|
|
|
RequestPtr sreqLow;
|
|
|
|
RequestPtr sreqHigh;
|
2006-04-23 00:26:48 +02:00
|
|
|
/** The size of the store. */
|
2012-06-05 07:23:09 +02:00
|
|
|
uint8_t size;
|
2010-02-12 20:53:20 +01:00
|
|
|
/** Whether or not the store is split into two requests. */
|
|
|
|
bool isSplit;
|
2006-04-23 00:26:48 +02:00
|
|
|
/** Whether or not the store can writeback. */
|
|
|
|
bool canWB;
|
|
|
|
/** Whether or not the store is committed. */
|
|
|
|
bool committed;
|
|
|
|
/** Whether or not the store is completed. */
|
|
|
|
bool completed;
|
|
|
|
};
|
2006-05-19 21:53:17 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
private:
|
|
|
|
/** The LSQUnit thread id. */
|
2009-05-26 18:23:13 +02:00
|
|
|
ThreadID lsqID;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
/** The store queue. */
|
|
|
|
std::vector<SQEntry> storeQueue;
|
|
|
|
|
|
|
|
/** The load queue. */
|
|
|
|
std::vector<DynInstPtr> loadQueue;
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
/** The number of LQ entries, plus a sentinel entry (circular queue).
|
|
|
|
* @todo: Consider having var that records the true number of LQ entries.
|
|
|
|
*/
|
2006-04-23 00:26:48 +02:00
|
|
|
unsigned LQEntries;
|
2006-05-19 21:53:17 +02:00
|
|
|
/** The number of SQ entries, plus a sentinel entry (circular queue).
|
|
|
|
* @todo: Consider having var that records the true number of SQ entries.
|
|
|
|
*/
|
2006-04-23 00:26:48 +02:00
|
|
|
unsigned SQEntries;
|
|
|
|
|
2011-04-04 18:42:23 +02:00
|
|
|
/** The number of places to shift addresses in the LSQ before checking
|
|
|
|
* for dependency violations
|
|
|
|
*/
|
|
|
|
unsigned depCheckShift;
|
|
|
|
|
|
|
|
/** Should loads be checked for dependency issues */
|
|
|
|
bool checkLoads;
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
/** The number of load instructions in the LQ. */
|
|
|
|
int loads;
|
2006-05-19 21:53:17 +02:00
|
|
|
/** The number of store instructions in the SQ. */
|
2006-04-23 00:26:48 +02:00
|
|
|
int stores;
|
|
|
|
/** The number of store instructions in the SQ waiting to writeback. */
|
|
|
|
int storesToWB;
|
|
|
|
|
|
|
|
/** The index of the head instruction in the LQ. */
|
|
|
|
int loadHead;
|
|
|
|
/** The index of the tail instruction in the LQ. */
|
|
|
|
int loadTail;
|
|
|
|
|
|
|
|
/** The index of the head instruction in the SQ. */
|
|
|
|
int storeHead;
|
2006-05-19 21:53:17 +02:00
|
|
|
/** The index of the first instruction that may be ready to be
|
|
|
|
* written back, and has not yet been written back.
|
2006-04-23 00:26:48 +02:00
|
|
|
*/
|
|
|
|
int storeWBIdx;
|
|
|
|
/** The index of the tail instruction in the SQ. */
|
|
|
|
int storeTail;
|
|
|
|
|
|
|
|
/// @todo Consider moving to a more advanced model with write vs read ports
|
|
|
|
/** The number of cache ports available each cycle. */
|
|
|
|
int cachePorts;
|
|
|
|
|
|
|
|
/** The number of used cache ports in this cycle. */
|
|
|
|
int usedPorts;
|
|
|
|
|
2006-05-31 17:45:02 +02:00
|
|
|
/** Is the LSQ switched out. */
|
2006-05-04 17:36:20 +02:00
|
|
|
bool switchedOut;
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
//list<InstSeqNum> mshrSeqNums;
|
|
|
|
|
2011-09-13 18:58:08 +02:00
|
|
|
/** Address Mask for a cache block (e.g. ~(cache_block_size-1)) */
|
|
|
|
Addr cacheBlockMask;
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
/** Wire to read information from the issue stage time queue. */
|
|
|
|
typename TimeBuffer<IssueStruct>::wire fromIssue;
|
|
|
|
|
|
|
|
/** Whether or not the LSQ is stalled. */
|
|
|
|
bool stalled;
|
|
|
|
/** The store that causes the stall due to partial store to load
|
|
|
|
* forwarding.
|
|
|
|
*/
|
|
|
|
InstSeqNum stallingStoreIsn;
|
|
|
|
/** The index of the above store. */
|
|
|
|
int stallingLoadIdx;
|
|
|
|
|
2006-06-09 22:28:17 +02:00
|
|
|
/** The packet that needs to be retried. */
|
|
|
|
PacketPtr retryPkt;
|
2006-06-09 17:46:35 +02:00
|
|
|
|
2006-06-09 22:28:17 +02:00
|
|
|
/** Whehter or not a store is blocked due to the memory system. */
|
2006-06-06 00:14:39 +02:00
|
|
|
bool isStoreBlocked;
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
/** Whether or not a load is blocked due to the memory system. */
|
2006-04-23 00:26:48 +02:00
|
|
|
bool isLoadBlocked;
|
|
|
|
|
2006-05-31 17:45:02 +02:00
|
|
|
/** Has the blocked load been handled. */
|
2006-04-23 00:26:48 +02:00
|
|
|
bool loadBlockedHandled;
|
|
|
|
|
2012-01-29 02:09:04 +01:00
|
|
|
/** Whether or not a store is in flight. */
|
|
|
|
bool storeInFlight;
|
|
|
|
|
2006-05-31 17:45:02 +02:00
|
|
|
/** The sequence number of the blocked load. */
|
2006-04-23 00:26:48 +02:00
|
|
|
InstSeqNum blockedLoadSeqNum;
|
|
|
|
|
|
|
|
/** The oldest load that caused a memory ordering violation. */
|
|
|
|
DynInstPtr memDepViolator;
|
|
|
|
|
2010-02-12 20:53:20 +01:00
|
|
|
/** Whether or not there is a packet that couldn't be sent because of
|
|
|
|
* a lack of cache ports. */
|
|
|
|
bool hasPendingPkt;
|
|
|
|
|
|
|
|
/** The packet that is pending free cache ports. */
|
|
|
|
PacketPtr pendingPkt;
|
|
|
|
|
2012-01-29 02:09:04 +01:00
|
|
|
/** Flag for memory model. */
|
|
|
|
bool needsTSO;
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
// Will also need how many read/write ports the Dcache has. Or keep track
|
|
|
|
// of that in stage that is one level up, and only call executeLoad/Store
|
|
|
|
// the appropriate number of times.
|
2006-06-14 04:35:05 +02:00
|
|
|
/** Total number of loads forwaded from LSQ stores. */
|
2009-03-06 04:09:53 +01:00
|
|
|
Stats::Scalar lsqForwLoads;
|
2006-06-14 04:35:05 +02:00
|
|
|
|
2006-10-02 17:58:09 +02:00
|
|
|
/** Total number of loads ignored due to invalid addresses. */
|
2009-03-06 04:09:53 +01:00
|
|
|
Stats::Scalar invAddrLoads;
|
2006-10-02 17:58:09 +02:00
|
|
|
|
|
|
|
/** Total number of squashed loads. */
|
2009-03-06 04:09:53 +01:00
|
|
|
Stats::Scalar lsqSquashedLoads;
|
2006-10-02 17:58:09 +02:00
|
|
|
|
|
|
|
/** Total number of responses from the memory system that are
|
|
|
|
* ignored due to the instruction already being squashed. */
|
2009-03-06 04:09:53 +01:00
|
|
|
Stats::Scalar lsqIgnoredResponses;
|
2006-10-02 17:58:09 +02:00
|
|
|
|
|
|
|
/** Tota number of memory ordering violations. */
|
2009-03-06 04:09:53 +01:00
|
|
|
Stats::Scalar lsqMemOrderViolation;
|
2006-10-02 17:58:09 +02:00
|
|
|
|
2006-06-14 04:35:05 +02:00
|
|
|
/** Total number of squashed stores. */
|
2009-03-06 04:09:53 +01:00
|
|
|
Stats::Scalar lsqSquashedStores;
|
2006-06-14 04:35:05 +02:00
|
|
|
|
|
|
|
/** Total number of software prefetches ignored due to invalid addresses. */
|
2009-03-06 04:09:53 +01:00
|
|
|
Stats::Scalar invAddrSwpfs;
|
2006-05-04 17:36:20 +02:00
|
|
|
|
2006-06-14 04:35:05 +02:00
|
|
|
/** Ready loads blocked due to partial store-forwarding. */
|
2009-03-06 04:09:53 +01:00
|
|
|
Stats::Scalar lsqBlockedLoads;
|
2006-05-04 17:36:20 +02:00
|
|
|
|
2006-06-14 04:35:05 +02:00
|
|
|
/** Number of loads that were rescheduled. */
|
2009-03-06 04:09:53 +01:00
|
|
|
Stats::Scalar lsqRescheduledLoads;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-06-14 04:35:05 +02:00
|
|
|
/** Number of times the LSQ is blocked due to the cache. */
|
2009-03-06 04:09:53 +01:00
|
|
|
Stats::Scalar lsqCacheBlocked;
|
2006-05-04 17:36:20 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
public:
|
|
|
|
/** Executes the load at the given index. */
|
2010-08-13 15:16:02 +02:00
|
|
|
Fault read(Request *req, Request *sreqLow, Request *sreqHigh,
|
|
|
|
uint8_t *data, int load_idx);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
/** Executes the store at the given index. */
|
2010-08-13 15:16:02 +02:00
|
|
|
Fault write(Request *req, Request *sreqLow, Request *sreqHigh,
|
|
|
|
uint8_t *data, int store_idx);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
/** Returns the index of the head load instruction. */
|
|
|
|
int getLoadHead() { return loadHead; }
|
|
|
|
/** Returns the sequence number of the head load instruction. */
|
|
|
|
InstSeqNum getLoadHeadSeqNum()
|
|
|
|
{
|
|
|
|
if (loadQueue[loadHead]) {
|
|
|
|
return loadQueue[loadHead]->seqNum;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Returns the index of the head store instruction. */
|
|
|
|
int getStoreHead() { return storeHead; }
|
|
|
|
/** Returns the sequence number of the head store instruction. */
|
|
|
|
InstSeqNum getStoreHeadSeqNum()
|
|
|
|
{
|
|
|
|
if (storeQueue[storeHead].inst) {
|
|
|
|
return storeQueue[storeHead].inst->seqNum;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Returns whether or not the LSQ unit is stalled. */
|
|
|
|
bool isStalled() { return stalled; }
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
Fault
|
2010-02-12 20:53:20 +01:00
|
|
|
LSQUnit<Impl>::read(Request *req, Request *sreqLow, Request *sreqHigh,
|
2010-08-13 15:16:02 +02:00
|
|
|
uint8_t *data, int load_idx)
|
2006-04-23 00:26:48 +02:00
|
|
|
{
|
2006-06-03 00:15:20 +02:00
|
|
|
DynInstPtr load_inst = loadQueue[load_idx];
|
|
|
|
|
|
|
|
assert(load_inst);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
assert(!load_inst->isExecuted());
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
// Make sure this isn't an uncacheable access
|
|
|
|
// A bit of a hackish way to get uncached accesses to work only if they're
|
|
|
|
// at the head of the LSQ and are ready to commit (at the head of the ROB
|
|
|
|
// too).
|
2006-10-08 23:48:24 +02:00
|
|
|
if (req->isUncacheable() &&
|
2006-06-14 19:12:41 +02:00
|
|
|
(load_idx != loadHead || !load_inst->isAtCommit())) {
|
2006-06-03 00:15:20 +02:00
|
|
|
iewStage->rescheduleMemInst(load_inst);
|
2006-06-14 04:35:05 +02:00
|
|
|
++lsqRescheduledLoads;
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
DPRINTF(LSQUnit, "Uncachable load [sn:%lli] PC %s\n",
|
|
|
|
load_inst->seqNum, load_inst->pcState());
|
2007-03-23 16:33:08 +01:00
|
|
|
|
|
|
|
// Must delete request now that it wasn't handed off to
|
|
|
|
// memory. This is quite ugly. @todo: Figure out the proper
|
|
|
|
// place to really handle request deletes.
|
|
|
|
delete req;
|
2010-02-12 20:53:20 +01:00
|
|
|
if (TheISA::HasUnalignedMemAcc && sreqLow) {
|
|
|
|
delete sreqLow;
|
|
|
|
delete sreqHigh;
|
|
|
|
}
|
2011-09-27 09:24:43 +02:00
|
|
|
return new GenericISA::M5PanicFault(
|
|
|
|
"Uncachable load [sn:%llx] PC %s\n",
|
|
|
|
load_inst->seqNum, load_inst->pcState());
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check the SQ for any previous stores that might lead to forwarding
|
2006-06-03 00:15:20 +02:00
|
|
|
int store_idx = load_inst->sqIdx;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
int store_size = 0;
|
|
|
|
|
|
|
|
DPRINTF(LSQUnit, "Read called, load idx: %i, store idx: %i, "
|
2010-02-12 20:53:20 +01:00
|
|
|
"storeHead: %i addr: %#x%s\n",
|
|
|
|
load_idx, store_idx, storeHead, req->getPaddr(),
|
|
|
|
sreqLow ? " split" : "");
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2009-04-20 06:44:15 +02:00
|
|
|
if (req->isLLSC()) {
|
2010-02-12 20:53:20 +01:00
|
|
|
assert(!sreqLow);
|
2006-10-23 20:00:07 +02:00
|
|
|
// Disable recording the result temporarily. Writing to misc
|
|
|
|
// regs normally updates the result, but this is not the
|
|
|
|
// desired behavior when handling store conditionals.
|
2012-06-05 07:23:09 +02:00
|
|
|
load_inst->recordResult(false);
|
2006-10-23 20:00:07 +02:00
|
|
|
TheISA::handleLockedRead(load_inst.get(), req);
|
2012-06-05 07:23:09 +02:00
|
|
|
load_inst->recordResult(true);
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
2011-08-01 04:21:17 +02:00
|
|
|
if (req->isMmappedIpr()) {
|
|
|
|
assert(!load_inst->memData);
|
|
|
|
load_inst->memData = new uint8_t[64];
|
|
|
|
|
|
|
|
ThreadContext *thread = cpu->tcBase(lsqID);
|
|
|
|
Tick delay;
|
MEM: Remove the Broadcast destination from the packet
This patch simplifies the packet by removing the broadcast flag and
instead more firmly relying on (and enforcing) the semantics of
transactions in the classic memory system, i.e. request packets are
routed from a master to a slave based on the address, and when they
are created they have neither a valid source, nor destination. On
their way to the slave, the request packet is updated with a source
field for all modules that multiplex packets from multiple master
(e.g. a bus). When a request packet is turned into a response packet
(at the final slave), it moves the potentially populated source field
to the destination field, and the response packet is routed through
any multiplexing components back to the master based on the
destination field.
Modules that connect multiplexing components, such as caches and
bridges store any existing source and destination field in the sender
state as a stack (just as before).
The packet constructor is simplified in that there is no longer a need
to pass the Packet::Broadcast as the destination (this was always the
case for the classic memory system). In the case of Ruby, rather than
using the parameter to the constructor we now rely on setDest, as
there is already another three-argument constructor in the packet
class.
In many places where the packet information was printed as part of
DPRINTFs, request packets would be printed with a numeric "dest" that
would always be -1 (Broadcast) and that field is now removed from the
printing.
2012-04-14 11:45:55 +02:00
|
|
|
PacketPtr data_pkt = new Packet(req, MemCmd::ReadReq);
|
2011-08-01 04:21:17 +02:00
|
|
|
|
|
|
|
if (!TheISA::HasUnalignedMemAcc || !sreqLow) {
|
|
|
|
data_pkt->dataStatic(load_inst->memData);
|
|
|
|
delay = TheISA::handleIprRead(thread, data_pkt);
|
|
|
|
} else {
|
|
|
|
assert(sreqLow->isMmappedIpr() && sreqHigh->isMmappedIpr());
|
MEM: Remove the Broadcast destination from the packet
This patch simplifies the packet by removing the broadcast flag and
instead more firmly relying on (and enforcing) the semantics of
transactions in the classic memory system, i.e. request packets are
routed from a master to a slave based on the address, and when they
are created they have neither a valid source, nor destination. On
their way to the slave, the request packet is updated with a source
field for all modules that multiplex packets from multiple master
(e.g. a bus). When a request packet is turned into a response packet
(at the final slave), it moves the potentially populated source field
to the destination field, and the response packet is routed through
any multiplexing components back to the master based on the
destination field.
Modules that connect multiplexing components, such as caches and
bridges store any existing source and destination field in the sender
state as a stack (just as before).
The packet constructor is simplified in that there is no longer a need
to pass the Packet::Broadcast as the destination (this was always the
case for the classic memory system). In the case of Ruby, rather than
using the parameter to the constructor we now rely on setDest, as
there is already another three-argument constructor in the packet
class.
In many places where the packet information was printed as part of
DPRINTFs, request packets would be printed with a numeric "dest" that
would always be -1 (Broadcast) and that field is now removed from the
printing.
2012-04-14 11:45:55 +02:00
|
|
|
PacketPtr fst_data_pkt = new Packet(sreqLow, MemCmd::ReadReq);
|
|
|
|
PacketPtr snd_data_pkt = new Packet(sreqHigh, MemCmd::ReadReq);
|
2011-08-01 04:21:17 +02:00
|
|
|
|
|
|
|
fst_data_pkt->dataStatic(load_inst->memData);
|
|
|
|
snd_data_pkt->dataStatic(load_inst->memData + sreqLow->getSize());
|
|
|
|
|
|
|
|
delay = TheISA::handleIprRead(thread, fst_data_pkt);
|
|
|
|
unsigned delay2 = TheISA::handleIprRead(thread, snd_data_pkt);
|
|
|
|
if (delay2 > delay)
|
|
|
|
delay = delay2;
|
|
|
|
|
|
|
|
delete sreqLow;
|
|
|
|
delete sreqHigh;
|
|
|
|
delete fst_data_pkt;
|
|
|
|
delete snd_data_pkt;
|
|
|
|
}
|
|
|
|
WritebackEvent *wb = new WritebackEvent(load_inst, data_pkt, this);
|
2012-08-28 20:30:31 +02:00
|
|
|
cpu->schedule(wb, cpu->clockEdge(delay));
|
2011-08-01 04:21:17 +02:00
|
|
|
return NoFault;
|
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
while (store_idx != -1) {
|
|
|
|
// End once we've reached the top of the LSQ
|
|
|
|
if (store_idx == storeWBIdx) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move the index to one younger
|
|
|
|
if (--store_idx < 0)
|
|
|
|
store_idx += SQEntries;
|
|
|
|
|
|
|
|
assert(storeQueue[store_idx].inst);
|
|
|
|
|
|
|
|
store_size = storeQueue[store_idx].size;
|
|
|
|
|
|
|
|
if (store_size == 0)
|
|
|
|
continue;
|
2007-03-23 16:33:08 +01:00
|
|
|
else if (storeQueue[store_idx].inst->uncacheable())
|
|
|
|
continue;
|
|
|
|
|
2012-06-05 07:23:09 +02:00
|
|
|
assert(storeQueue[store_idx].inst->effAddrValid());
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
// Check if the store data is within the lower and upper bounds of
|
|
|
|
// addresses that the request needs.
|
|
|
|
bool store_has_lower_limit =
|
2006-06-03 00:15:20 +02:00
|
|
|
req->getVaddr() >= storeQueue[store_idx].inst->effAddr;
|
2006-04-23 00:26:48 +02:00
|
|
|
bool store_has_upper_limit =
|
2006-06-03 00:15:20 +02:00
|
|
|
(req->getVaddr() + req->getSize()) <=
|
|
|
|
(storeQueue[store_idx].inst->effAddr + store_size);
|
2006-04-23 00:26:48 +02:00
|
|
|
bool lower_load_has_store_part =
|
2006-06-03 00:15:20 +02:00
|
|
|
req->getVaddr() < (storeQueue[store_idx].inst->effAddr +
|
2006-04-23 00:26:48 +02:00
|
|
|
store_size);
|
|
|
|
bool upper_load_has_store_part =
|
2006-06-03 00:15:20 +02:00
|
|
|
(req->getVaddr() + req->getSize()) >
|
|
|
|
storeQueue[store_idx].inst->effAddr;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
// If the store's data has all of the data needed, we can forward.
|
2007-03-23 16:33:08 +01:00
|
|
|
if ((store_has_lower_limit && store_has_upper_limit)) {
|
2006-05-19 21:53:17 +02:00
|
|
|
// Get shift amount for offset into the store's data.
|
2011-05-23 17:40:21 +02:00
|
|
|
int shift_amt = req->getVaddr() - storeQueue[store_idx].inst->effAddr;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2010-08-13 15:16:02 +02:00
|
|
|
memcpy(data, storeQueue[store_idx].data + shift_amt,
|
|
|
|
req->getSize());
|
2006-12-16 15:35:09 +01:00
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
assert(!load_inst->memData);
|
|
|
|
load_inst->memData = new uint8_t[64];
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2007-04-04 00:53:26 +02:00
|
|
|
memcpy(load_inst->memData,
|
|
|
|
storeQueue[store_idx].data + shift_amt, req->getSize());
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
DPRINTF(LSQUnit, "Forwarding from store idx %i to load to "
|
|
|
|
"addr %#x, data %#x\n",
|
2006-06-09 17:46:35 +02:00
|
|
|
store_idx, req->getVaddr(), data);
|
2006-06-06 00:14:39 +02:00
|
|
|
|
MEM: Remove the Broadcast destination from the packet
This patch simplifies the packet by removing the broadcast flag and
instead more firmly relying on (and enforcing) the semantics of
transactions in the classic memory system, i.e. request packets are
routed from a master to a slave based on the address, and when they
are created they have neither a valid source, nor destination. On
their way to the slave, the request packet is updated with a source
field for all modules that multiplex packets from multiple master
(e.g. a bus). When a request packet is turned into a response packet
(at the final slave), it moves the potentially populated source field
to the destination field, and the response packet is routed through
any multiplexing components back to the master based on the
destination field.
Modules that connect multiplexing components, such as caches and
bridges store any existing source and destination field in the sender
state as a stack (just as before).
The packet constructor is simplified in that there is no longer a need
to pass the Packet::Broadcast as the destination (this was always the
case for the classic memory system). In the case of Ruby, rather than
using the parameter to the constructor we now rely on setDest, as
there is already another three-argument constructor in the packet
class.
In many places where the packet information was printed as part of
DPRINTFs, request packets would be printed with a numeric "dest" that
would always be -1 (Broadcast) and that field is now removed from the
printing.
2012-04-14 11:45:55 +02:00
|
|
|
PacketPtr data_pkt = new Packet(req, MemCmd::ReadReq);
|
2006-06-06 00:14:39 +02:00
|
|
|
data_pkt->dataStatic(load_inst->memData);
|
|
|
|
|
|
|
|
WritebackEvent *wb = new WritebackEvent(load_inst, data_pkt, this);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
// We'll say this has a 1 cycle load-store forwarding latency
|
|
|
|
// for now.
|
|
|
|
// @todo: Need to make this a parameter.
|
2011-01-08 06:50:29 +01:00
|
|
|
cpu->schedule(wb, curTick());
|
2006-06-06 00:14:39 +02:00
|
|
|
|
2010-02-12 20:53:20 +01:00
|
|
|
// Don't need to do anything special for split loads.
|
|
|
|
if (TheISA::HasUnalignedMemAcc && sreqLow) {
|
|
|
|
delete sreqLow;
|
|
|
|
delete sreqHigh;
|
|
|
|
}
|
|
|
|
|
2006-06-14 04:35:05 +02:00
|
|
|
++lsqForwLoads;
|
2006-04-23 00:26:48 +02:00
|
|
|
return NoFault;
|
|
|
|
} else if ((store_has_lower_limit && lower_load_has_store_part) ||
|
|
|
|
(store_has_upper_limit && upper_load_has_store_part) ||
|
|
|
|
(lower_load_has_store_part && upper_load_has_store_part)) {
|
|
|
|
// This is the partial store-load forwarding case where a store
|
|
|
|
// has only part of the load's data.
|
|
|
|
|
|
|
|
// If it's already been written back, then don't worry about
|
|
|
|
// stalling on it.
|
|
|
|
if (storeQueue[store_idx].completed) {
|
2007-03-23 16:33:08 +01:00
|
|
|
panic("Should not check one of these");
|
2006-04-23 00:26:48 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Must stall load and force it to retry, so long as it's the oldest
|
|
|
|
// load that needs to do so.
|
|
|
|
if (!stalled ||
|
|
|
|
(stalled &&
|
2006-06-03 00:15:20 +02:00
|
|
|
load_inst->seqNum <
|
2006-04-23 00:26:48 +02:00
|
|
|
loadQueue[stallingLoadIdx]->seqNum)) {
|
|
|
|
stalled = true;
|
|
|
|
stallingStoreIsn = storeQueue[store_idx].inst->seqNum;
|
|
|
|
stallingLoadIdx = load_idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tell IQ/mem dep unit that this instruction will need to be
|
|
|
|
// rescheduled eventually
|
2006-06-03 00:15:20 +02:00
|
|
|
iewStage->rescheduleMemInst(load_inst);
|
2006-07-19 21:28:02 +02:00
|
|
|
iewStage->decrWb(load_inst->seqNum);
|
2007-03-23 16:33:08 +01:00
|
|
|
load_inst->clearIssued();
|
2006-06-14 04:35:05 +02:00
|
|
|
++lsqRescheduledLoads;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
// Do not generate a writeback event as this instruction is not
|
|
|
|
// complete.
|
|
|
|
DPRINTF(LSQUnit, "Load-store forwarding mis-match. "
|
|
|
|
"Store idx %i to load addr %#x\n",
|
2006-06-03 00:15:20 +02:00
|
|
|
store_idx, req->getVaddr());
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2007-03-23 16:33:08 +01:00
|
|
|
// Must delete request now that it wasn't handed off to
|
|
|
|
// memory. This is quite ugly. @todo: Figure out the
|
|
|
|
// proper place to really handle request deletes.
|
|
|
|
delete req;
|
2010-02-12 20:53:20 +01:00
|
|
|
if (TheISA::HasUnalignedMemAcc && sreqLow) {
|
|
|
|
delete sreqLow;
|
|
|
|
delete sreqHigh;
|
|
|
|
}
|
2007-03-23 16:33:08 +01:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
return NoFault;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there's no forwarding case, then go access memory
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
DPRINTF(LSQUnit, "Doing memory access for inst [sn:%lli] PC %s\n",
|
|
|
|
load_inst->seqNum, load_inst->pcState());
|
2006-05-19 21:53:17 +02:00
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
assert(!load_inst->memData);
|
|
|
|
load_inst->memData = new uint8_t[64];
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
++usedPorts;
|
|
|
|
|
2006-07-13 19:12:51 +02:00
|
|
|
// if we the cache is not blocked, do cache access
|
2010-02-12 20:53:20 +01:00
|
|
|
bool completedFirst = false;
|
2006-07-13 19:12:51 +02:00
|
|
|
if (!lsq->cacheBlocked()) {
|
2010-02-12 20:53:20 +01:00
|
|
|
MemCmd command =
|
|
|
|
req->isLLSC() ? MemCmd::LoadLockedReq : MemCmd::ReadReq;
|
MEM: Remove the Broadcast destination from the packet
This patch simplifies the packet by removing the broadcast flag and
instead more firmly relying on (and enforcing) the semantics of
transactions in the classic memory system, i.e. request packets are
routed from a master to a slave based on the address, and when they
are created they have neither a valid source, nor destination. On
their way to the slave, the request packet is updated with a source
field for all modules that multiplex packets from multiple master
(e.g. a bus). When a request packet is turned into a response packet
(at the final slave), it moves the potentially populated source field
to the destination field, and the response packet is routed through
any multiplexing components back to the master based on the
destination field.
Modules that connect multiplexing components, such as caches and
bridges store any existing source and destination field in the sender
state as a stack (just as before).
The packet constructor is simplified in that there is no longer a need
to pass the Packet::Broadcast as the destination (this was always the
case for the classic memory system). In the case of Ruby, rather than
using the parameter to the constructor we now rely on setDest, as
there is already another three-argument constructor in the packet
class.
In many places where the packet information was printed as part of
DPRINTFs, request packets would be printed with a numeric "dest" that
would always be -1 (Broadcast) and that field is now removed from the
printing.
2012-04-14 11:45:55 +02:00
|
|
|
PacketPtr data_pkt = new Packet(req, command);
|
2010-02-12 20:53:20 +01:00
|
|
|
PacketPtr fst_data_pkt = NULL;
|
|
|
|
PacketPtr snd_data_pkt = NULL;
|
|
|
|
|
2006-10-10 01:14:14 +02:00
|
|
|
data_pkt->dataStatic(load_inst->memData);
|
|
|
|
|
|
|
|
LSQSenderState *state = new LSQSenderState;
|
|
|
|
state->isLoad = true;
|
|
|
|
state->idx = load_idx;
|
|
|
|
state->inst = load_inst;
|
|
|
|
data_pkt->senderState = state;
|
|
|
|
|
2010-02-12 20:53:20 +01:00
|
|
|
if (!TheISA::HasUnalignedMemAcc || !sreqLow) {
|
|
|
|
|
|
|
|
// Point the first packet at the main data packet.
|
|
|
|
fst_data_pkt = data_pkt;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Create the split packets.
|
MEM: Remove the Broadcast destination from the packet
This patch simplifies the packet by removing the broadcast flag and
instead more firmly relying on (and enforcing) the semantics of
transactions in the classic memory system, i.e. request packets are
routed from a master to a slave based on the address, and when they
are created they have neither a valid source, nor destination. On
their way to the slave, the request packet is updated with a source
field for all modules that multiplex packets from multiple master
(e.g. a bus). When a request packet is turned into a response packet
(at the final slave), it moves the potentially populated source field
to the destination field, and the response packet is routed through
any multiplexing components back to the master based on the
destination field.
Modules that connect multiplexing components, such as caches and
bridges store any existing source and destination field in the sender
state as a stack (just as before).
The packet constructor is simplified in that there is no longer a need
to pass the Packet::Broadcast as the destination (this was always the
case for the classic memory system). In the case of Ruby, rather than
using the parameter to the constructor we now rely on setDest, as
there is already another three-argument constructor in the packet
class.
In many places where the packet information was printed as part of
DPRINTFs, request packets would be printed with a numeric "dest" that
would always be -1 (Broadcast) and that field is now removed from the
printing.
2012-04-14 11:45:55 +02:00
|
|
|
fst_data_pkt = new Packet(sreqLow, command);
|
|
|
|
snd_data_pkt = new Packet(sreqHigh, command);
|
2010-02-12 20:53:20 +01:00
|
|
|
|
|
|
|
fst_data_pkt->dataStatic(load_inst->memData);
|
|
|
|
snd_data_pkt->dataStatic(load_inst->memData + sreqLow->getSize());
|
|
|
|
|
|
|
|
fst_data_pkt->senderState = state;
|
|
|
|
snd_data_pkt->senderState = state;
|
|
|
|
|
|
|
|
state->isSplit = true;
|
|
|
|
state->outstanding = 2;
|
|
|
|
state->mainPkt = data_pkt;
|
|
|
|
}
|
|
|
|
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
if (!dcachePort->sendTimingReq(fst_data_pkt)) {
|
2006-10-10 01:14:14 +02:00
|
|
|
// Delete state and data packet because a load retry
|
|
|
|
// initiates a pipeline restart; it does not retry.
|
|
|
|
delete state;
|
2007-03-23 16:33:08 +01:00
|
|
|
delete data_pkt->req;
|
2006-10-10 01:14:14 +02:00
|
|
|
delete data_pkt;
|
2010-02-12 20:53:20 +01:00
|
|
|
if (TheISA::HasUnalignedMemAcc && sreqLow) {
|
|
|
|
delete fst_data_pkt->req;
|
|
|
|
delete fst_data_pkt;
|
|
|
|
delete snd_data_pkt->req;
|
|
|
|
delete snd_data_pkt;
|
2010-07-22 19:54:37 +02:00
|
|
|
sreqLow = NULL;
|
|
|
|
sreqHigh = NULL;
|
2010-02-12 20:53:20 +01:00
|
|
|
}
|
2006-10-10 01:14:14 +02:00
|
|
|
|
2007-03-23 16:33:08 +01:00
|
|
|
req = NULL;
|
|
|
|
|
2006-07-13 19:12:51 +02:00
|
|
|
// If the access didn't succeed, tell the LSQ by setting
|
|
|
|
// the retry thread id.
|
|
|
|
lsq->setRetryTid(lsqID);
|
2010-02-12 20:53:20 +01:00
|
|
|
} else if (TheISA::HasUnalignedMemAcc && sreqLow) {
|
|
|
|
completedFirst = true;
|
|
|
|
|
|
|
|
// The first packet was sent without problems, so send this one
|
|
|
|
// too. If there is a problem with this packet then the whole
|
|
|
|
// load will be squashed, so indicate this to the state object.
|
|
|
|
// The first packet will return in completeDataAccess and be
|
|
|
|
// handled there.
|
|
|
|
++usedPorts;
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
if (!dcachePort->sendTimingReq(snd_data_pkt)) {
|
2010-02-12 20:53:20 +01:00
|
|
|
|
|
|
|
// The main packet will be deleted in completeDataAccess.
|
|
|
|
delete snd_data_pkt->req;
|
|
|
|
delete snd_data_pkt;
|
|
|
|
|
|
|
|
state->complete();
|
|
|
|
|
|
|
|
req = NULL;
|
2010-07-22 19:54:37 +02:00
|
|
|
sreqHigh = NULL;
|
2010-02-12 20:53:20 +01:00
|
|
|
|
|
|
|
lsq->setRetryTid(lsqID);
|
|
|
|
}
|
2006-07-13 19:12:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the cache was blocked, or has become blocked due to the access,
|
|
|
|
// handle it.
|
|
|
|
if (lsq->cacheBlocked()) {
|
2007-03-23 16:33:08 +01:00
|
|
|
if (req)
|
|
|
|
delete req;
|
2010-02-12 20:53:20 +01:00
|
|
|
if (TheISA::HasUnalignedMemAcc && sreqLow && !completedFirst) {
|
|
|
|
delete sreqLow;
|
|
|
|
delete sreqHigh;
|
|
|
|
}
|
2007-03-23 16:33:08 +01:00
|
|
|
|
2006-06-14 04:35:05 +02:00
|
|
|
++lsqCacheBlocked;
|
2006-08-16 21:56:22 +02:00
|
|
|
|
2011-05-23 17:40:19 +02:00
|
|
|
// If the first part of a split access succeeds, then let the LSQ
|
|
|
|
// handle the decrWb when completeDataAccess is called upon return
|
|
|
|
// of the requested first part of data
|
|
|
|
if (!completedFirst)
|
|
|
|
iewStage->decrWb(load_inst->seqNum);
|
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
// There's an older load that's already going to squash.
|
|
|
|
if (isLoadBlocked && blockedLoadSeqNum < load_inst->seqNum)
|
|
|
|
return NoFault;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
// Record that the load was blocked due to memory. This
|
|
|
|
// load will squash all instructions after it, be
|
|
|
|
// refetched, and re-executed.
|
|
|
|
isLoadBlocked = true;
|
|
|
|
loadBlockedHandled = false;
|
|
|
|
blockedLoadSeqNum = load_inst->seqNum;
|
|
|
|
// No fault occurred, even though the interface is blocked.
|
|
|
|
return NoFault;
|
|
|
|
}
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
return NoFault;
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
Fault
|
2010-02-12 20:53:20 +01:00
|
|
|
LSQUnit<Impl>::write(Request *req, Request *sreqLow, Request *sreqHigh,
|
2010-08-13 15:16:02 +02:00
|
|
|
uint8_t *data, int store_idx)
|
2006-04-23 00:26:48 +02:00
|
|
|
{
|
|
|
|
assert(storeQueue[store_idx].inst);
|
|
|
|
|
|
|
|
DPRINTF(LSQUnit, "Doing write to store idx %i, addr %#x data %#x"
|
|
|
|
" | storeHead:%i [sn:%i]\n",
|
2006-06-03 00:15:20 +02:00
|
|
|
store_idx, req->getPaddr(), data, storeHead,
|
2006-04-23 00:26:48 +02:00
|
|
|
storeQueue[store_idx].inst->seqNum);
|
2006-05-19 21:53:17 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
storeQueue[store_idx].req = req;
|
2010-02-12 20:53:20 +01:00
|
|
|
storeQueue[store_idx].sreqLow = sreqLow;
|
|
|
|
storeQueue[store_idx].sreqHigh = sreqHigh;
|
2010-08-13 15:16:02 +02:00
|
|
|
unsigned size = req->getSize();
|
|
|
|
storeQueue[store_idx].size = size;
|
|
|
|
assert(size <= sizeof(storeQueue[store_idx].data));
|
2010-07-22 19:52:02 +02:00
|
|
|
|
|
|
|
// Split stores can only occur in ISAs with unaligned memory accesses. If
|
|
|
|
// a store request has been split, sreqLow and sreqHigh will be non-null.
|
|
|
|
if (TheISA::HasUnalignedMemAcc && sreqLow) {
|
|
|
|
storeQueue[store_idx].isSplit = true;
|
|
|
|
}
|
2007-04-04 00:53:26 +02:00
|
|
|
|
2010-08-13 15:16:02 +02:00
|
|
|
memcpy(storeQueue[store_idx].data, data, size);
|
2006-05-19 21:53:17 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
// This function only writes the data to the store queue, so no fault
|
|
|
|
// can happen here.
|
|
|
|
return NoFault;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __CPU_O3_LSQ_UNIT_HH__
|