gem5  v21.2.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 
40 namespace gem5
41 {
42 
43 namespace branch_prediction
44 {
45 
60 class BiModeBP : public BPredUnit
61 {
62  public:
63  BiModeBP(const BiModeBPParams &params);
64  void uncondBranch(ThreadID tid, Addr pc, void * &bp_history);
65  void squash(ThreadID tid, void *bp_history);
66  bool lookup(ThreadID tid, Addr branch_addr, void * &bp_history);
67  void btbUpdate(ThreadID tid, Addr branch_addr, void * &bp_history);
68  void update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history,
69  bool squashed, const StaticInstPtr & inst, Addr corrTarget);
70 
71  private:
72  void updateGlobalHistReg(ThreadID tid, bool taken);
73 
74  struct BPHistory
75  {
76  unsigned globalHistoryReg;
77  // was the taken array's prediction used?
78  // true: takenPred used
79  // false: notPred used
80  bool takenUsed;
81  // prediction of the taken array
82  // true: predict taken
83  // false: predict not-taken
84  bool takenPred;
85  // prediction of the not-taken array
86  // true: predict taken
87  // false: predict not-taken
89  // the final taken/not-taken prediction
90  // true: predict taken
91  // false: predict not-taken
92  bool finalPred;
93  };
94 
98 
100  unsigned choiceCtrBits;
103  unsigned globalCtrBits;
105 
106  // choice predictors
108  // taken direction predictors
110  // not-taken direction predictors
112 
113  unsigned choiceThreshold;
114  unsigned takenThreshold;
116 };
117 
118 } // namespace branch_prediction
119 } // namespace gem5
120 
121 #endif // __CPU_PRED_BI_MODE_PRED_HH__
gem5::branch_prediction::BiModeBP::BPHistory::notTakenPred
bool notTakenPred
Definition: bi_mode.hh:88
gem5::branch_prediction::BiModeBP::globalPredictorSize
unsigned globalPredictorSize
Definition: bi_mode.hh:102
gem5::branch_prediction::BiModeBP::globalHistoryBits
unsigned globalHistoryBits
Definition: bi_mode.hh:96
gem5::branch_prediction::BiModeBP::uncondBranch
void uncondBranch(ThreadID tid, Addr pc, void *&bp_history)
Definition: bi_mode.cc:76
gem5::branch_prediction::BiModeBP::choiceHistoryMask
unsigned choiceHistoryMask
Definition: bi_mode.hh:101
gem5::branch_prediction::BiModeBP
Implements a bi-mode branch predictor.
Definition: bi_mode.hh:60
std::vector< unsigned >
gem5::branch_prediction::BiModeBP::BPHistory::globalHistoryReg
unsigned globalHistoryReg
Definition: bi_mode.hh:76
gem5::branch_prediction::BiModeBP::choicePredictorSize
unsigned choicePredictorSize
Definition: bi_mode.hh:99
gem5::branch_prediction::BiModeBP::BPHistory::finalPred
bool finalPred
Definition: bi_mode.hh:92
sat_counter.hh
gem5::branch_prediction::BiModeBP::takenCounters
std::vector< SatCounter8 > takenCounters
Definition: bi_mode.hh:109
gem5::RefCountingPtr< StaticInst >
gem5::branch_prediction::BiModeBP::BiModeBP
BiModeBP(const BiModeBPParams &params)
Definition: bi_mode.cc:44
gem5::branch_prediction::BiModeBP::historyRegisterMask
unsigned historyRegisterMask
Definition: bi_mode.hh:97
gem5::branch_prediction::BiModeBP::BPHistory
Definition: bi_mode.hh:74
gem5::branch_prediction::BiModeBP::globalHistoryMask
unsigned globalHistoryMask
Definition: bi_mode.hh:104
gem5::SimObject::params
const Params & params() const
Definition: sim_object.hh:176
gem5::branch_prediction::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:146
gem5::branch_prediction::BiModeBP::BPHistory::takenUsed
bool takenUsed
Definition: bi_mode.hh:80
gem5::branch_prediction::BiModeBP::BPHistory::takenPred
bool takenPred
Definition: bi_mode.hh:84
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::branch_prediction::BiModeBP::notTakenCounters
std::vector< SatCounter8 > notTakenCounters
Definition: bi_mode.hh:111
gem5::branch_prediction::BiModeBP::choiceThreshold
unsigned choiceThreshold
Definition: bi_mode.hh:113
gem5::branch_prediction::BiModeBP::globalHistoryReg
std::vector< unsigned > globalHistoryReg
Definition: bi_mode.hh:95
bpred_unit.hh
gem5::branch_prediction::BiModeBP::globalCtrBits
unsigned globalCtrBits
Definition: bi_mode.hh:103
gem5::branch_prediction::BiModeBP::updateGlobalHistReg
void updateGlobalHistReg(ThreadID tid, bool taken)
Definition: bi_mode.cc:228
gem5::branch_prediction::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:107
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
gem5::branch_prediction::BPredUnit
Basically a wrapper class to hold both the branch predictor and the BTB.
Definition: bpred_unit.hh:68
gem5::branch_prediction::BiModeBP::notTakenThreshold
unsigned notTakenThreshold
Definition: bi_mode.hh:115
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: tlb.cc:60
gem5::branch_prediction::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:158
gem5::branch_prediction::BiModeBP::takenThreshold
unsigned takenThreshold
Definition: bi_mode.hh:114
gem5::branch_prediction::BiModeBP::choiceCtrBits
unsigned choiceCtrBits
Definition: bi_mode.hh:100
gem5::branch_prediction::BiModeBP::squash
void squash(ThreadID tid, void *bp_history)
Definition: bi_mode.cc:89
gem5::ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:242
gem5::branch_prediction::BiModeBP::choiceCounters
std::vector< SatCounter8 > choiceCounters
Definition: bi_mode.hh:107

Generated on Tue Dec 21 2021 11:34:26 for gem5 by doxygen 1.8.17