cpu: re-organizes the branch predictor structure.
[gem5.git] / src / cpu / pred / BranchPredictor.py
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
30 from m5.SimObject import SimObject
31 from m5.params import *
32
33 class 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
46 class LocalBP(BranchPredictor):
47 type = 'LocalBP'
48 cxx_class = 'LocalBP'
49 cxx_header = "cpu/pred/2bit_local.hh"
50
51 localPredictorSize = Param.Unsigned(2048, "Size of local predictor")
52 localCtrBits = Param.Unsigned(2, "Bits per counter")
53
54
55 class TournamentBP(BranchPredictor):
56 type = 'TournamentBP'
57 cxx_class = 'TournamentBP'
58 cxx_header = "cpu/pred/tournament.hh"
59
60 localPredictorSize = Param.Unsigned(2048, "Size of local predictor")
61 localCtrBits = Param.Unsigned(2, "Bits per counter")
62 localHistoryTableSize = Param.Unsigned(2048, "size of local history table")
63 globalPredictorSize = Param.Unsigned(8192, "Size of global predictor")
64 globalCtrBits = Param.Unsigned(2, "Bits per counter")
65 choicePredictorSize = Param.Unsigned(8192, "Size of choice predictor")
66 choiceCtrBits = Param.Unsigned(2, "Bits of choice counters")
67
68
69 class BiModeBP(BranchPredictor):
70 type = 'BiModeBP'
71 cxx_class = 'BiModeBP'
72 cxx_header = "cpu/pred/bi_mode.hh"
73
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