gem5 v24.0.0.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, void * &bp_history) override;
78
79 void update(ThreadID tid, Addr pc, bool taken,
80 void * &bp_history, bool squashed,
81 const StaticInstPtr & inst, Addr target) override;
82
83 void squash(ThreadID tid, void * &bp_history) override
84 { assert(bp_history == NULL); }
85
86 private:
93 inline bool getPrediction(uint8_t &count);
94
96 inline unsigned getLocalIndex(Addr &PC);
97
99 const unsigned localPredictorSize;
100
102 const unsigned localCtrBits;
103
105 const unsigned localPredictorSets;
106
109
111 const unsigned indexMask;
112};
113
114} // namespace branch_prediction
115} // namespace gem5
116
117#endif // __CPU_PRED_2BIT_LOCAL_PRED_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Basically a wrapper class to hold both the branch predictor and the BTB.
Definition bpred_unit.hh:71
Implements a local predictor that uses the PC to index into a table of counters.
Definition 2bit_local.hh:66
const unsigned localPredictorSize
Size of the local predictor.
Definition 2bit_local.hh:99
bool getPrediction(uint8_t &count)
Returns the taken/not taken prediction given the value of the counter.
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
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 2bit_local.cc:82
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:90
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:83
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