summaryrefslogtreecommitdiff
path: root/cpu/beta_cpu/btb.hh
blob: 0ed1281370004440f4056f5ad40c211fc538d6d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef __CPU_BETA_CPU_BTB_HH__
#define __CPU_BETA_CPU_BTB_HH__

// For Addr type.
#include "arch/alpha/isa_traits.hh"

class DefaultBTB
{
  private:
    struct BTBEntry
    {
        BTBEntry()
            : tag(0), target(0), valid(false)
        {
        }

        Addr tag;
        Addr target;
        bool valid;
    };

  public:
    DefaultBTB(unsigned numEntries, unsigned tagBits,
               unsigned instShiftAmt);

    Addr lookup(const Addr &inst_PC);

    bool valid(const Addr &inst_PC);

    void update(const Addr &inst_PC, const Addr &target_PC);

  private:
    inline unsigned getIndex(const Addr &inst_PC);

    inline Addr getTag(const Addr &inst_PC);

    BTBEntry *btb;

    unsigned numEntries;

    unsigned idxMask;

    unsigned tagBits;

    unsigned tagMask;

    unsigned instShiftAmt;

    unsigned tagShiftAmt;
};

#endif // __CPU_BETA_CPU_BTB_HH__