rename.hh revision 2665
13520Sgblack@eecs.umich.edu/* 23520Sgblack@eecs.umich.edu * Copyright (c) 2004-2005 The Regents of The University of Michigan 33520Sgblack@eecs.umich.edu * All rights reserved. 43520Sgblack@eecs.umich.edu * 53520Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 63520Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 73520Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 83520Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 93520Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 103520Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 113520Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 123520Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 133520Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 143520Sgblack@eecs.umich.edu * this software without specific prior written permission. 153520Sgblack@eecs.umich.edu * 163520Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 173520Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 183520Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 193520Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 203520Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 213520Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 223520Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 233520Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 243520Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 253520Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 263520Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 273520Sgblack@eecs.umich.edu * 283520Sgblack@eecs.umich.edu * Authors: Kevin Lim 293520Sgblack@eecs.umich.edu */ 303520Sgblack@eecs.umich.edu 313520Sgblack@eecs.umich.edu// Todo: 323520Sgblack@eecs.umich.edu// Fix up trap and barrier handling. 333520Sgblack@eecs.umich.edu// May want to have different statuses to differentiate the different stall 343520Sgblack@eecs.umich.edu// conditions. 353520Sgblack@eecs.umich.edu 363520Sgblack@eecs.umich.edu#ifndef __CPU_O3_CPU_SIMPLE_RENAME_HH__ 374103Ssaidi@eecs.umich.edu#define __CPU_O3_CPU_SIMPLE_RENAME_HH__ 385647Sgblack@eecs.umich.edu 393520Sgblack@eecs.umich.edu#include <list> 408232Snate@binkert.org 418232Snate@binkert.org#include "base/statistics.hh" 425647Sgblack@eecs.umich.edu#include "base/timebuf.hh" 435647Sgblack@eecs.umich.edu 443520Sgblack@eecs.umich.edu// Will need rename maps for both the int reg file and fp reg file. 455565Snate@binkert.org// Or change rename map class to handle both. (RegFile handles both.) 465565Snate@binkert.orgtemplate<class Impl> 475647Sgblack@eecs.umich.educlass SimpleRename 483520Sgblack@eecs.umich.edu{ 495565Snate@binkert.org public: 505565Snate@binkert.org // Typedefs from the Impl. 515565Snate@binkert.org typedef typename Impl::CPUPol CPUPol; 525565Snate@binkert.org typedef typename Impl::DynInstPtr DynInstPtr; 535810Sgblack@eecs.umich.edu typedef typename Impl::FullCPU FullCPU; 545565Snate@binkert.org typedef typename Impl::Params Params; 555565Snate@binkert.org 565565Snate@binkert.org typedef typename CPUPol::FetchStruct FetchStruct; 575565Snate@binkert.org typedef typename CPUPol::DecodeStruct DecodeStruct; 585565Snate@binkert.org typedef typename CPUPol::RenameStruct RenameStruct; 595565Snate@binkert.org typedef typename CPUPol::TimeStruct TimeStruct; 605647Sgblack@eecs.umich.edu 615647Sgblack@eecs.umich.edu // Typedefs from the CPUPol 625647Sgblack@eecs.umich.edu typedef typename CPUPol::FreeList FreeList; 635647Sgblack@eecs.umich.edu typedef typename CPUPol::RenameMap RenameMap; 645647Sgblack@eecs.umich.edu 655647Sgblack@eecs.umich.edu // Typedefs from the ISA. 665647Sgblack@eecs.umich.edu typedef TheISA::RegIndex RegIndex; 675647Sgblack@eecs.umich.edu 685810Sgblack@eecs.umich.edu public: 693520Sgblack@eecs.umich.edu // Rename will block if ROB becomes full or issue queue becomes full, 705565Snate@binkert.org // or there are no free registers to rename to. 715565Snate@binkert.org // Only case where rename squashes is if IEW squashes. 725565Snate@binkert.org enum Status { 735565Snate@binkert.org Running, 743520Sgblack@eecs.umich.edu Idle, 755565Snate@binkert.org Squashing, 765810Sgblack@eecs.umich.edu Blocked, 775810Sgblack@eecs.umich.edu Unblocking, 785810Sgblack@eecs.umich.edu BarrierStall 795810Sgblack@eecs.umich.edu }; 805810Sgblack@eecs.umich.edu 815810Sgblack@eecs.umich.edu private: 825565Snate@binkert.org Status _status; 835565Snate@binkert.org 845565Snate@binkert.org public: 853520Sgblack@eecs.umich.edu SimpleRename(Params ¶ms); 865565Snate@binkert.org 875565Snate@binkert.org void regStats(); 883520Sgblack@eecs.umich.edu 895565Snate@binkert.org void setCPU(FullCPU *cpu_ptr); 905565Snate@binkert.org 913520Sgblack@eecs.umich.edu void setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr); 925565Snate@binkert.org 935565Snate@binkert.org void setRenameQueue(TimeBuffer<RenameStruct> *rq_ptr); 945565Snate@binkert.org 953520Sgblack@eecs.umich.edu void setDecodeQueue(TimeBuffer<DecodeStruct> *dq_ptr); 965565Snate@binkert.org 975565Snate@binkert.org void setRenameMap(RenameMap *rm_ptr); 985565Snate@binkert.org 995565Snate@binkert.org void setFreeList(FreeList *fl_ptr); 1003520Sgblack@eecs.umich.edu 1015568Snate@binkert.org void dumpHistory(); 1025565Snate@binkert.org 1033520Sgblack@eecs.umich.edu void tick(); 1045565Snate@binkert.org 1055565Snate@binkert.org void rename(); 1063520Sgblack@eecs.umich.edu 1075565Snate@binkert.org void squash(); 1085565Snate@binkert.org 1095565Snate@binkert.org private: 1105565Snate@binkert.org void block(); 1113520Sgblack@eecs.umich.edu 1125565Snate@binkert.org inline void unblock(); 1135704Snate@binkert.org 1145565Snate@binkert.org void doSquash(); 1155565Snate@binkert.org 1163520Sgblack@eecs.umich.edu void removeFromHistory(InstSeqNum inst_seq_num); 1175565Snate@binkert.org 1185565Snate@binkert.org inline void renameSrcRegs(DynInstPtr &inst); 1195565Snate@binkert.org 1203520Sgblack@eecs.umich.edu inline void renameDestRegs(DynInstPtr &inst); 1215565Snate@binkert.org 1225565Snate@binkert.org inline int calcFreeROBEntries(); 1235565Snate@binkert.org 1245565Snate@binkert.org inline int calcFreeIQEntries(); 1255565Snate@binkert.org 1265565Snate@binkert.org /** Holds the previous information for each rename. 1273520Sgblack@eecs.umich.edu * Note that often times the inst may have been deleted, so only access 1285565Snate@binkert.org * the pointer for the address and do not dereference it. 1295565Snate@binkert.org */ 1305565Snate@binkert.org struct RenameHistory { 1315565Snate@binkert.org RenameHistory(InstSeqNum _instSeqNum, RegIndex _archReg, 1325565Snate@binkert.org PhysRegIndex _newPhysReg, PhysRegIndex _prevPhysReg) 1335565Snate@binkert.org : instSeqNum(_instSeqNum), archReg(_archReg), 1343520Sgblack@eecs.umich.edu newPhysReg(_newPhysReg), prevPhysReg(_prevPhysReg), 1355565Snate@binkert.org placeHolder(false) 1365704Snate@binkert.org { 1375565Snate@binkert.org } 1387720Sgblack@eecs.umich.edu 1395565Snate@binkert.org /** Constructor used specifically for cases where a place holder 1403520Sgblack@eecs.umich.edu * rename history entry is being made. 1415565Snate@binkert.org */ 1425565Snate@binkert.org RenameHistory(InstSeqNum _instSeqNum) 1435565Snate@binkert.org : instSeqNum(_instSeqNum), archReg(0), newPhysReg(0), 1446227Snate@binkert.org prevPhysReg(0), placeHolder(true) 1456227Snate@binkert.org { 1463521Sgblack@eecs.umich.edu } 1475565Snate@binkert.org 1485565Snate@binkert.org InstSeqNum instSeqNum; 1493520Sgblack@eecs.umich.edu RegIndex archReg; 1505565Snate@binkert.org PhysRegIndex newPhysReg; 1516227Snate@binkert.org PhysRegIndex prevPhysReg; 1525565Snate@binkert.org bool placeHolder; 1535565Snate@binkert.org }; 1545565Snate@binkert.org 1555565Snate@binkert.org std::list<RenameHistory> historyBuffer; 1565565Snate@binkert.org 1573520Sgblack@eecs.umich.edu /** CPU interface. */ 1583520Sgblack@eecs.umich.edu FullCPU *cpu; 1593520Sgblack@eecs.umich.edu 1603520Sgblack@eecs.umich.edu // Interfaces to objects outside of rename. 1615565Snate@binkert.org /** Time buffer interface. */ 1625565Snate@binkert.org TimeBuffer<TimeStruct> *timeBuffer; 1636227Snate@binkert.org 1645565Snate@binkert.org /** Wire to get IEW's output from backwards time buffer. */ 1655565Snate@binkert.org typename TimeBuffer<TimeStruct>::wire fromIEW; 1665565Snate@binkert.org 1675565Snate@binkert.org /** Wire to get commit's output from backwards time buffer. */ 1685565Snate@binkert.org typename TimeBuffer<TimeStruct>::wire fromCommit; 1695565Snate@binkert.org 1705565Snate@binkert.org /** Wire to write infromation heading to previous stages. */ 1713633Sktlim@umich.edu // Might not be the best name as not only decode will read it. 1723633Sktlim@umich.edu typename TimeBuffer<TimeStruct>::wire toDecode; 1735565Snate@binkert.org 1745565Snate@binkert.org /** Rename instruction queue. */ 1755565Snate@binkert.org TimeBuffer<RenameStruct> *renameQueue; 1765565Snate@binkert.org 1775565Snate@binkert.org /** Wire to write any information heading to IEW. */ 1785565Snate@binkert.org typename TimeBuffer<RenameStruct>::wire toIEW; 1795565Snate@binkert.org 1805565Snate@binkert.org /** Decode instruction queue interface. */ 1815565Snate@binkert.org TimeBuffer<DecodeStruct> *decodeQueue; 1825565Snate@binkert.org 1834103Ssaidi@eecs.umich.edu /** Wire to get decode's output from decode queue. */ 1845565Snate@binkert.org typename TimeBuffer<DecodeStruct>::wire fromDecode; 1854103Ssaidi@eecs.umich.edu 1865565Snate@binkert.org /** Skid buffer between rename and decode. */ 1875565Snate@binkert.org std::queue<DecodeStruct> skidBuffer; 1885565Snate@binkert.org 1895565Snate@binkert.org /** Rename map interface. */ 1905565Snate@binkert.org SimpleRenameMap *renameMap; 1915565Snate@binkert.org 1925565Snate@binkert.org /** Free list interface. */ 1935565Snate@binkert.org FreeList *freeList; 1945565Snate@binkert.org 1953520Sgblack@eecs.umich.edu /** Delay between iew and rename, in ticks. */ 1965565Snate@binkert.org int iewToRenameDelay; 1975565Snate@binkert.org 1985565Snate@binkert.org /** Delay between decode and rename, in ticks. */ 1995565Snate@binkert.org int decodeToRenameDelay; 200 201 /** Delay between commit and rename, in ticks. */ 202 unsigned commitToRenameDelay; 203 204 /** Rename width, in instructions. */ 205 unsigned renameWidth; 206 207 /** Commit width, in instructions. Used so rename knows how many 208 * instructions might have freed registers in the previous cycle. 209 */ 210 unsigned commitWidth; 211 212 /** The instruction that rename is currently on. It needs to have 213 * persistent state so that when a stall occurs in the middle of a 214 * group of instructions, it can restart at the proper instruction. 215 */ 216 unsigned numInst; 217 218 Stats::Scalar<> renameSquashCycles; 219 Stats::Scalar<> renameIdleCycles; 220 Stats::Scalar<> renameBlockCycles; 221 Stats::Scalar<> renameUnblockCycles; 222 Stats::Scalar<> renameRenamedInsts; 223 Stats::Scalar<> renameSquashedInsts; 224 Stats::Scalar<> renameROBFullEvents; 225 Stats::Scalar<> renameIQFullEvents; 226 Stats::Scalar<> renameFullRegistersEvents; 227 Stats::Scalar<> renameRenamedOperands; 228 Stats::Scalar<> renameRenameLookups; 229 Stats::Scalar<> renameHBPlaceHolders; 230 Stats::Scalar<> renameCommittedMaps; 231 Stats::Scalar<> renameUndoneMaps; 232 Stats::Scalar<> renameValidUndoneMaps; 233}; 234 235#endif // __CPU_O3_CPU_SIMPLE_RENAME_HH__ 236