BranchPredictor.py revision 11433:72b075cdc336
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 * 32 33class BranchPredictor(SimObject): 34 type = 'BranchPredictor' 35 cxx_class = 'BPredUnit' 36 cxx_header = "cpu/pred/bpred_unit.hh" 37 abstract = True 38 39 numThreads = Param.Unsigned(1, "Number of threads") 40 BTBEntries = Param.Unsigned(4096, "Number of BTB entries") 41 BTBTagSize = Param.Unsigned(16, "Size of the BTB tags, in bits") 42 RASSize = Param.Unsigned(16, "RAS size") 43 instShiftAmt = Param.Unsigned(2, "Number of bits to shift instructions by") 44 45 useIndirect = Param.Bool(True, "Use indirect branch predictor") 46 indirectHashGHR = Param.Bool(True, "Hash branch predictor GHR") 47 indirectHashTargets = Param.Bool(True, "Hash path history targets") 48 indirectSets = Param.Unsigned(256, "Cache sets for indirect predictor") 49 indirectWays = Param.Unsigned(2, "Ways for indirect predictor") 50 indirectTagSize = Param.Unsigned(16, "Indirect target cache tag bits") 51 indirectPathLength = Param.Unsigned(3, 52 "Previous indirect targets to use for path history") 53 54 55 56class LocalBP(BranchPredictor): 57 type = 'LocalBP' 58 cxx_class = 'LocalBP' 59 cxx_header = "cpu/pred/2bit_local.hh" 60 61 localPredictorSize = Param.Unsigned(2048, "Size of local predictor") 62 localCtrBits = Param.Unsigned(2, "Bits per counter") 63 64 65class TournamentBP(BranchPredictor): 66 type = 'TournamentBP' 67 cxx_class = 'TournamentBP' 68 cxx_header = "cpu/pred/tournament.hh" 69 70 localPredictorSize = Param.Unsigned(2048, "Size of local predictor") 71 localCtrBits = Param.Unsigned(2, "Bits per counter") 72 localHistoryTableSize = Param.Unsigned(2048, "size of local history table") 73 globalPredictorSize = Param.Unsigned(8192, "Size of global predictor") 74 globalCtrBits = Param.Unsigned(2, "Bits per counter") 75 choicePredictorSize = Param.Unsigned(8192, "Size of choice predictor") 76 choiceCtrBits = Param.Unsigned(2, "Bits of choice counters") 77 78 79class BiModeBP(BranchPredictor): 80 type = 'BiModeBP' 81 cxx_class = 'BiModeBP' 82 cxx_header = "cpu/pred/bi_mode.hh" 83 84 globalPredictorSize = Param.Unsigned(8192, "Size of global predictor") 85 globalCtrBits = Param.Unsigned(2, "Bits per counter") 86 choicePredictorSize = Param.Unsigned(8192, "Size of choice predictor") 87 choiceCtrBits = Param.Unsigned(2, "Bits of choice counters") 88 89