1/*
2 * Copyright (c) 2011, 2014 ARM Limited
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

--- 36 unchanged lines hidden (view full) ---

45#ifndef __CPU_PRED_TOURNAMENT_PRED_HH__
46#define __CPU_PRED_TOURNAMENT_PRED_HH__
47
48#include <vector>
49
50#include "base/types.hh"
51#include "cpu/pred/bpred_unit.hh"
52#include "cpu/pred/sat_counter.hh"
53#include "params/TournamentBP.hh"
54
55/**
56 * Implements a tournament branch predictor, hopefully identical to the one
57 * used in the 21264. It has a local predictor, which uses a local history
58 * table to index into a table of counters, and a global predictor, which
59 * uses a global history to index into a table of counters. A choice
60 * predictor chooses between the two. Only the global history register
61 * is speculatively updated, the rest are updated upon branches committing
62 * or misspeculating.
63 */
64class TournamentBP : public BPredUnit
65{
66 public:
67 /**
68 * Default branch predictor constructor.
69 */
69 TournamentBP(const Params *params);
70 TournamentBP(const TournamentBPParams *params);
71
72 /**
73 * Looks up the given address in the branch predictor and returns
74 * a true/false value as to whether it is taken. Also creates a
75 * BPHistory object to store any state it will need on squash/update.
76 * @param branch_addr The address of the branch to look up.
77 * @param bp_history Pointer that will be set to the BPHistory object.
78 * @return Whether or not the branch is taken.
79 */
80 bool lookup(Addr branch_addr, void * &bp_history);
81
82 /**
83 * Records that there was an unconditional branch, and modifies
84 * the bp history to point to an object that has the previous
85 * global history stored in it.
86 * @param bp_history Pointer that will be set to the BPHistory object.
87 */
87 void uncondBranch(void * &bp_history);
88 void uncondBranch(Addr pc, void * &bp_history);
89 /**
90 * Updates the branch predictor to Not Taken if a BTB entry is
91 * invalid or not found.
92 * @param branch_addr The address of the branch to look up.
93 * @param bp_history Pointer to any bp history state.
94 * @return Whether or not the branch is taken.
95 */
96 void btbUpdate(Addr branch_addr, void * &bp_history);

--- 133 unchanged lines hidden (view full) ---

230 std::vector<SatCounter> choiceCtrs;
231
232 /** Number of entries in the choice predictor. */
233 unsigned choicePredictorSize;
234
235 /** Number of bits in the choice predictor's counters. */
236 unsigned choiceCtrBits;
237
237 /** Number of bits to shift the instruction over to get rid of the word
238 * offset.
239 */
240 unsigned instShiftAmt;
241
238 /** Thresholds for the counter value; above the threshold is taken,
239 * equal to or below the threshold is not taken.
240 */
241 unsigned localThreshold;
242 unsigned globalThreshold;
243 unsigned choiceThreshold;
244};
245
246#endif // __CPU_PRED_TOURNAMENT_PRED_HH__