1/*
2 * Copyright 2019 Texas A&M University
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice,
8 *    this list of conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 *    this list of conditions and the following disclaimer in the documentation
12 *    and/or other materials provided with the distribution.
13 *
14 * 3. Neither the name of the copyright holder nor the names of its
15 *    contributors may be used to endorse or promote products derived from this
16 *    software without specific prior written permission.
17 *
18 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 *  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 *  Author: Daniel A. Jiménez
31 *  Adapted to gem5 by: Javier Bueno Hedo
32 *
33 */
34
35/*
36 * Multiperspective Perceptron Predictor with TAGE (by Daniel A. Jiménez)
37 * 64 KB version
38 */
39#ifndef __CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_TAGE_64KB_HH__
40#define __CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_TAGE_64KB_HH__
41
42#include "cpu/pred/multiperspective_perceptron_tage.hh"
43#include "params/MPP_StatisticalCorrector_64KB.hh"
44#include "params/MultiperspectivePerceptronTAGE64KB.hh"
45
46class MPP_StatisticalCorrector_64KB : public MPP_StatisticalCorrector {
47    const unsigned numEntriesSecondLocalHistories;
48    const unsigned numEntriesThirdLocalHistories;
49
50    // Second local history GEHL
51    const unsigned snb;
52    const unsigned logSnb;
53    std::vector<int> sm;
54    std::vector<int8_t> * sgehl;
55    std::vector<int8_t> ws;
56
57    // Third local history GEHL
58    const unsigned tnb;
59    const unsigned logTnb;
60    std::vector<int> tm;
61    std::vector<int8_t> * tgehl;
62    std::vector<int8_t> wt;
63
64    StatisticalCorrector::SCThreadHistory *makeThreadHistory() override;
65    int gPredictions(ThreadID tid, Addr branch_pc,
66            StatisticalCorrector::BranchInfo* bi, int &lsum, int64_t phist)
67            override;
68    void getBiasLSUM(Addr branch_pc,
69            StatisticalCorrector::BranchInfo *bi, int &lsum) const override;
70    void gUpdates(ThreadID tid, Addr pc, bool taken,
71            StatisticalCorrector::BranchInfo* bi, int64_t phist) override;
72    void scHistoryUpdate(Addr branch_pc, const StaticInstPtr &inst, bool taken,
73            StatisticalCorrector::BranchInfo *bi, Addr corrTarget) override;
74  public:
75    MPP_StatisticalCorrector_64KB(
76            const MPP_StatisticalCorrector_64KBParams *p);
77    size_t getSizeInBits() const override;
78};
79
80class MultiperspectivePerceptronTAGE64KB :
81        public MultiperspectivePerceptronTAGE {
82    void createSpecs() override;
83  public:
84    MultiperspectivePerceptronTAGE64KB(
85            const MultiperspectivePerceptronTAGE64KBParams *p);
86};
87
88#endif // __CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_TAGE_64KB_HH__
89