bpred_unit.hh revision 1061
1
2#ifndef __BPRED_UNIT_HH__
3#define __BPRED_UNIT_HH__
4
5// For Addr type.
6#include "arch/alpha/isa_traits.hh"
7
8#include "cpu/beta_cpu/2bit_local_pred.hh"
9#include "cpu/beta_cpu/btb.hh"
10
11/**
12 * Basically a wrapper class to hold both the branch predictor
13 * and the BTB.  Right now I'm unsure of the implementation; it would
14 * be nicer to have something closer to the CPUPolicy or the Impl where
15 * this is just typedefs, but it forces the upper level stages to be
16 * aware of the constructors of the BP and the BTB.  The nicer thing
17 * to do is have this templated on the Impl, accept the usual Params
18 * object, and be able to call the constructors on the BP and BTB.
19 */
20template<class Impl>
21class DefaultBPredUnit
22{
23  public:
24    typedef typename Impl::Params Params;
25
26    DefaultBPredUnit(Params &params);
27
28    bool BPLookup(Addr &inst_PC)
29    { return BP.lookup(inst_PC); }
30
31    bool BTBValid(Addr &inst_PC)
32    { return BTB.valid(inst_PC); }
33
34    Addr BTBLookup(Addr &inst_PC)
35    { return BTB.lookup(inst_PC); }
36
37    void BPUpdate(Addr &inst_PC, bool taken)
38    { BP.update(inst_PC, taken); }
39
40    void BTBUpdate(Addr &inst_PC, Addr &target_PC)
41    { BTB.update(inst_PC, target_PC); }
42
43  private:
44
45    DefaultBP BP;
46
47    DefaultBTB BTB;
48
49};
50
51#endif // __BPRED_UNIT_HH__
52