gem5 v24.0.0.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
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, void * &bp_history) override;
79 void squash(ThreadID tid, void * &bp_history) override;
80 void update(ThreadID tid, Addr pc, bool taken,
81 void * &bp_history, bool squashed,
82 const StaticInstPtr & inst, Addr target) override;
83
84 private:
85 void updateGlobalHistReg(ThreadID tid, bool taken);
86 void uncondBranch(ThreadID tid, Addr pc, void * &bp_history);
87
88 struct BPHistory
89 {
91 // was the taken array's prediction used?
92 // true: takenPred used
93 // false: notPred used
95 // prediction of the taken array
96 // true: predict taken
97 // false: predict not-taken
99 // prediction of the not-taken array
100 // true: predict taken
101 // false: predict not-taken
103 // the final taken/not-taken prediction
104 // true: predict taken
105 // false: predict not-taken
107 };
108
112
119
120 // choice predictors
122 // taken direction predictors
124 // not-taken direction predictors
126
130};
131
132} // namespace branch_prediction
133} // namespace gem5
134
135#endif // __CPU_PRED_BI_MODE_PRED_HH__
Basically a wrapper class to hold both the branch predictor and the BTB.
Definition bpred_unit.hh:71
Implements a bi-mode branch predictor.
Definition bi_mode.hh:73
void updateHistories(ThreadID tid, Addr pc, bool uncond, bool taken, Addr target, void *&bp_history) override
Ones done with the prediction this function updates the path and global history.
Definition bi_mode.cc:100
std::vector< unsigned > globalHistoryReg
Definition bi_mode.hh:109
std::vector< SatCounter8 > notTakenCounters
Definition bi_mode.hh:125
void updateGlobalHistReg(ThreadID tid, bool taken)
Definition bi_mode.cc:247
void uncondBranch(ThreadID tid, Addr pc, void *&bp_history)
Definition bi_mode.cc:88
void squash(ThreadID tid, void *&bp_history) override
Definition bi_mode.cc:112
std::vector< SatCounter8 > takenCounters
Definition bi_mode.hh:123
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:176
std::vector< SatCounter8 > choiceCounters
Definition bi_mode.hh:121
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:131
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 - Pranith Kumar Copyright (c) 2020 Inria 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

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0