fu_pool.hh revision 9184
12292SN/A/* 22689Sktlim@umich.edu * Copyright (c) 2006 The Regents of The University of Michigan 32292SN/A * All rights reserved. 42292SN/A * 52292SN/A * Redistribution and use in source and binary forms, with or without 62292SN/A * modification, are permitted provided that the following conditions are 72292SN/A * met: redistributions of source code must retain the above copyright 82292SN/A * notice, this list of conditions and the following disclaimer; 92292SN/A * redistributions in binary form must reproduce the above copyright 102292SN/A * notice, this list of conditions and the following disclaimer in the 112292SN/A * documentation and/or other materials provided with the distribution; 122292SN/A * neither the name of the copyright holders nor the names of its 132292SN/A * contributors may be used to endorse or promote products derived from 142292SN/A * this software without specific prior written permission. 152292SN/A * 162292SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172292SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182292SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192292SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202292SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212292SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222292SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232292SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242292SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252292SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262292SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272689Sktlim@umich.edu * 282689Sktlim@umich.edu * Authors: Kevin Lim 292292SN/A */ 302292SN/A 312292SN/A#ifndef __CPU_O3_FU_POOL_HH__ 322292SN/A#define __CPU_O3_FU_POOL_HH__ 332292SN/A 342292SN/A#include <bitset> 352292SN/A#include <list> 362292SN/A#include <string> 372292SN/A#include <vector> 382292SN/A 398229Snate@binkert.org#include "cpu/op_class.hh" 405034Smilesck@eecs.umich.edu#include "params/FUPool.hh" 412292SN/A#include "sim/sim_object.hh" 422292SN/A 432292SN/Aclass FUDesc; 442292SN/Aclass FuncUnit; 452292SN/A 462292SN/A/** 472292SN/A * Pool of FU's, specific to the new CPU model. The old FU pool had lists of 482292SN/A * free units and busy units, and whenever a FU was needed it would iterate 492292SN/A * through the free units to find a FU that provided the capability. This pool 502292SN/A * has lists of units specific to each of the capabilities, and whenever a FU 512292SN/A * is needed, it iterates through that list to find a free unit. The previous 522292SN/A * FU pool would have to be ticked each cycle to update which units became 532292SN/A * free. This FU pool lets the IEW stage handle freeing units, which frees 542292SN/A * them as their scheduled execution events complete. This limits units in this 552292SN/A * model to either have identical issue and op latencies, or 1 cycle issue 562292SN/A * latencies. 572292SN/A */ 582292SN/Aclass FUPool : public SimObject 592292SN/A{ 602292SN/A private: 612292SN/A /** Maximum op execution latencies, per op class. */ 629184Sandreas.hansson@arm.com Cycles maxOpLatencies[Num_OpClasses]; 632292SN/A /** Maximum issue latencies, per op class. */ 649184Sandreas.hansson@arm.com Cycles maxIssueLatencies[Num_OpClasses]; 652292SN/A 662292SN/A /** Bitvector listing capabilities of this FU pool. */ 672292SN/A std::bitset<Num_OpClasses> capabilityList; 682292SN/A 692292SN/A /** Bitvector listing which FUs are busy. */ 702292SN/A std::vector<bool> unitBusy; 712292SN/A 722292SN/A /** List of units to be freed at the end of this cycle. */ 732292SN/A std::vector<int> unitsToBeFreed; 742292SN/A 752292SN/A /** 762292SN/A * Class that implements a circular queue to hold FU indices. The hope is 772292SN/A * that FUs that have been just used will be moved to the end of the queue 782292SN/A * by iterating through it, thus leaving free units at the head of the 792292SN/A * queue. 802292SN/A */ 812292SN/A class FUIdxQueue { 822292SN/A public: 832292SN/A /** Constructs a circular queue of FU indices. */ 842292SN/A FUIdxQueue() 852292SN/A : idx(0), size(0) 862292SN/A { } 872292SN/A 882292SN/A /** Adds a FU to the queue. */ 892292SN/A inline void addFU(int fu_idx); 902292SN/A 912292SN/A /** Returns the index of the FU at the head of the queue, and changes 922292SN/A * the index to the next element. 932292SN/A */ 942292SN/A inline int getFU(); 952292SN/A 962292SN/A private: 972292SN/A /** Circular queue index. */ 982292SN/A int idx; 992292SN/A 1002292SN/A /** Size of the queue. */ 1012292SN/A int size; 1022292SN/A 1032292SN/A /** Queue of FU indices. */ 1042292SN/A std::vector<int> funcUnitsIdx; 1052292SN/A }; 1062292SN/A 1072292SN/A /** Per op class queues of FUs that provide that capability. */ 1082292SN/A FUIdxQueue fuPerCapList[Num_OpClasses]; 1092292SN/A 1102292SN/A /** Number of FUs. */ 1112292SN/A int numFU; 1122292SN/A 1132292SN/A /** Functional units. */ 1142292SN/A std::vector<FuncUnit *> funcUnits; 1152292SN/A 1162292SN/A typedef std::vector<FuncUnit *>::iterator fuListIterator; 1172292SN/A 1182292SN/A public: 1195034Smilesck@eecs.umich.edu typedef FUPoolParams Params; 1202292SN/A /** Constructs a FU pool. */ 1215034Smilesck@eecs.umich.edu FUPool(const Params *p); 1222292SN/A ~FUPool(); 1232292SN/A 1242292SN/A /** Annotates units that provide memory operations. Included only because 1252292SN/A * old FU pool provided this function. 1262292SN/A */ 1279184Sandreas.hansson@arm.com void annotateMemoryUnits(Cycles hit_latency); 1282292SN/A 1292292SN/A /** 1302292SN/A * Gets a FU providing the requested capability. Will mark the unit as busy, 1312292SN/A * but leaves the freeing of the unit up to the IEW stage. 1322292SN/A * @param capability The capability requested. 1332292SN/A * @return Returns -2 if the FU pool does not have the capability, -1 if 1342292SN/A * there is no free FU, and the FU's index otherwise. 1352292SN/A */ 1362292SN/A int getUnit(OpClass capability); 1372292SN/A 1382292SN/A /** Frees a FU at the end of this cycle. */ 1392327SN/A void freeUnitNextCycle(int fu_idx); 1402292SN/A 1412292SN/A /** Frees all FUs on the list. */ 1422292SN/A void processFreeUnits(); 1432292SN/A 1442292SN/A /** Returns the total number of FUs. */ 1452292SN/A int size() { return numFU; } 1462292SN/A 1472292SN/A /** Debugging function used to dump FU information. */ 1482292SN/A void dump(); 1492292SN/A 1502292SN/A /** Returns the operation execution latency of the given capability. */ 1519184Sandreas.hansson@arm.com Cycles getOpLatency(OpClass capability) { 1522292SN/A return maxOpLatencies[capability]; 1532292SN/A } 1542292SN/A 1552292SN/A /** Returns the issue latency of the given capability. */ 1569184Sandreas.hansson@arm.com Cycles getIssueLatency(OpClass capability) { 1572292SN/A return maxIssueLatencies[capability]; 1582292SN/A } 1592307SN/A 1602348SN/A /** Switches out functional unit pool. */ 1612307SN/A void switchOut(); 1622348SN/A 1632348SN/A /** Takes over from another CPU's thread. */ 1648737Skoansin.tan@gmail.com void takeOver(); 1652292SN/A}; 1662292SN/A 1672292SN/A#endif // __CPU_O3_FU_POOL_HH__ 168