btb.hh revision 2665
113521Sgabeblack@google.com/* 213521Sgabeblack@google.com * Copyright (c) 2004-2005 The Regents of The University of Michigan 313521Sgabeblack@google.com * All rights reserved. 413521Sgabeblack@google.com * 513521Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 613521Sgabeblack@google.com * modification, are permitted provided that the following conditions are 713521Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 813521Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 913521Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1013521Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1113521Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1213521Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1313521Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1413521Sgabeblack@google.com * this software without specific prior written permission. 1513521Sgabeblack@google.com * 1613521Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1713521Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1813521Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1913521Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2013521Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2113521Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2213521Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2313586Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2413521Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2513521Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2613521Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2713521Sgabeblack@google.com * 2813521Sgabeblack@google.com * Authors: Kevin Lim 2913521Sgabeblack@google.com */ 3013521Sgabeblack@google.com 3113521Sgabeblack@google.com#ifndef __CPU_O3_CPU_BTB_HH__ 3213521Sgabeblack@google.com#define __CPU_O3_CPU_BTB_HH__ 3313521Sgabeblack@google.com 3413521Sgabeblack@google.com// For Addr type. 3513521Sgabeblack@google.com#include "arch/isa_traits.hh" 3613521Sgabeblack@google.com 3713521Sgabeblack@google.comclass DefaultBTB 3813521Sgabeblack@google.com{ 3913521Sgabeblack@google.com private: 4013521Sgabeblack@google.com struct BTBEntry 4113521Sgabeblack@google.com { 4213521Sgabeblack@google.com BTBEntry() 4313521Sgabeblack@google.com : tag(0), target(0), valid(false) 4413521Sgabeblack@google.com { 4513521Sgabeblack@google.com } 4613521Sgabeblack@google.com 4713521Sgabeblack@google.com Addr tag; 4813521Sgabeblack@google.com Addr target; 4913521Sgabeblack@google.com bool valid; 5013521Sgabeblack@google.com }; 5113521Sgabeblack@google.com 5213521Sgabeblack@google.com public: 5313521Sgabeblack@google.com DefaultBTB(unsigned numEntries, unsigned tagBits, 5413521Sgabeblack@google.com unsigned instShiftAmt); 5513521Sgabeblack@google.com 5613521Sgabeblack@google.com Addr lookup(const Addr &inst_PC); 5713521Sgabeblack@google.com 5813521Sgabeblack@google.com bool valid(const Addr &inst_PC); 5913521Sgabeblack@google.com 6013521Sgabeblack@google.com void update(const Addr &inst_PC, const Addr &target_PC); 6113521Sgabeblack@google.com 6213521Sgabeblack@google.com private: 6313521Sgabeblack@google.com inline unsigned getIndex(const Addr &inst_PC); 6413521Sgabeblack@google.com 6513521Sgabeblack@google.com inline Addr getTag(const Addr &inst_PC); 6613521Sgabeblack@google.com 6713521Sgabeblack@google.com BTBEntry *btb; 6813521Sgabeblack@google.com 6913521Sgabeblack@google.com unsigned numEntries; 7013521Sgabeblack@google.com 7113521Sgabeblack@google.com unsigned idxMask; 7213521Sgabeblack@google.com 7313521Sgabeblack@google.com unsigned tagBits; 7413521Sgabeblack@google.com 7513521Sgabeblack@google.com unsigned tagMask; 7613521Sgabeblack@google.com 7713521Sgabeblack@google.com unsigned instShiftAmt; 7813521Sgabeblack@google.com 7913521Sgabeblack@google.com unsigned tagShiftAmt; 8013521Sgabeblack@google.com}; 8113521Sgabeblack@google.com 8213521Sgabeblack@google.com#endif // __CPU_O3_CPU_BTB_HH__ 8313521Sgabeblack@google.com