fu_pool.hh revision 2307
1955SN/A/* 2955SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan 35871Snate@binkert.org * All rights reserved. 41762SN/A * 5955SN/A * Redistribution and use in source and binary forms, with or without 6955SN/A * modification, are permitted provided that the following conditions are 7955SN/A * met: redistributions of source code must retain the above copyright 8955SN/A * notice, this list of conditions and the following disclaimer; 9955SN/A * redistributions in binary form must reproduce the above copyright 10955SN/A * notice, this list of conditions and the following disclaimer in the 11955SN/A * documentation and/or other materials provided with the distribution; 12955SN/A * neither the name of the copyright holders nor the names of its 13955SN/A * contributors may be used to endorse or promote products derived from 14955SN/A * this software without specific prior written permission. 15955SN/A * 16955SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17955SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18955SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19955SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20955SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21955SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22955SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23955SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24955SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25955SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26955SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27955SN/A */ 28955SN/A 292665Ssaidi@eecs.umich.edu#ifndef __CPU_O3_FU_POOL_HH__ 302665Ssaidi@eecs.umich.edu#define __CPU_O3_FU_POOL_HH__ 315863Snate@binkert.org 32955SN/A#include <bitset> 33955SN/A#include <list> 34955SN/A#include <string> 35955SN/A#include <vector> 36955SN/A 372632Sstever@eecs.umich.edu#include "base/sched_list.hh" 382632Sstever@eecs.umich.edu#include "encumbered/cpu/full/op_class.hh" 392632Sstever@eecs.umich.edu#include "sim/sim_object.hh" 402632Sstever@eecs.umich.edu 41955SN/Aclass FUDesc; 422632Sstever@eecs.umich.educlass FuncUnit; 432632Sstever@eecs.umich.edu 442761Sstever@eecs.umich.edu/** 452632Sstever@eecs.umich.edu * Pool of FU's, specific to the new CPU model. The old FU pool had lists of 462632Sstever@eecs.umich.edu * free units and busy units, and whenever a FU was needed it would iterate 472632Sstever@eecs.umich.edu * through the free units to find a FU that provided the capability. This pool 482761Sstever@eecs.umich.edu * has lists of units specific to each of the capabilities, and whenever a FU 492761Sstever@eecs.umich.edu * is needed, it iterates through that list to find a free unit. The previous 502761Sstever@eecs.umich.edu * FU pool would have to be ticked each cycle to update which units became 512632Sstever@eecs.umich.edu * free. This FU pool lets the IEW stage handle freeing units, which frees 522632Sstever@eecs.umich.edu * them as their scheduled execution events complete. This limits units in this 532761Sstever@eecs.umich.edu * model to either have identical issue and op latencies, or 1 cycle issue 542761Sstever@eecs.umich.edu * latencies. 552761Sstever@eecs.umich.edu */ 562761Sstever@eecs.umich.educlass FUPool : public SimObject 572761Sstever@eecs.umich.edu{ 582632Sstever@eecs.umich.edu private: 592632Sstever@eecs.umich.edu /** Maximum op execution latencies, per op class. */ 602632Sstever@eecs.umich.edu unsigned maxOpLatencies[Num_OpClasses]; 612632Sstever@eecs.umich.edu /** Maximum issue latencies, per op class. */ 622632Sstever@eecs.umich.edu unsigned maxIssueLatencies[Num_OpClasses]; 632632Sstever@eecs.umich.edu 642632Sstever@eecs.umich.edu /** Bitvector listing capabilities of this FU pool. */ 65955SN/A std::bitset<Num_OpClasses> capabilityList; 66955SN/A 67955SN/A /** Bitvector listing which FUs are busy. */ 685863Snate@binkert.org std::vector<bool> unitBusy; 695863Snate@binkert.org 705863Snate@binkert.org /** List of units to be freed at the end of this cycle. */ 715863Snate@binkert.org std::vector<int> unitsToBeFreed; 725863Snate@binkert.org 735863Snate@binkert.org /** 745863Snate@binkert.org * Class that implements a circular queue to hold FU indices. The hope is 755863Snate@binkert.org * that FUs that have been just used will be moved to the end of the queue 765863Snate@binkert.org * by iterating through it, thus leaving free units at the head of the 775863Snate@binkert.org * queue. 785863Snate@binkert.org */ 795863Snate@binkert.org class FUIdxQueue { 805863Snate@binkert.org public: 815863Snate@binkert.org /** Constructs a circular queue of FU indices. */ 825863Snate@binkert.org FUIdxQueue() 835863Snate@binkert.org : idx(0), size(0) 845863Snate@binkert.org { } 855863Snate@binkert.org 865863Snate@binkert.org /** Adds a FU to the queue. */ 875863Snate@binkert.org inline void addFU(int fu_idx); 885863Snate@binkert.org 895863Snate@binkert.org /** Returns the index of the FU at the head of the queue, and changes 905863Snate@binkert.org * the index to the next element. 915863Snate@binkert.org */ 925863Snate@binkert.org inline int getFU(); 935863Snate@binkert.org 945863Snate@binkert.org private: 955863Snate@binkert.org /** Circular queue index. */ 965863Snate@binkert.org int idx; 975863Snate@binkert.org 985863Snate@binkert.org /** Size of the queue. */ 99955SN/A int size; 1005396Ssaidi@eecs.umich.edu 1015863Snate@binkert.org /** Queue of FU indices. */ 1025863Snate@binkert.org std::vector<int> funcUnitsIdx; 1034202Sbinkertn@umich.edu }; 1045863Snate@binkert.org 1055863Snate@binkert.org /** Per op class queues of FUs that provide that capability. */ 1065863Snate@binkert.org FUIdxQueue fuPerCapList[Num_OpClasses]; 1075863Snate@binkert.org 108955SN/A /** Number of FUs. */ 1095273Sstever@gmail.com int numFU; 1105871Snate@binkert.org 1115273Sstever@gmail.com /** Functional units. */ 1125871Snate@binkert.org std::vector<FuncUnit *> funcUnits; 1135863Snate@binkert.org 1145863Snate@binkert.org typedef std::vector<FuncUnit *>::iterator fuListIterator; 1155863Snate@binkert.org 1165871Snate@binkert.org public: 1175872Snate@binkert.org 1185872Snate@binkert.org /** Constructs a FU pool. */ 1195872Snate@binkert.org FUPool(std::string name, std::vector<FUDesc *> l); 1205871Snate@binkert.org ~FUPool(); 1215871Snate@binkert.org 1225871Snate@binkert.org /** Annotates units that provide memory operations. Included only because 1235871Snate@binkert.org * old FU pool provided this function. 1245871Snate@binkert.org */ 1255871Snate@binkert.org void annotateMemoryUnits(unsigned hit_latency); 1265871Snate@binkert.org 1275871Snate@binkert.org /** 1285871Snate@binkert.org * Gets a FU providing the requested capability. Will mark the unit as busy, 1295871Snate@binkert.org * but leaves the freeing of the unit up to the IEW stage. 1305871Snate@binkert.org * @param capability The capability requested. 1315871Snate@binkert.org * @return Returns -2 if the FU pool does not have the capability, -1 if 1325871Snate@binkert.org * there is no free FU, and the FU's index otherwise. 1335871Snate@binkert.org */ 1345863Snate@binkert.org int getUnit(OpClass capability); 1355227Ssaidi@eecs.umich.edu 1365396Ssaidi@eecs.umich.edu /** Frees a FU at the end of this cycle. */ 1375396Ssaidi@eecs.umich.edu void freeUnit(int fu_idx); 1385396Ssaidi@eecs.umich.edu 1395396Ssaidi@eecs.umich.edu /** Frees all FUs on the list. */ 1405396Ssaidi@eecs.umich.edu void processFreeUnits(); 1415396Ssaidi@eecs.umich.edu 1425396Ssaidi@eecs.umich.edu /** Returns the total number of FUs. */ 1435396Ssaidi@eecs.umich.edu int size() { return numFU; } 1445588Ssaidi@eecs.umich.edu 1455396Ssaidi@eecs.umich.edu /** Debugging function used to dump FU information. */ 1465396Ssaidi@eecs.umich.edu void dump(); 1475396Ssaidi@eecs.umich.edu 1485396Ssaidi@eecs.umich.edu /** Returns the operation execution latency of the given capability. */ 1495396Ssaidi@eecs.umich.edu unsigned getOpLatency(OpClass capability) { 1505396Ssaidi@eecs.umich.edu return maxOpLatencies[capability]; 1515396Ssaidi@eecs.umich.edu } 1525396Ssaidi@eecs.umich.edu 1535396Ssaidi@eecs.umich.edu /** Returns the issue latency of the given capability. */ 1545396Ssaidi@eecs.umich.edu unsigned getIssueLatency(OpClass capability) { 1555396Ssaidi@eecs.umich.edu return maxIssueLatencies[capability]; 1565396Ssaidi@eecs.umich.edu } 1575396Ssaidi@eecs.umich.edu 1585396Ssaidi@eecs.umich.edu void switchOut(); 1595871Snate@binkert.org void takeOverFrom(); 1605871Snate@binkert.org}; 1615871Snate@binkert.org 1625871Snate@binkert.org#endif // __CPU_O3_FU_POOL_HH__ 1635871Snate@binkert.org