BranchPredictor.py revision 13442:5314c50529a5
1# Copyright (c) 2012 Mark D. Hill and David A. Wood 2# Copyright (c) 2015 The University of Wisconsin 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; 9# redistributions in binary form must reproduce the above copyright 10# notice, this list of conditions and the following disclaimer in the 11# documentation and/or other materials provided with the distribution; 12# neither the name of the copyright holders nor the names of its 13# contributors may be used to endorse or promote products derived from 14# this software without specific prior written permission. 15# 16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27# 28# Authors: Nilay Vaish and Dibakar Gope 29 30from m5.SimObject import SimObject 31from m5.params import * 32from m5.proxy import * 33 34class BranchPredictor(SimObject): 35 type = 'BranchPredictor' 36 cxx_class = 'BPredUnit' 37 cxx_header = "cpu/pred/bpred_unit.hh" 38 abstract = True 39 40 numThreads = Param.Unsigned(Parent.numThreads, "Number of threads") 41 BTBEntries = Param.Unsigned(4096, "Number of BTB entries") 42 BTBTagSize = Param.Unsigned(16, "Size of the BTB tags, in bits") 43 RASSize = Param.Unsigned(16, "RAS size") 44 instShiftAmt = Param.Unsigned(2, "Number of bits to shift instructions by") 45 46 useIndirect = Param.Bool(True, "Use indirect branch predictor") 47 indirectHashGHR = Param.Bool(True, "Hash branch predictor GHR") 48 indirectHashTargets = Param.Bool(True, "Hash path history targets") 49 indirectSets = Param.Unsigned(256, "Cache sets for indirect predictor") 50 indirectWays = Param.Unsigned(2, "Ways for indirect predictor") 51 indirectTagSize = Param.Unsigned(16, "Indirect target cache tag bits") 52 indirectPathLength = Param.Unsigned(3, 53 "Previous indirect targets to use for path history") 54 55 56 57class LocalBP(BranchPredictor): 58 type = 'LocalBP' 59 cxx_class = 'LocalBP' 60 cxx_header = "cpu/pred/2bit_local.hh" 61 62 localPredictorSize = Param.Unsigned(2048, "Size of local predictor") 63 localCtrBits = Param.Unsigned(2, "Bits per counter") 64 65 66class TournamentBP(BranchPredictor): 67 type = 'TournamentBP' 68 cxx_class = 'TournamentBP' 69 cxx_header = "cpu/pred/tournament.hh" 70 71 localPredictorSize = Param.Unsigned(2048, "Size of local predictor") 72 localCtrBits = Param.Unsigned(2, "Bits per counter") 73 localHistoryTableSize = Param.Unsigned(2048, "size of local history table") 74 globalPredictorSize = Param.Unsigned(8192, "Size of global predictor") 75 globalCtrBits = Param.Unsigned(2, "Bits per counter") 76 choicePredictorSize = Param.Unsigned(8192, "Size of choice predictor") 77 choiceCtrBits = Param.Unsigned(2, "Bits of choice counters") 78 79 80class BiModeBP(BranchPredictor): 81 type = 'BiModeBP' 82 cxx_class = 'BiModeBP' 83 cxx_header = "cpu/pred/bi_mode.hh" 84 85 globalPredictorSize = Param.Unsigned(8192, "Size of global predictor") 86 globalCtrBits = Param.Unsigned(2, "Bits per counter") 87 choicePredictorSize = Param.Unsigned(8192, "Size of choice predictor") 88 choiceCtrBits = Param.Unsigned(2, "Bits of choice counters") 89 90class LTAGE(BranchPredictor): 91 type = 'LTAGE' 92 cxx_class = 'LTAGE' 93 cxx_header = "cpu/pred/ltage.hh" 94 95 logSizeBiMP = Param.Unsigned(14, "Log size of Bimodal predictor in bits") 96 logRatioBiModalHystEntries = Param.Unsigned(2, 97 "Log num of prediction entries for a shared hysteresis bit " \ 98 "for the Bimodal") 99 logSizeTagTables = Param.Unsigned(11, "Log size of tag table in LTAGE") 100 logSizeLoopPred = Param.Unsigned(8, "Log size of the loop predictor") 101 nHistoryTables = Param.Unsigned(12, "Number of history tables") 102 tagTableCounterBits = Param.Unsigned(3, "Number of tag table counter bits") 103 histBufferSize = Param.Unsigned(2097152, 104 "A large number to track all branch histories(2MEntries default)") 105 minHist = Param.Unsigned(4, "Minimum history size of LTAGE") 106 maxHist = Param.Unsigned(640, "Maximum history size of LTAGE") 107 minTagWidth = Param.Unsigned(7, "Minimum tag size in tag tables") 108 109 loopTableAgeBits = Param.Unsigned(8, "Number of age bits per loop entry") 110 loopTableConfidenceBits = Param.Unsigned(2, 111 "Number of confidence bits per loop entry") 112 loopTableTagBits = Param.Unsigned(14, "Number of tag bits per loop entry") 113 loopTableIterBits = Param.Unsigned(14, "Nuber of iteration bits per loop") 114 115