gem5  v20.1.0.0
cortex_a76.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Google, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef __ARCH_ARM_FASTMODEL_CORTEXA76_CORETEX_A76_HH__
29 #define __ARCH_ARM_FASTMODEL_CORTEXA76_CORETEX_A76_HH__
30 
34 #include "params/FastModelCortexA76.hh"
35 #include "params/FastModelCortexA76Cluster.hh"
36 #include "scx/scx.h"
37 #include "sim/port.hh"
39 
40 class BaseCPU;
41 
42 namespace FastModel
43 {
44 
45 // The fast model exports a class called scx_evs_CortexA76x1 which represents
46 // the subsystem described in LISA+. This class specializes it to export gem5
47 // ports and interface with its peer gem5 CPU. The gem5 CPU inherits from the
48 // gem5 BaseCPU class and implements its API, while this class actually does
49 // the work.
50 class CortexA76Cluster;
51 
52 class CortexA76 : public Iris::CPU<CortexA76TC>
53 {
54  protected:
55  typedef FastModelCortexA76Params Params;
57  const Params &_params;
58 
60  int num = 0;
61 
62  const Params &params() { return _params; }
63 
64  public:
65  CortexA76(Params &p) : Base(&p, scx::scx_get_iris_connection_interface()),
66  _params(p)
67  {}
68 
69  void
70  clockPeriodUpdated() override
71  {
73 
74  // FIXME(b/139447397): this is a workaround since CNTFRQ_EL0 should not
75  // be modified after clock is changed in real hardwares. Remove or
76  // modify this after a more reasonable solution is found.
77  for (auto *tc : threadContexts) {
78  tc->setMiscRegNoEffect(ArmISA::MISCREG_CNTFRQ_EL0, frequency());
79  }
80  }
81 
82  void initState() override;
83 
84  template <class T>
85  void set_evs_param(const std::string &n, T val);
86 
87  void setCluster(CortexA76Cluster *_cluster, int _num);
88 
89  Port &getPort(const std::string &if_name,
90  PortID idx=InvalidPortID) override;
91 };
92 
94 {
95  private:
96  typedef FastModelCortexA76ClusterParams Params;
97  const Params &_params;
98 
101 
102  public:
103  template <class T>
104  void
105  set_evs_param(const std::string &n, T val)
106  {
107  scx::scx_set_parameter(evs->name() + std::string(".") + n, val);
108  }
109 
110  CortexA76 *getCore(int num) { return cores.at(num); }
112 
114  const Params &params() { return _params; }
115 
116  Port &getPort(const std::string &if_name,
117  PortID idx=InvalidPortID) override;
118 };
119 
120 template <class T>
121 inline void
122 CortexA76::set_evs_param(const std::string &n, T val)
123 {
124  for (auto &path: params().thread_paths)
125  cluster->set_evs_param(path + "." + n, val);
126 }
127 
128 } // namespace FastModel
129 
130 #endif // __ARCH_ARM_FASTMODEL_CORTEXA76_CORETEX_A76_HH__
FastModel::CortexA76Cluster::Params
FastModelCortexA76ClusterParams Params
Definition: cortex_a76.hh:96
FastModel::CortexA76
Definition: cortex_a76.hh:52
Iris::BaseCPU::clockPeriodUpdated
void clockPeriodUpdated() override
Definition: cpu.hh:105
sc_core::sc_module
Definition: sc_module.hh:97
InvalidPortID
const PortID InvalidPortID
Definition: types.hh:238
ArmISA::MISCREG_CNTFRQ_EL0
@ MISCREG_CNTFRQ_EL0
Definition: miscregs.hh:745
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
thread_context.hh
std::vector
STL vector class.
Definition: stl.hh:37
FastModel::CortexA76::setCluster
void setCluster(CortexA76Cluster *_cluster, int _num)
Definition: cortex_a76.cc:47
FastModel::CortexA76::params
const Params & params()
Definition: cortex_a76.hh:62
FastModel::CortexA76Cluster::getCore
CortexA76 * getCore(int num)
Definition: cortex_a76.hh:110
cpu.hh
FastModel::CortexA76::cluster
CortexA76Cluster * cluster
Definition: cortex_a76.hh:59
ArmISA::n
Bitfield< 31 > n
Definition: miscregs_types.hh:450
FastModel::CortexA76::initState
void initState() override
Definition: cortex_a76.cc:40
FastModel::CortexA76Cluster::_params
const Params & _params
Definition: cortex_a76.hh:97
FastModel::CortexA76Cluster::getEvs
sc_core::sc_module * getEvs()
Definition: cortex_a76.hh:111
FastModel::CortexA76Cluster::CortexA76Cluster
CortexA76Cluster(Params &p)
Definition: cortex_a76.cc:101
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
BaseCPU::threadContexts
std::vector< ThreadContext * > threadContexts
Definition: base.hh:252
FastModel::CortexA76::getPort
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Definition: cortex_a76.cc:93
X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
FastModel::CortexA76::set_evs_param
void set_evs_param(const std::string &n, T val)
Definition: cortex_a76.hh:122
port.hh
sc_module.hh
amba_ports.hh
FastModel::CortexA76::CortexA76
CortexA76(Params &p)
Definition: cortex_a76.hh:65
BaseCPU
Definition: cpu_dummy.hh:43
FastModel::CortexA76::num
int num
Definition: cortex_a76.hh:60
FastModel::CortexA76Cluster::cores
std::vector< CortexA76 * > cores
Definition: cortex_a76.hh:99
FastModel
Definition: amba_from_tlm_bridge.cc:32
FastModel::CortexA76Cluster::params
const Params & params()
Definition: cortex_a76.hh:114
FastModel::CortexA76::_params
const Params & _params
Definition: cortex_a76.hh:57
FastModel::CortexA76Cluster::set_evs_param
void set_evs_param(const std::string &n, T val)
Definition: cortex_a76.hh:105
FastModel::CortexA76Cluster
Definition: cortex_a76.hh:93
FastModel::CortexA76::clockPeriodUpdated
void clockPeriodUpdated() override
Definition: cortex_a76.hh:70
sc_core::sc_object::name
const char * name() const
Definition: sc_object.cc:44
FastModel::CortexA76::Params
FastModelCortexA76Params Params
Definition: cortex_a76.hh:55
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
FastModel::CortexA76Cluster::evs
sc_core::sc_module * evs
Definition: cortex_a76.hh:100
FastModel::CortexA76Cluster::getPort
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: cortex_a76.cc:195
FastModel::CortexA76::Base
Iris::CPU< CortexA76TC > Base
Definition: cortex_a76.hh:56
Iris::CPU
Definition: cpu.hh:128
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:01:58 for gem5 by doxygen 1.8.17