diff options
author | Andreas Sandberg <andreas@sandberg.pp.se> | 2014-02-09 20:49:28 +0100 |
---|---|---|
committer | Andreas Sandberg <andreas@sandberg.pp.se> | 2014-02-09 20:49:28 +0100 |
commit | c52190a695dc1928713e5bbda85cd17867c7e465 (patch) | |
tree | 8e9e03fdd3b1cf367f4fa9e28eaf8458947cfcf7 /src/cpu/simple/base.hh | |
parent | eb73a14fe29ff4940a206a9961e30c2376412951 (diff) | |
download | gem5-c52190a695dc1928713e5bbda85cd17867c7e465.tar.xz |
cpu: simple: Add support for using branch predictors
This changesets adds branch predictor support to the
BaseSimpleCPU. The simple CPUs normally don't need a branch predictor,
however, there are at least two cases where it can be desirable:
1) A simple CPU can be used to warm the branch predictor of an O3
CPU before switching to the slower O3 model.
2) The simple CPU can be used as a quick way of evaluating/debugging
new branch predictors since it exposes branch predictor
statistics.
Limitations:
* Since the simple CPU doesn't speculate, only one instruction will
be active in the branch predictor at a time (i.e., the branch
predictor will never see speculative branches).
* The outcome of a branch prediction does not affect the performance
of the simple CPU.
Diffstat (limited to 'src/cpu/simple/base.hh')
-rw-r--r-- | src/cpu/simple/base.hh | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/cpu/simple/base.hh b/src/cpu/simple/base.hh index 8134465af..ad672da6c 100644 --- a/src/cpu/simple/base.hh +++ b/src/cpu/simple/base.hh @@ -77,7 +77,7 @@ namespace Trace { } struct BaseSimpleCPUParams; - +class BPredUnit; class BaseSimpleCPU : public BaseCPU { @@ -87,6 +87,8 @@ class BaseSimpleCPU : public BaseCPU typedef TheISA::FloatRegBits FloatRegBits; typedef TheISA::CCReg CCReg; + BPredUnit *branchPred; + protected: Trace::InstRecord *traceData; @@ -272,6 +274,15 @@ class BaseSimpleCPU : public BaseCPU Stats::Scalar dcacheRetryCycles; Counter lastDcacheRetry; + /// @{ + /// Total number of branches fetched + Stats::Scalar numBranches; + /// Number of branches predicted as taken + Stats::Scalar numPredictedBranches; + /// Number of misprediced branches + Stats::Scalar numBranchMispred; + /// @} + void serializeThread(std::ostream &os, ThreadID tid); void unserializeThread(Checkpoint *cp, const std::string §ion, ThreadID tid); @@ -446,6 +457,9 @@ class BaseSimpleCPU : public BaseCPU bool misspeculating() { return thread->misspeculating(); } ThreadContext *tcBase() { return tc; } + + private: + TheISA::PCState pred_pc; }; #endif // __CPU_SIMPLE_BASE_HH__ |