2bit_local.hh revision 1689
12623SN/A/* 22623SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan 32623SN/A * All rights reserved. 42623SN/A * 52623SN/A * Redistribution and use in source and binary forms, with or without 62623SN/A * modification, are permitted provided that the following conditions are 72623SN/A * met: redistributions of source code must retain the above copyright 82623SN/A * notice, this list of conditions and the following disclaimer; 92623SN/A * redistributions in binary form must reproduce the above copyright 102623SN/A * notice, this list of conditions and the following disclaimer in the 112623SN/A * documentation and/or other materials provided with the distribution; 122623SN/A * neither the name of the copyright holders nor the names of its 132623SN/A * contributors may be used to endorse or promote products derived from 142623SN/A * this software without specific prior written permission. 152623SN/A * 162623SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172623SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182623SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192623SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202623SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212623SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222623SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232623SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242623SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252623SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262623SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu */ 282665Ssaidi@eecs.umich.edu 292623SN/A#ifndef __CPU_BETA_CPU_2BIT_LOCAL_PRED_HH__ 302623SN/A#define __CPU_BETA_CPU_2BIT_LOCAL_PRED_HH__ 313170Sstever@eecs.umich.edu 322623SN/A// For Addr type. 332623SN/A#include "arch/alpha/isa_traits.hh" 342623SN/A#include "cpu/beta_cpu/sat_counter.hh" 353348Sbinkertn@umich.edu 363348Sbinkertn@umich.educlass DefaultBP 372623SN/A{ 382901Ssaidi@eecs.umich.edu public: 392623SN/A /** 402623SN/A * Default branch predictor constructor. 412623SN/A */ 422623SN/A DefaultBP(unsigned localPredictorSize, unsigned localCtrBits, 432623SN/A unsigned instShiftAmt); 442623SN/A 452623SN/A /** 462623SN/A * Looks up the given address in the branch predictor and returns 472623SN/A * a true/false value as to whether it is taken. 482623SN/A * @param branch_addr The address of the branch to look up. 492623SN/A * @return Whether or not the branch is taken. 502623SN/A */ 512623SN/A bool lookup(Addr &branch_addr); 522623SN/A 532623SN/A /** 542623SN/A * Updates the branch predictor with the actual result of a branch. 552623SN/A * @param branch_addr The address of the branch to update. 562623SN/A * @param taken Whether or not the branch was taken. 572623SN/A */ 582623SN/A void update(Addr &branch_addr, bool taken); 592623SN/A 602623SN/A private: 612856Srdreslin@umich.edu 622856Srdreslin@umich.edu /** Returns the taken/not taken prediction given the value of the 632856Srdreslin@umich.edu * counter. 642856Srdreslin@umich.edu */ 652856Srdreslin@umich.edu inline bool getPrediction(uint8_t &count); 662856Srdreslin@umich.edu 672856Srdreslin@umich.edu /** Calculates the local index based on the PC. */ 682856Srdreslin@umich.edu inline unsigned getLocalIndex(Addr &PC); 692856Srdreslin@umich.edu 702856Srdreslin@umich.edu /** Array of counters that make up the local predictor. */ 712623SN/A SatCounter *localCtrs; 722623SN/A 732623SN/A /** Size of the local predictor. */ 742623SN/A unsigned localPredictorSize; 752623SN/A 762856Srdreslin@umich.edu /** Number of bits of the local predictor's counters. */ 772856Srdreslin@umich.edu unsigned localCtrBits; 782856Srdreslin@umich.edu 792623SN/A /** Number of bits to shift the PC when calculating index. */ 802856Srdreslin@umich.edu unsigned instShiftAmt; 812856Srdreslin@umich.edu 822856Srdreslin@umich.edu /** Mask to get index bits. */ 832623SN/A unsigned indexMask; 842623SN/A}; 852623SN/A 862680Sktlim@umich.edu#endif // __CPU_BETA_CPU_2BIT_LOCAL_PRED_HH__ 872680Sktlim@umich.edu