gem5  v20.1.0.0
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 
29 /* @file
30  * Implementation of a bi-mode branch predictor
31  */
32 
33 #ifndef __CPU_PRED_BI_MODE_PRED_HH__
34 #define __CPU_PRED_BI_MODE_PRED_HH__
35 
36 #include "base/sat_counter.hh"
37 #include "cpu/pred/bpred_unit.hh"
38 #include "params/BiModeBP.hh"
39 
54 class BiModeBP : public BPredUnit
55 {
56  public:
57  BiModeBP(const BiModeBPParams *params);
58  void uncondBranch(ThreadID tid, Addr pc, void * &bp_history);
59  void squash(ThreadID tid, void *bp_history);
60  bool lookup(ThreadID tid, Addr branch_addr, void * &bp_history);
61  void btbUpdate(ThreadID tid, Addr branch_addr, void * &bp_history);
62  void update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history,
63  bool squashed, const StaticInstPtr & inst, Addr corrTarget);
64 
65  private:
66  void updateGlobalHistReg(ThreadID tid, bool taken);
67 
68  struct BPHistory {
69  unsigned globalHistoryReg;
70  // was the taken array's prediction used?
71  // true: takenPred used
72  // false: notPred used
73  bool takenUsed;
74  // prediction of the taken array
75  // true: predict taken
76  // false: predict not-taken
77  bool takenPred;
78  // prediction of the not-taken array
79  // true: predict taken
80  // false: predict not-taken
82  // the final taken/not-taken prediction
83  // true: predict taken
84  // false: predict not-taken
85  bool finalPred;
86  };
87 
91 
93  unsigned choiceCtrBits;
96  unsigned globalCtrBits;
98 
99  // choice predictors
101  // taken direction predictors
103  // not-taken direction predictors
105 
106  unsigned choiceThreshold;
107  unsigned takenThreshold;
109 };
110 
111 #endif // __CPU_PRED_BI_MODE_PRED_HH__
BiModeBP::choiceCtrBits
unsigned choiceCtrBits
Definition: bi_mode.hh:93
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
BiModeBP::globalHistoryBits
unsigned globalHistoryBits
Definition: bi_mode.hh:89
BiModeBP::choiceCounters
std::vector< SatCounter > choiceCounters
Definition: bi_mode.hh:100
BiModeBP::BPHistory::takenPred
bool takenPred
Definition: bi_mode.hh:77
BiModeBP::lookup
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:101
BiModeBP::globalPredictorSize
unsigned globalPredictorSize
Definition: bi_mode.hh:95
BiModeBP::globalHistoryReg
std::vector< unsigned > globalHistoryReg
Definition: bi_mode.hh:88
BiModeBP::BPHistory::globalHistoryReg
unsigned globalHistoryReg
Definition: bi_mode.hh:69
std::vector< unsigned >
BiModeBP::globalCtrBits
unsigned globalCtrBits
Definition: bi_mode.hh:96
BiModeBP::updateGlobalHistReg
void updateGlobalHistReg(ThreadID tid, bool taken)
Definition: bi_mode.cc:222
BiModeBP::BPHistory::takenUsed
bool takenUsed
Definition: bi_mode.hh:73
BiModeBP::BPHistory::finalPred
bool finalPred
Definition: bi_mode.hh:85
sat_counter.hh
BiModeBP
Implements a bi-mode branch predictor.
Definition: bi_mode.hh:54
BiModeBP::choiceThreshold
unsigned choiceThreshold
Definition: bi_mode.hh:106
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
BiModeBP::choiceHistoryMask
unsigned choiceHistoryMask
Definition: bi_mode.hh:94
BPredUnit
Basically a wrapper class to hold both the branch predictor and the BTB.
Definition: bpred_unit.hh:62
BiModeBP::BPHistory
Definition: bi_mode.hh:68
BiModeBP::takenThreshold
unsigned takenThreshold
Definition: bi_mode.hh:107
BiModeBP::historyRegisterMask
unsigned historyRegisterMask
Definition: bi_mode.hh:90
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
BiModeBP::takenCounters
std::vector< SatCounter > takenCounters
Definition: bi_mode.hh:102
SimObject::params
const Params * params() const
Definition: sim_object.hh:119
BiModeBP::BPHistory::notTakenPred
bool notTakenPred
Definition: bi_mode.hh:81
bpred_unit.hh
BiModeBP::choicePredictorSize
unsigned choicePredictorSize
Definition: bi_mode.hh:92
BiModeBP::update
void update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history, bool squashed, const StaticInstPtr &inst, Addr corrTarget)
Updates the BP with taken/not taken information.
Definition: bi_mode.cc:152
BiModeBP::globalHistoryMask
unsigned globalHistoryMask
Definition: bi_mode.hh:97
BiModeBP::notTakenCounters
std::vector< SatCounter > notTakenCounters
Definition: bi_mode.hh:104
BiModeBP::squash
void squash(ThreadID tid, void *bp_history)
Definition: bi_mode.cc:83
BiModeBP::notTakenThreshold
unsigned notTakenThreshold
Definition: bi_mode.hh:108
RefCountingPtr< StaticInst >
BiModeBP::uncondBranch
void uncondBranch(ThreadID tid, Addr pc, void *&bp_history)
Definition: bi_mode.cc:70
BiModeBP::btbUpdate
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:140
BiModeBP::BiModeBP
BiModeBP(const BiModeBPParams *params)
Definition: bi_mode.cc:38

Generated on Wed Sep 30 2020 14:02:09 for gem5 by doxygen 1.8.17