113685Sjavier.bueno@metempsy.com/*
213685Sjavier.bueno@metempsy.com * Copyright (c) 2018 Metempsy Technology Consulting
313685Sjavier.bueno@metempsy.com * All rights reserved.
413685Sjavier.bueno@metempsy.com *
513685Sjavier.bueno@metempsy.com * Copyright (c) 2006 INRIA (Institut National de Recherche en
613685Sjavier.bueno@metempsy.com * Informatique et en Automatique  / French National Research Institute
713685Sjavier.bueno@metempsy.com * for Computer Science and Applied Mathematics)
813685Sjavier.bueno@metempsy.com *
913685Sjavier.bueno@metempsy.com * All rights reserved.
1013685Sjavier.bueno@metempsy.com *
1113685Sjavier.bueno@metempsy.com * Redistribution and use in source and binary forms, with or without
1213685Sjavier.bueno@metempsy.com * modification, are permitted provided that the following conditions are
1313685Sjavier.bueno@metempsy.com * met: redistributions of source code must retain the above copyright
1413685Sjavier.bueno@metempsy.com * notice, this list of conditions and the following disclaimer;
1513685Sjavier.bueno@metempsy.com * redistributions in binary form must reproduce the above copyright
1613685Sjavier.bueno@metempsy.com * notice, this list of conditions and the following disclaimer in the
1713685Sjavier.bueno@metempsy.com * documentation and/or other materials provided with the distribution;
1813685Sjavier.bueno@metempsy.com * neither the name of the copyright holders nor the names of its
1913685Sjavier.bueno@metempsy.com * contributors may be used to endorse or promote products derived from
2013685Sjavier.bueno@metempsy.com * this software without specific prior written permission.
2113685Sjavier.bueno@metempsy.com *
2213685Sjavier.bueno@metempsy.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2313685Sjavier.bueno@metempsy.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2413685Sjavier.bueno@metempsy.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2513685Sjavier.bueno@metempsy.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2613685Sjavier.bueno@metempsy.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2713685Sjavier.bueno@metempsy.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2813685Sjavier.bueno@metempsy.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2913685Sjavier.bueno@metempsy.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3013685Sjavier.bueno@metempsy.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3113685Sjavier.bueno@metempsy.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3213685Sjavier.bueno@metempsy.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3313685Sjavier.bueno@metempsy.com *
3413685Sjavier.bueno@metempsy.com * Author: André Seznec, Pau Cabre, Javier Bueno
3513685Sjavier.bueno@metempsy.com *
3613685Sjavier.bueno@metempsy.com */
3713685Sjavier.bueno@metempsy.com
3813685Sjavier.bueno@metempsy.com/*
3913685Sjavier.bueno@metempsy.com * 8KB TAGE-SC-L branch predictor (devised by Andre Seznec)
4013685Sjavier.bueno@metempsy.com */
4113685Sjavier.bueno@metempsy.com
4213685Sjavier.bueno@metempsy.com#ifndef __CPU_PRED_TAGE_SC_L_8KB
4313685Sjavier.bueno@metempsy.com#define __CPU_PRED_TAGE_SC_L_8KB
4413685Sjavier.bueno@metempsy.com
4513685Sjavier.bueno@metempsy.com#include "cpu/pred/tage_sc_l.hh"
4613685Sjavier.bueno@metempsy.com#include "params/TAGE_SC_L_8KB.hh"
4713685Sjavier.bueno@metempsy.com#include "params/TAGE_SC_L_8KB_StatisticalCorrector.hh"
4813685Sjavier.bueno@metempsy.com#include "params/TAGE_SC_L_TAGE_8KB.hh"
4913685Sjavier.bueno@metempsy.com
5013685Sjavier.bueno@metempsy.comclass TAGE_SC_L_TAGE_8KB : public TAGE_SC_L_TAGE
5113685Sjavier.bueno@metempsy.com{
5213685Sjavier.bueno@metempsy.com  public:
5313685Sjavier.bueno@metempsy.com    TAGE_SC_L_TAGE_8KB(const TAGE_SC_L_TAGE_8KBParams *p) : TAGE_SC_L_TAGE(p)
5413685Sjavier.bueno@metempsy.com    {}
5513685Sjavier.bueno@metempsy.com
5613685Sjavier.bueno@metempsy.com    void initFoldedHistories(ThreadHistory & history) override;
5713685Sjavier.bueno@metempsy.com    int gindex_ext(int index, int bank) const override;
5813685Sjavier.bueno@metempsy.com
5913685Sjavier.bueno@metempsy.com    uint16_t gtag(ThreadID tid, Addr pc, int bank) const override;
6013685Sjavier.bueno@metempsy.com
6113685Sjavier.bueno@metempsy.com    void handleAllocAndUReset(
6213685Sjavier.bueno@metempsy.com        bool alloc, bool taken, TAGEBase::BranchInfo* bi, int nrand) override;
6313685Sjavier.bueno@metempsy.com
6413685Sjavier.bueno@metempsy.com    void handleTAGEUpdate(
6513685Sjavier.bueno@metempsy.com        Addr branch_pc, bool taken, TAGEBase::BranchInfo* bi) override;
6613685Sjavier.bueno@metempsy.com
6713685Sjavier.bueno@metempsy.com    void resetUctr(uint8_t & u) override;
6813685Sjavier.bueno@metempsy.com};
6913685Sjavier.bueno@metempsy.com
7013685Sjavier.bueno@metempsy.comclass TAGE_SC_L_8KB_StatisticalCorrector : public StatisticalCorrector
7113685Sjavier.bueno@metempsy.com{
7213685Sjavier.bueno@metempsy.com    // global branch history GEHL
7313685Sjavier.bueno@metempsy.com    const unsigned gnb;
7413685Sjavier.bueno@metempsy.com    const unsigned logGnb;
7513685Sjavier.bueno@metempsy.com    std::vector<int> gm;
7613685Sjavier.bueno@metempsy.com    std::vector<int8_t> * ggehl;
7713685Sjavier.bueno@metempsy.com    std::vector<int8_t> wg;
7813685Sjavier.bueno@metempsy.com
7913685Sjavier.bueno@metempsy.com    struct SC_8KB_ThreadHistory : public SCThreadHistory
8013685Sjavier.bueno@metempsy.com    {
8113685Sjavier.bueno@metempsy.com        SC_8KB_ThreadHistory() {
8213685Sjavier.bueno@metempsy.com            globalHist = 0;
8313685Sjavier.bueno@metempsy.com        }
8413685Sjavier.bueno@metempsy.com        int64_t globalHist; // global history
8513685Sjavier.bueno@metempsy.com    };
8613685Sjavier.bueno@metempsy.com
8713685Sjavier.bueno@metempsy.com    SCThreadHistory *makeThreadHistory() override;
8813685Sjavier.bueno@metempsy.com
8913685Sjavier.bueno@metempsy.com  public:
9013685Sjavier.bueno@metempsy.com    TAGE_SC_L_8KB_StatisticalCorrector(
9113685Sjavier.bueno@metempsy.com        TAGE_SC_L_8KB_StatisticalCorrectorParams *p);
9213685Sjavier.bueno@metempsy.com
9313685Sjavier.bueno@metempsy.com    unsigned getIndBiasBank( Addr branch_pc, BranchInfo* bi, int hitBank,
9413685Sjavier.bueno@metempsy.com        int altBank) const override;
9513685Sjavier.bueno@metempsy.com
9613685Sjavier.bueno@metempsy.com    int gPredictions( ThreadID tid, Addr branch_pc,
9713685Sjavier.bueno@metempsy.com        BranchInfo* bi, int & lsum, int64_t phist) override;
9813685Sjavier.bueno@metempsy.com
9913685Sjavier.bueno@metempsy.com    int gIndexLogsSubstr(int nbr, int i) override;
10013685Sjavier.bueno@metempsy.com
10113685Sjavier.bueno@metempsy.com    void scHistoryUpdate(
10214081Sjavier.bueno@metempsy.com        Addr branch_pc, const StaticInstPtr &inst, bool taken,
10314081Sjavier.bueno@metempsy.com        BranchInfo * tage_bi, Addr corrTarget) override;
10413685Sjavier.bueno@metempsy.com
10513685Sjavier.bueno@metempsy.com    void gUpdates(ThreadID tid, Addr pc, bool taken, BranchInfo* bi,
10613685Sjavier.bueno@metempsy.com        int64_t phist) override;
10713685Sjavier.bueno@metempsy.com};
10813685Sjavier.bueno@metempsy.com
10913685Sjavier.bueno@metempsy.comclass TAGE_SC_L_8KB : public TAGE_SC_L
11013685Sjavier.bueno@metempsy.com{
11113685Sjavier.bueno@metempsy.com  public:
11213685Sjavier.bueno@metempsy.com    TAGE_SC_L_8KB(const TAGE_SC_L_8KBParams *params);
11313685Sjavier.bueno@metempsy.com};
11413685Sjavier.bueno@metempsy.com
11513685Sjavier.bueno@metempsy.com#endif // __CPU_PRED_TAGE_SC_L_8KB
11613685Sjavier.bueno@metempsy.com
117