gem5  v22.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 
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__
Basically a wrapper class to hold both the branch predictor and the BTB.
Definition: bpred_unit.hh:69
Implements a bi-mode branch predictor.
Definition: bi_mode.hh:61
void squash(ThreadID tid, void *bp_history)
Definition: bi_mode.cc:89
std::vector< unsigned > globalHistoryReg
Definition: bi_mode.hh:95
std::vector< SatCounter8 > notTakenCounters
Definition: bi_mode.hh:111
void updateGlobalHistReg(ThreadID tid, bool taken)
Definition: bi_mode.cc:228
void uncondBranch(ThreadID tid, Addr pc, void *&bp_history)
Definition: bi_mode.cc:76
std::vector< SatCounter8 > takenCounters
Definition: bi_mode.hh:109
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
std::vector< SatCounter8 > choiceCounters
Definition: bi_mode.hh:107
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
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
BiModeBP(const BiModeBPParams &params)
Definition: bi_mode.cc:44
const Params & params() const
Definition: sim_object.hh:176
Bitfield< 4 > pc
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:235
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147

Generated on Wed Dec 21 2022 10:22:31 for gem5 by doxygen 1.9.1