114081Sjavier.bueno@metempsy.com/*
214081Sjavier.bueno@metempsy.com * Copyright 2019 Texas A&M University
314081Sjavier.bueno@metempsy.com *
414081Sjavier.bueno@metempsy.com * Redistribution and use in source and binary forms, with or without
514081Sjavier.bueno@metempsy.com * modification, are permitted provided that the following conditions are met:
614081Sjavier.bueno@metempsy.com *
714081Sjavier.bueno@metempsy.com * 1. Redistributions of source code must retain the above copyright notice,
814081Sjavier.bueno@metempsy.com *    this list of conditions and the following disclaimer.
914081Sjavier.bueno@metempsy.com *
1014081Sjavier.bueno@metempsy.com * 2. Redistributions in binary form must reproduce the above copyright notice,
1114081Sjavier.bueno@metempsy.com *    this list of conditions and the following disclaimer in the documentation
1214081Sjavier.bueno@metempsy.com *    and/or other materials provided with the distribution.
1314081Sjavier.bueno@metempsy.com *
1414081Sjavier.bueno@metempsy.com * 3. Neither the name of the copyright holder nor the names of its
1514081Sjavier.bueno@metempsy.com *    contributors may be used to endorse or promote products derived from this
1614081Sjavier.bueno@metempsy.com *    software without specific prior written permission.
1714081Sjavier.bueno@metempsy.com *
1814081Sjavier.bueno@metempsy.com *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1914081Sjavier.bueno@metempsy.com *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2014081Sjavier.bueno@metempsy.com *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2114081Sjavier.bueno@metempsy.com *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2214081Sjavier.bueno@metempsy.com *  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2314081Sjavier.bueno@metempsy.com *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2414081Sjavier.bueno@metempsy.com *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2514081Sjavier.bueno@metempsy.com *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2614081Sjavier.bueno@metempsy.com *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2714081Sjavier.bueno@metempsy.com *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2814081Sjavier.bueno@metempsy.com *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2914081Sjavier.bueno@metempsy.com *
3014081Sjavier.bueno@metempsy.com *  Author: Daniel A. Jiménez
3114081Sjavier.bueno@metempsy.com *  Adapted to gem5 by: Javier Bueno Hedo
3214081Sjavier.bueno@metempsy.com *
3314081Sjavier.bueno@metempsy.com */
3414081Sjavier.bueno@metempsy.com
3514081Sjavier.bueno@metempsy.com/*
3614081Sjavier.bueno@metempsy.com * Multiperspective Perceptron Predictor with TAGE (by Daniel A. Jiménez)
3714081Sjavier.bueno@metempsy.com * 64 KB version
3814081Sjavier.bueno@metempsy.com */
3914081Sjavier.bueno@metempsy.com#ifndef __CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_TAGE_64KB_HH__
4014081Sjavier.bueno@metempsy.com#define __CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_TAGE_64KB_HH__
4114081Sjavier.bueno@metempsy.com
4214081Sjavier.bueno@metempsy.com#include "cpu/pred/multiperspective_perceptron_tage.hh"
4314081Sjavier.bueno@metempsy.com#include "params/MPP_StatisticalCorrector_64KB.hh"
4414081Sjavier.bueno@metempsy.com#include "params/MultiperspectivePerceptronTAGE64KB.hh"
4514081Sjavier.bueno@metempsy.com
4614081Sjavier.bueno@metempsy.comclass MPP_StatisticalCorrector_64KB : public MPP_StatisticalCorrector {
4714081Sjavier.bueno@metempsy.com    const unsigned numEntriesSecondLocalHistories;
4814081Sjavier.bueno@metempsy.com    const unsigned numEntriesThirdLocalHistories;
4914081Sjavier.bueno@metempsy.com
5014081Sjavier.bueno@metempsy.com    // Second local history GEHL
5114081Sjavier.bueno@metempsy.com    const unsigned snb;
5214081Sjavier.bueno@metempsy.com    const unsigned logSnb;
5314081Sjavier.bueno@metempsy.com    std::vector<int> sm;
5414081Sjavier.bueno@metempsy.com    std::vector<int8_t> * sgehl;
5514081Sjavier.bueno@metempsy.com    std::vector<int8_t> ws;
5614081Sjavier.bueno@metempsy.com
5714081Sjavier.bueno@metempsy.com    // Third local history GEHL
5814081Sjavier.bueno@metempsy.com    const unsigned tnb;
5914081Sjavier.bueno@metempsy.com    const unsigned logTnb;
6014081Sjavier.bueno@metempsy.com    std::vector<int> tm;
6114081Sjavier.bueno@metempsy.com    std::vector<int8_t> * tgehl;
6214081Sjavier.bueno@metempsy.com    std::vector<int8_t> wt;
6314081Sjavier.bueno@metempsy.com
6414081Sjavier.bueno@metempsy.com    StatisticalCorrector::SCThreadHistory *makeThreadHistory() override;
6514081Sjavier.bueno@metempsy.com    int gPredictions(ThreadID tid, Addr branch_pc,
6614081Sjavier.bueno@metempsy.com            StatisticalCorrector::BranchInfo* bi, int &lsum, int64_t phist)
6714081Sjavier.bueno@metempsy.com            override;
6814081Sjavier.bueno@metempsy.com    void getBiasLSUM(Addr branch_pc,
6914081Sjavier.bueno@metempsy.com            StatisticalCorrector::BranchInfo *bi, int &lsum) const override;
7014081Sjavier.bueno@metempsy.com    void gUpdates(ThreadID tid, Addr pc, bool taken,
7114081Sjavier.bueno@metempsy.com            StatisticalCorrector::BranchInfo* bi, int64_t phist) override;
7214081Sjavier.bueno@metempsy.com    void scHistoryUpdate(Addr branch_pc, const StaticInstPtr &inst, bool taken,
7314081Sjavier.bueno@metempsy.com            StatisticalCorrector::BranchInfo *bi, Addr corrTarget) override;
7414081Sjavier.bueno@metempsy.com  public:
7514081Sjavier.bueno@metempsy.com    MPP_StatisticalCorrector_64KB(
7614081Sjavier.bueno@metempsy.com            const MPP_StatisticalCorrector_64KBParams *p);
7714081Sjavier.bueno@metempsy.com    size_t getSizeInBits() const override;
7814081Sjavier.bueno@metempsy.com};
7914081Sjavier.bueno@metempsy.com
8014081Sjavier.bueno@metempsy.comclass MultiperspectivePerceptronTAGE64KB :
8114081Sjavier.bueno@metempsy.com        public MultiperspectivePerceptronTAGE {
8214081Sjavier.bueno@metempsy.com    void createSpecs() override;
8314081Sjavier.bueno@metempsy.com  public:
8414081Sjavier.bueno@metempsy.com    MultiperspectivePerceptronTAGE64KB(
8514081Sjavier.bueno@metempsy.com            const MultiperspectivePerceptronTAGE64KBParams *p);
8614081Sjavier.bueno@metempsy.com};
8714081Sjavier.bueno@metempsy.com
8814081Sjavier.bueno@metempsy.com#endif // __CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_TAGE_64KB_HH__
89