gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
2bit_local.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011, 2014 ARM Limited
3 * Copyright (c) 2022-2023 The University of Edinburgh
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder. You may use the software subject to the license
11 * terms below provided that you ensure that this notice is replicated
12 * unmodified and in its entirety in all distributions of the software,
13 * modified or unmodified, in source code or in binary form.
14 *
15 * Copyright (c) 2004-2006 The Regents of The University of Michigan
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met: redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer;
22 * redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution;
25 * neither the name of the copyright holders nor the names of its
26 * contributors may be used to endorse or promote products derived from
27 * this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 */
41
42#ifndef __CPU_PRED_2BIT_LOCAL_PRED_HH__
43#define __CPU_PRED_2BIT_LOCAL_PRED_HH__
44
45#include <vector>
46
47#include "base/sat_counter.hh"
48#include "base/types.hh"
50#include "params/LocalBP.hh"
51
52namespace gem5
53{
54
55namespace branch_prediction
56{
57
65class LocalBP : public BPredUnit
66{
67 public:
71 LocalBP(const LocalBPParams &params);
72
73 // Overriding interface functions
74 bool lookup(ThreadID tid, Addr pc, void * &bp_history) override;
75
76 void updateHistories(ThreadID tid, Addr pc, bool uncond, bool taken,
77 Addr target, const StaticInstPtr &inst,
78 void * &bp_history) override;
79
80 void update(ThreadID tid, Addr pc, bool taken,
81 void * &bp_history, bool squashed,
82 const StaticInstPtr & inst, Addr target) override;
83
84 void squash(ThreadID tid, void * &bp_history) override
85 { assert(bp_history == NULL); }
86
87 private:
94 inline bool getPrediction(uint8_t &count);
95
97 inline unsigned getLocalIndex(Addr &PC);
98
100 const unsigned localPredictorSize;
101
103 const unsigned localCtrBits;
104
106 const unsigned localPredictorSets;
107
110
112 const unsigned indexMask;
113};
114
115} // namespace branch_prediction
116} // namespace gem5
117
118#endif // __CPU_PRED_2BIT_LOCAL_PRED_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
BPredUnit(const Params &p)
Branch Predictor Unit (BPU) interface functions.
Definition bpred_unit.cc:58
const unsigned localPredictorSize
Size of the local predictor.
bool getPrediction(uint8_t &count)
Returns the taken/not taken prediction given the value of the counter.
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 2bit_local.cc:82
const unsigned localCtrBits
Number of bits of the local predictor's counters.
const unsigned localPredictorSets
Number of sets.
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.
LocalBP(const LocalBPParams &params)
Default branch predictor constructor.
Definition 2bit_local.cc:54
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 2bit_local.cc:91
const unsigned indexMask
Mask to get index bits.
std::vector< SatCounter8 > localCtrs
Array of counters that make up the local predictor.
unsigned getLocalIndex(Addr &PC)
Calculates the local index based on the PC.
void squash(ThreadID tid, void *&bp_history) override
Definition 2bit_local.hh:84
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