summaryrefslogtreecommitdiff
path: root/src/cpu/pred/tage_sc_l_8KB.hh
blob: 7730463b1aa23b5ba66df29be009be4835929d44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 * Copyright (c) 2018 Metempsy Technology Consulting
 * All rights reserved.
 *
 * Copyright (c) 2006 INRIA (Institut National de Recherche en
 * Informatique et en Automatique  / French National Research Institute
 * for Computer Science and Applied Mathematics)
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met: redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer;
 * redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution;
 * neither the name of the copyright holders nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Author: André Seznec, Pau Cabre, Javier Bueno
 *
 */

/*
 * 8KB TAGE-SC-L branch predictor (devised by Andre Seznec)
 */

#ifndef __CPU_PRED_TAGE_SC_L_8KB
#define __CPU_PRED_TAGE_SC_L_8KB

#include "cpu/pred/tage_sc_l.hh"
#include "params/TAGE_SC_L_8KB.hh"
#include "params/TAGE_SC_L_8KB_StatisticalCorrector.hh"
#include "params/TAGE_SC_L_TAGE_8KB.hh"

class TAGE_SC_L_TAGE_8KB : public TAGE_SC_L_TAGE
{
  public:
    TAGE_SC_L_TAGE_8KB(const TAGE_SC_L_TAGE_8KBParams *p) : TAGE_SC_L_TAGE(p)
    {}

    void initFoldedHistories(ThreadHistory & history) override;
    int gindex_ext(int index, int bank) const override;

    uint16_t gtag(ThreadID tid, Addr pc, int bank) const override;

    void handleAllocAndUReset(
        bool alloc, bool taken, TAGEBase::BranchInfo* bi, int nrand) override;

    void handleTAGEUpdate(
        Addr branch_pc, bool taken, TAGEBase::BranchInfo* bi) override;

    void resetUctr(uint8_t & u) override;
};

class TAGE_SC_L_8KB_StatisticalCorrector : public StatisticalCorrector
{
    // global branch history GEHL
    const unsigned gnb;
    const unsigned logGnb;
    std::vector<int> gm;
    std::vector<int8_t> * ggehl;
    std::vector<int8_t> wg;

    struct SC_8KB_ThreadHistory : public SCThreadHistory
    {
        SC_8KB_ThreadHistory() {
            globalHist = 0;
        }
        int64_t globalHist; // global history
    };

    SCThreadHistory *makeThreadHistory() override;

  public:
    TAGE_SC_L_8KB_StatisticalCorrector(
        TAGE_SC_L_8KB_StatisticalCorrectorParams *p);

    unsigned getIndBiasBank( Addr branch_pc, BranchInfo* bi, int hitBank,
        int altBank) const override;

    int gPredictions( ThreadID tid, Addr branch_pc,
        BranchInfo* bi, int & lsum, int64_t phist) override;

    int gIndexLogsSubstr(int nbr, int i) override;

    void scHistoryUpdate(
        Addr branch_pc, const StaticInstPtr &inst, bool taken,
        BranchInfo * tage_bi, Addr corrTarget) override;

    void gUpdates(ThreadID tid, Addr pc, bool taken, BranchInfo* bi,
        int64_t phist) override;
};

class TAGE_SC_L_8KB : public TAGE_SC_L
{
  public:
    TAGE_SC_L_8KB(const TAGE_SC_L_8KBParams *params);
};

#endif // __CPU_PRED_TAGE_SC_L_8KB