gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bi_mode.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 The Regents of The University of Michigan
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: Anthony Gutierrez
29  */
30 
31 /* @file
32  * Implementation of a bi-mode branch predictor
33  */
34 
35 #ifndef __CPU_PRED_BI_MODE_PRED_HH__
36 #define __CPU_PRED_BI_MODE_PRED_HH__
37 
38 #include "cpu/pred/bpred_unit.hh"
39 #include "cpu/pred/sat_counter.hh"
40 #include "params/BiModeBP.hh"
41 
56 class BiModeBP : public BPredUnit
57 {
58  public:
59  BiModeBP(const BiModeBPParams *params);
60  void uncondBranch(ThreadID tid, Addr pc, void * &bp_history);
61  void squash(ThreadID tid, void *bp_history);
62  bool lookup(ThreadID tid, Addr branch_addr, void * &bp_history);
63  void btbUpdate(ThreadID tid, Addr branch_addr, void * &bp_history);
64  void update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history,
65  bool squashed);
66  unsigned getGHR(ThreadID tid, void *bp_history) const;
67 
68  private:
69  void updateGlobalHistReg(ThreadID tid, bool taken);
70 
71  struct BPHistory {
72  unsigned globalHistoryReg;
73  // was the taken array's prediction used?
74  // true: takenPred used
75  // false: notPred used
76  bool takenUsed;
77  // prediction of the taken array
78  // true: predict taken
79  // false: predict not-taken
80  bool takenPred;
81  // prediction of the not-taken array
82  // true: predict taken
83  // false: predict not-taken
85  // the final taken/not-taken prediction
86  // true: predict taken
87  // false: predict not-taken
88  bool finalPred;
89  };
90 
91  // choice predictors
93  // taken direction predictors
95  // not-taken direction predictors
97 
101 
103  unsigned choiceCtrBits;
106  unsigned globalCtrBits;
108 
109  unsigned choiceThreshold;
110  unsigned takenThreshold;
112 };
113 
114 #endif // __CPU_PRED_BI_MODE_PRED_HH__
unsigned globalHistoryBits
Definition: bi_mode.hh:99
void squash(ThreadID tid, void *bp_history)
Definition: bi_mode.cc:94
void btbUpdate(ThreadID tid, Addr branch_addr, void *&bp_history)
If a branch is not taken, because the BTB address is invalid or missing, this function sets the appro...
Definition: bi_mode.cc:151
unsigned choiceCtrBits
Definition: bi_mode.hh:103
bool lookup(ThreadID tid, Addr branch_addr, void *&bp_history)
Looks up a given PC in the BP to see if it is taken or not taken.
Definition: bi_mode.cc:112
void updateGlobalHistReg(ThreadID tid, bool taken)
Definition: bi_mode.cc:239
std::vector< SatCounter > choiceCounters
Definition: bi_mode.hh:92
unsigned globalPredictorSize
Definition: bi_mode.hh:105
std::vector< unsigned > globalHistoryReg
Definition: bi_mode.hh:98
const Params * params() const
Definition: sim_object.hh:111
unsigned globalCtrBits
Definition: bi_mode.hh:106
unsigned choiceThreshold
Definition: bi_mode.hh:109
unsigned globalHistoryReg
Definition: bi_mode.hh:72
unsigned choiceHistoryMask
Definition: bi_mode.hh:104
unsigned historyRegisterMask
Definition: bi_mode.hh:100
unsigned choicePredictorSize
Definition: bi_mode.hh:102
std::vector< SatCounter > notTakenCounters
Definition: bi_mode.hh:96
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Basically a wrapper class to hold both the branch predictor and the BTB.
Definition: bpred_unit.hh:67
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:171
unsigned takenThreshold
Definition: bi_mode.hh:110
unsigned getGHR(ThreadID tid, void *bp_history) const
Definition: bi_mode.cc:233
std::vector< SatCounter > takenCounters
Definition: bi_mode.hh:94
unsigned globalHistoryMask
Definition: bi_mode.hh:107
void update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history, bool squashed)
Updates the BP with taken/not taken information.
Definition: bi_mode.cc:163
IntReg pc
Definition: remote_gdb.hh:91
BiModeBP(const BiModeBPParams *params)
Definition: bi_mode.cc:40
Implements a bi-mode branch predictor.
Definition: bi_mode.hh:56
void uncondBranch(ThreadID tid, Addr pc, void *&bp_history)
Definition: bi_mode.cc:81
unsigned notTakenThreshold
Definition: bi_mode.hh:111

Generated on Fri Jun 9 2017 13:03:44 for gem5 by doxygen 1.8.6