gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
bi_mode.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022-2023 The University of Edinburgh
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2014 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
41/* @file
42 * Implementation of a bi-mode branch predictor
43 */
44
45#ifndef __CPU_PRED_BI_MODE_PRED_HH__
46#define __CPU_PRED_BI_MODE_PRED_HH__
47
48#include "base/sat_counter.hh"
50#include "params/BiModeBP.hh"
51
52namespace gem5
53{
54
55namespace branch_prediction
56{
57
71
72class BiModeBP : public BPredUnit
73{
74 public:
75 BiModeBP(const BiModeBPParams &params);
76 bool lookup(ThreadID tid, Addr pc, void * &bp_history) override;
77 void updateHistories(ThreadID tid, Addr pc, bool uncond, bool taken,
78 Addr target, const StaticInstPtr &inst,
79 void * &bp_history) override;
80 void squash(ThreadID tid, void * &bp_history) override;
81 void update(ThreadID tid, Addr pc, bool taken,
82 void * &bp_history, bool squashed,
83 const StaticInstPtr & inst, Addr target) override;
84
85 private:
86 void updateGlobalHistReg(ThreadID tid, bool taken);
87 void uncondBranch(ThreadID tid, Addr pc, void * &bp_history);
88
89 struct BPHistory
90 {
92 // was the taken array's prediction used?
93 // true: takenPred used
94 // false: notPred used
96 // prediction of the taken array
97 // true: predict taken
98 // false: predict not-taken
100 // prediction of the not-taken array
101 // true: predict taken
102 // false: predict not-taken
104 // the final taken/not-taken prediction
105 // true: predict taken
106 // false: predict not-taken
108 };
109
113
120
121 // choice predictors
123 // taken direction predictors
125 // not-taken direction predictors
127
131};
132
133} // namespace branch_prediction
134} // namespace gem5
135
136#endif // __CPU_PRED_BI_MODE_PRED_HH__
BPredUnit(const Params &p)
Branch Predictor Unit (BPU) interface functions.
Definition bpred_unit.cc:58
std::vector< unsigned > globalHistoryReg
Definition bi_mode.hh:110
std::vector< SatCounter8 > notTakenCounters
Definition bi_mode.hh:126
void updateGlobalHistReg(ThreadID tid, bool taken)
Definition bi_mode.cc:248
void uncondBranch(ThreadID tid, Addr pc, void *&bp_history)
Definition bi_mode.cc:88
void updateHistories(ThreadID tid, Addr pc, bool uncond, bool taken, Addr target, const StaticInstPtr &inst, void *&bp_history) override
Ones done with the prediction this function updates the path and global history.
Definition bi_mode.cc:100
void squash(ThreadID tid, void *&bp_history) override
Definition bi_mode.cc:113
std::vector< SatCounter8 > takenCounters
Definition bi_mode.hh:124
void update(ThreadID tid, Addr pc, bool taken, void *&bp_history, bool squashed, const StaticInstPtr &inst, Addr target) override
Updates the BP with taken/not taken information.
Definition bi_mode.cc:177
std::vector< SatCounter8 > choiceCounters
Definition bi_mode.hh:122
bool lookup(ThreadID tid, Addr pc, void *&bp_history) override
Looks up a given conditional branch PC of in the BP to see if it is taken or not taken.
Definition bi_mode.cc:132
BiModeBP(const BiModeBPParams &params)
Definition bi_mode.cc:56
STL vector class.
Definition stl.hh:37
const Params & params() const
Bitfield< 4 > pc
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
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
RefCountingPtr< StaticInst > StaticInstPtr

Generated on Mon May 26 2025 09:19:08 for gem5 by doxygen 1.13.2