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

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