2bit_local.hh revision 1684
1#ifndef __CPU_BETA_CPU_2BIT_LOCAL_PRED_HH__
2#define __CPU_BETA_CPU_2BIT_LOCAL_PRED_HH__
3
4// For Addr type.
5#include "arch/alpha/isa_traits.hh"
6#include "cpu/beta_cpu/sat_counter.hh"
7
8class DefaultBP
9{
10  public:
11    /**
12     * Default branch predictor constructor.
13     */
14    DefaultBP(unsigned localPredictorSize, unsigned localCtrBits,
15              unsigned instShiftAmt);
16
17    /**
18     * Looks up the given address in the branch predictor and returns
19     * a true/false value as to whether it is taken.
20     * @param branch_addr The address of the branch to look up.
21     * @return Whether or not the branch is taken.
22     */
23    bool lookup(Addr &branch_addr);
24
25    /**
26     * Updates the branch predictor with the actual result of a branch.
27     * @param branch_addr The address of the branch to update.
28     * @param taken Whether or not the branch was taken.
29     */
30    void update(Addr &branch_addr, bool taken);
31
32  private:
33
34    /** Returns the taken/not taken prediction given the value of the
35     *  counter.
36     */
37    inline bool getPrediction(uint8_t &count);
38
39    /** Calculates the local index based on the PC. */
40    inline unsigned getLocalIndex(Addr &PC);
41
42    /** Array of counters that make up the local predictor. */
43    SatCounter *localCtrs;
44
45    /** Size of the local predictor. */
46    unsigned localPredictorSize;
47
48    /** Number of bits of the local predictor's counters. */
49    unsigned localCtrBits;
50
51    /** Number of bits to shift the PC when calculating index. */
52    unsigned instShiftAmt;
53
54    /** Mask to get index bits. */
55    unsigned indexMask;
56};
57
58#endif // __CPU_BETA_CPU_2BIT_LOCAL_PRED_HH__
59