gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
evs.cc
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  * Authors: Gabe Black
28  */
29 
31 
34 #include "base/logging.hh"
35 #include "dev/arm/base_gic.hh"
36 #include "sim/core.hh"
38 
39 namespace FastModel
40 {
41 
42 template <class Types>
43 void
45 {
46  clockRateControl->set_mul_div(SimClock::Int::s, clockPeriod.value);
47 }
48 
49 template <class Types>
51  const sc_core::sc_module_name &mod_name, const Params &p) :
52  Base(mod_name), amba(Base::amba, p.name + ".amba", -1),
53  clockChanged(Iris::ClockEventName.c_str()),
54  clockPeriod(Iris::PeriodAttributeName.c_str()),
55  gem5CpuCluster(Iris::Gem5CpuClusterAttributeName.c_str()),
56  sendFunctional(Iris::SendFunctionalAttributeName.c_str()),
57  params(p)
58 {
59  for (int i = 0; i < CoreCount; i++) {
60  redist.emplace_back(new TlmGicTarget(this->redistributor[i],
61  csprintf("%s.redistributor[%d]", name(), i), i));
62  cnthpirq.emplace_back(new SignalReceiver(csprintf("cnthpirq[%d]", i)));
63  cnthvirq.emplace_back(new SignalReceiver(csprintf("cnthvirq[%d]", i)));
64  cntpsirq.emplace_back(new SignalReceiver(csprintf("cntpsirq[%d]", i)));
65  cntvirq.emplace_back(new SignalReceiver(csprintf("cntvirq[%d]", i)));
66  commirq.emplace_back(new SignalReceiver(csprintf("commirq[%d]", i)));
67  ctidbgirq.emplace_back(
68  new SignalReceiver(csprintf("ctidbgirq[%d]", i)));
69  pmuirq.emplace_back(new SignalReceiver(csprintf("pmuirq[%d]", i)));
70  vcpumntirq.emplace_back(
71  new SignalReceiver(csprintf("vcpumntirq[%d]", i)));
72  cntpnsirq.emplace_back(
73  new SignalReceiver(csprintf("cntpnsirq[%d]", i)));
74 
75  Base::cnthpirq[i].bind(cnthpirq[i]->signal_in);
76  Base::cnthvirq[i].bind(cnthvirq[i]->signal_in);
77  Base::cntpsirq[i].bind(cntpsirq[i]->signal_in);
78  Base::cntvirq[i].bind(cntvirq[i]->signal_in);
79  Base::commirq[i].bind(commirq[i]->signal_in);
80  Base::ctidbgirq[i].bind(ctidbgirq[i]->signal_in);
81  Base::pmuirq[i].bind(pmuirq[i]->signal_in);
82  Base::vcpumntirq[i].bind(vcpumntirq[i]->signal_in);
83  Base::cntpnsirq[i].bind(cntpnsirq[i]->signal_in);
84  }
85 
86  clockRateControl.bind(this->clock_rate_s);
87 
88  this->add_attribute(gem5CpuCluster);
89  this->add_attribute(clockPeriod);
91  this->dont_initialize();
92  this->sensitive << clockChanged;
93 
94  sendFunctional.value = [this](PacketPtr pkt) { sendFunc(pkt); };
95  this->add_attribute(sendFunctional);
96 }
97 
98 template <class Types>
99 void
101 {
102  auto *trans = sc_gem5::packet2payload(pkt);
103  panic_if(Base::amba->transport_dbg(*trans) != trans->get_data_length(),
104  "Didn't send entire functional packet!");
105  trans->release();
106 }
107 
108 template <class Types>
109 void
111 {
112  Base::before_end_of_elaboration();
113 
114  auto *cluster = gem5CpuCluster.value;
115 
116  auto set_on_change = [cluster](
117  SignalReceiver &recv, ArmInterruptPinGen *gen, int num)
118  {
119  auto *pin = gen->get(cluster->getCore(num)->getContext(0));
120  auto handler = [pin](bool status)
121  {
122  status ? pin->raise() : pin->clear();
123  };
124  recv.onChange(handler);
125  };
126 
127  for (int i = 0; i < CoreCount; i++) {
128  set_on_change(*cnthpirq[i], cluster->params().cnthpirq, i);
129  set_on_change(*cnthvirq[i], cluster->params().cnthvirq, i);
130  set_on_change(*cntpsirq[i], cluster->params().cntpsirq, i);
131  set_on_change(*cntvirq[i], cluster->params().cntvirq, i);
132  set_on_change(*commirq[i], cluster->params().commirq, i);
133  set_on_change(*ctidbgirq[i], cluster->params().ctidbgirq, i);
134  set_on_change(*pmuirq[i], cluster->params().pmuirq, i);
135  set_on_change(*vcpumntirq[i], cluster->params().vcpumntirq, i);
136  set_on_change(*cntpnsirq[i], cluster->params().cntpnsirq, i);
137  }
138 }
139 
140 template <class Types>
141 Port &
142 ScxEvsCortexA76<Types>::gem5_getPort(const std::string &if_name, int idx)
143 {
144  if (if_name == "redistributor")
145  return *redist.at(idx);
146  else if (if_name == "amba")
147  return amba;
148  else
149  return Base::gem5_getPort(if_name, idx);
150 }
151 
156 
157 } // namespace FastModel
158 
160 FastModelScxEvsCortexA76x1Params::create()
161 {
162  return new FastModel::ScxEvsCortexA76x1(name.c_str(), *this);
163 }
164 
166 FastModelScxEvsCortexA76x2Params::create()
167 {
168  return new FastModel::ScxEvsCortexA76x2(name.c_str(), *this);
169 }
170 
172 FastModelScxEvsCortexA76x3Params::create()
173 {
174  return new FastModel::ScxEvsCortexA76x3(name.c_str(), *this);
175 }
176 
178 FastModelScxEvsCortexA76x4Params::create()
179 {
180  return new FastModel::ScxEvsCortexA76x4(name.c_str(), *this);
181 }
typename Types::Params Params
Definition: evs.hh:62
Ports are used to interface objects to each other.
Definition: port.hh:60
std::vector< std::unique_ptr< SignalReceiver > > cntpsirq
Definition: evs.hh:78
const std::string & name()
Definition: trace.cc:54
Bitfield< 7 > i
#define SC_METHOD(name)
Definition: sc_module.hh:301
void onChange(OnChangeFunc func)
sc_core::sc_event clockChanged
Definition: evs.hh:86
ClockRateControlInitiatorSocket clockRateControl
Definition: evs.hh:66
static const std::string PeriodAttributeName
Definition: cpu.hh:48
static const int CoreCount
Definition: evs.hh:60
sc_core::sc_attribute< CortexA76Cluster * > gem5CpuCluster
Definition: evs.hh:88
typename Types::Base Base
Definition: evs.hh:61
tlm::tlm_generic_payload * packet2payload(PacketPtr packet)
Convert a gem5 packet to a TLM payload by copying all the relevant information to new tlm payload...
Definition: gem5_to_tlm.cc:86
ScxEvsCortexA76< ScxEvsCortexA76x2Types > ScxEvsCortexA76x2
Definition: evs.hh:127
std::vector< std::unique_ptr< SignalReceiver > > commirq
Definition: evs.hh:80
std::vector< std::unique_ptr< SignalReceiver > > pmuirq
Definition: evs.hh:82
Port & gem5_getPort(const std::string &if_name, int idx) override
Definition: evs.cc:142
sc_core::sc_attribute< PortProxy::SendFunctionalFunc > sendFunctional
Definition: evs.hh:89
Bitfield< 5, 0 > status
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:162
virtual void bind(base_target_socket_type &s)
sc_core::sc_attribute< Tick > clockPeriod
Definition: evs.hh:87
std::vector< std::unique_ptr< SignalReceiver > > cnthvirq
Definition: evs.hh:77
AmbaInitiator amba
Definition: evs.hh:73
ScxEvsCortexA76(const sc_core::sc_module_name &mod_name, const Params &p)
Definition: evs.cc:50
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
sc_gem5::TlmTargetBaseWrapper< 64, svp_gicv3_comms::gicv3_comms_fw_if, svp_gicv3_comms::gicv3_comms_bw_if, 1, sc_core::SC_ONE_OR_MORE_BOUND > TlmGicTarget
Definition: evs.hh:71
Tick s
second
Definition: core.cc:65
std::vector< std::unique_ptr< SignalReceiver > > vcpumntirq
Definition: evs.hh:83
static const std::string ClockEventName
Definition: cpu.hh:45
ScxEvsCortexA76< ScxEvsCortexA76x4Types > ScxEvsCortexA76x4
Definition: evs.hh:145
Base class for ARM GIC implementations.
static const std::string Gem5CpuClusterAttributeName
Definition: cpu.hh:51
void sendFunc(PacketPtr pkt)
Definition: evs.cc:100
void clockChangeHandler()
Definition: evs.cc:44
void before_end_of_elaboration() override
Definition: evs.cc:110
std::vector< std::unique_ptr< SignalReceiver > > ctidbgirq
Definition: evs.hh:81
This SimObject is instantiated in the python world and serves as an ArmInterruptPin generator...
Definition: base_gic.hh:137
static const std::string SendFunctionalAttributeName
Definition: cpu.hh:54
std::vector< std::unique_ptr< SignalReceiver > > cntpnsirq
Definition: evs.hh:84
ScxEvsCortexA76< ScxEvsCortexA76x1Types > ScxEvsCortexA76x1
Definition: evs.hh:118
std::vector< std::unique_ptr< SignalReceiver > > cnthpirq
Definition: evs.hh:76
Bitfield< 0 > p
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:185
ScxEvsCortexA76< ScxEvsCortexA76x3Types > ScxEvsCortexA76x3
Definition: evs.hh:136
Definition: cpu.cc:36
std::vector< std::unique_ptr< TlmGicTarget > > redist
Definition: evs.hh:74
std::vector< std::unique_ptr< SignalReceiver > > cntvirq
Definition: evs.hh:79

Generated on Fri Feb 28 2020 16:26:56 for gem5 by doxygen 1.8.13