bpred_unit.hh revision 1061
112953Sgabeblack@google.com
212953Sgabeblack@google.com#ifndef __BPRED_UNIT_HH__
312953Sgabeblack@google.com#define __BPRED_UNIT_HH__
412953Sgabeblack@google.com
512953Sgabeblack@google.com// For Addr type.
612953Sgabeblack@google.com#include "arch/alpha/isa_traits.hh"
712953Sgabeblack@google.com
812953Sgabeblack@google.com#include "cpu/beta_cpu/2bit_local_pred.hh"
912953Sgabeblack@google.com#include "cpu/beta_cpu/btb.hh"
1012953Sgabeblack@google.com
1112953Sgabeblack@google.com/**
1212953Sgabeblack@google.com * Basically a wrapper class to hold both the branch predictor
1312953Sgabeblack@google.com * and the BTB.  Right now I'm unsure of the implementation; it would
1412953Sgabeblack@google.com * be nicer to have something closer to the CPUPolicy or the Impl where
1512953Sgabeblack@google.com * this is just typedefs, but it forces the upper level stages to be
1612953Sgabeblack@google.com * aware of the constructors of the BP and the BTB.  The nicer thing
1712953Sgabeblack@google.com * to do is have this templated on the Impl, accept the usual Params
1812953Sgabeblack@google.com * object, and be able to call the constructors on the BP and BTB.
1912953Sgabeblack@google.com */
2012953Sgabeblack@google.comtemplate<class Impl>
2112953Sgabeblack@google.comclass DefaultBPredUnit
2212953Sgabeblack@google.com{
2312953Sgabeblack@google.com  public:
2412953Sgabeblack@google.com    typedef typename Impl::Params Params;
2512953Sgabeblack@google.com
2612953Sgabeblack@google.com    DefaultBPredUnit(Params &params);
2712953Sgabeblack@google.com
2812953Sgabeblack@google.com    bool BPLookup(Addr &inst_PC)
2912953Sgabeblack@google.com    { return BP.lookup(inst_PC); }
3012953Sgabeblack@google.com
3112953Sgabeblack@google.com    bool BTBValid(Addr &inst_PC)
3212953Sgabeblack@google.com    { return BTB.valid(inst_PC); }
3313063Sgabeblack@google.com
3413063Sgabeblack@google.com    Addr BTBLookup(Addr &inst_PC)
3513063Sgabeblack@google.com    { return BTB.lookup(inst_PC); }
3612957Sgabeblack@google.com
3712957Sgabeblack@google.com    void BPUpdate(Addr &inst_PC, bool taken)
3812961Sgabeblack@google.com    { BP.update(inst_PC, taken); }
3913063Sgabeblack@google.com
4012954Sgabeblack@google.com    void BTBUpdate(Addr &inst_PC, Addr &target_PC)
4112954Sgabeblack@google.com    { BTB.update(inst_PC, target_PC); }
4212953Sgabeblack@google.com
4312953Sgabeblack@google.com  private:
4413063Sgabeblack@google.com
4512953Sgabeblack@google.com    DefaultBP BP;
4612961Sgabeblack@google.com
4712961Sgabeblack@google.com    DefaultBTB BTB;
4812953Sgabeblack@google.com
4912953Sgabeblack@google.com};
5012953Sgabeblack@google.com
5112953Sgabeblack@google.com#endif // __BPRED_UNIT_HH__
5212954Sgabeblack@google.com