gem5  v21.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 
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, clk_period);
45 }
46 
47 template <class Types>
48 void
50 {
51  periphClockRateControl->set_mul_div(sys_counter_frq, 1);
52 }
53 
54 template <class Types>
55 void
57 {
58  gem5CpuCluster = dynamic_cast<CortexA76Cluster *>(cluster);
59  panic_if(!gem5CpuCluster, "Cluster should be of type CortexA76Cluster");
60 }
61 
62 template <class Types>
64  const sc_core::sc_module_name &mod_name, const Params &p) :
65  Base(mod_name), amba(Base::amba, p.name + ".amba", -1),
66  params(p)
67 {
68  for (int i = 0; i < CoreCount; i++) {
69  redist.emplace_back(new TlmGicTarget(this->redistributor[i],
70  csprintf("%s.redistributor[%d]", name(), i), i));
71  cnthpirq.emplace_back(new SignalReceiver(csprintf("cnthpirq[%d]", i)));
72  cnthvirq.emplace_back(new SignalReceiver(csprintf("cnthvirq[%d]", i)));
73  cntpsirq.emplace_back(new SignalReceiver(csprintf("cntpsirq[%d]", i)));
74  cntvirq.emplace_back(new SignalReceiver(csprintf("cntvirq[%d]", i)));
75  commirq.emplace_back(new SignalReceiver(csprintf("commirq[%d]", i)));
76  ctidbgirq.emplace_back(
77  new SignalReceiver(csprintf("ctidbgirq[%d]", i)));
78  pmuirq.emplace_back(new SignalReceiver(csprintf("pmuirq[%d]", i)));
79  vcpumntirq.emplace_back(
80  new SignalReceiver(csprintf("vcpumntirq[%d]", i)));
81  cntpnsirq.emplace_back(
82  new SignalReceiver(csprintf("cntpnsirq[%d]", i)));
83 
84  Base::cnthpirq[i].bind(cnthpirq[i]->signal_in);
85  Base::cnthvirq[i].bind(cnthvirq[i]->signal_in);
86  Base::cntpsirq[i].bind(cntpsirq[i]->signal_in);
87  Base::cntvirq[i].bind(cntvirq[i]->signal_in);
88  Base::commirq[i].bind(commirq[i]->signal_in);
89  Base::ctidbgirq[i].bind(ctidbgirq[i]->signal_in);
90  Base::pmuirq[i].bind(pmuirq[i]->signal_in);
91  Base::vcpumntirq[i].bind(vcpumntirq[i]->signal_in);
92  Base::cntpnsirq[i].bind(cntpnsirq[i]->signal_in);
93  }
94 
95  clockRateControl.bind(this->clock_rate_s);
96  periphClockRateControl.bind(this->periph_clock_rate_s);
97 }
98 
99 template <class Types>
100 void
102 {
103  auto *trans = sc_gem5::packet2payload(pkt);
104  panic_if(Base::amba->transport_dbg(*trans) != trans->get_data_length(),
105  "Didn't send entire functional packet!");
106  trans->release();
107 }
108 
109 template <class Types>
110 void
112 {
113  Base::before_end_of_elaboration();
114 
115  auto set_on_change = [this](
116  SignalReceiver &recv, ArmInterruptPinGen *gen, int num)
117  {
118  auto *pin = gen->get(gem5CpuCluster->getCore(num)->getContext(0));
119  auto handler = [pin](bool status)
120  {
121  status ? pin->raise() : pin->clear();
122  };
123  recv.onChange(handler);
124  };
125 
126  for (int i = 0; i < CoreCount; i++) {
127  set_on_change(*cnthpirq[i], gem5CpuCluster->params().cnthpirq, i);
128  set_on_change(*cnthvirq[i], gem5CpuCluster->params().cnthvirq, i);
129  set_on_change(*cntpsirq[i], gem5CpuCluster->params().cntpsirq, i);
130  set_on_change(*cntvirq[i], gem5CpuCluster->params().cntvirq, i);
131  set_on_change(*commirq[i], gem5CpuCluster->params().commirq, i);
132  set_on_change(*ctidbgirq[i], gem5CpuCluster->params().ctidbgirq, i);
133  set_on_change(*pmuirq[i], gem5CpuCluster->params().pmuirq, i);
134  set_on_change(*vcpumntirq[i], gem5CpuCluster->params().vcpumntirq, i);
135  set_on_change(*cntpnsirq[i], gem5CpuCluster->params().cntpnsirq, i);
136  }
137 }
138 
139 template <class Types>
140 Port &
141 ScxEvsCortexA76<Types>::gem5_getPort(const std::string &if_name, int idx)
142 {
143  if (if_name == "redistributor")
144  return *redist.at(idx);
145  else if (if_name == "amba")
146  return amba;
147  else
148  return Base::gem5_getPort(if_name, idx);
149 }
150 
155 
156 } // namespace FastModel
FastModel::ScxEvsCortexA76::cnthpirq
std::vector< std::unique_ptr< SignalReceiver > > cnthpirq
Definition: evs.hh:76
FastModel::ScxEvsCortexA76::cntpnsirq
std::vector< std::unique_ptr< SignalReceiver > > cntpnsirq
Definition: evs.hh:84
FastModel::ScxEvsCortexA76::CoreCount
static const int CoreCount
Definition: evs.hh:59
ArmISA::status
Bitfield< 5, 0 > status
Definition: miscregs_types.hh:417
FastModel::ScxEvsCortexA76::ctidbgirq
std::vector< std::unique_ptr< SignalReceiver > > ctidbgirq
Definition: evs.hh:81
FastModel::ScxEvsCortexA76::commirq
std::vector< std::unique_ptr< SignalReceiver > > commirq
Definition: evs.hh:80
cortex_a76.hh
FastModel::ScxEvsCortexA76::cnthvirq
std::vector< std::unique_ptr< SignalReceiver > > cnthvirq
Definition: evs.hh:77
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:141
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:104
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:59
FastModel::ScxEvsCortexA76::periphClockRateControl
ClockRateControlInitiatorSocket periphClockRateControl
Definition: evs.hh:66
FastModel::ScxEvsCortexA76::clockRateControl
ClockRateControlInitiatorSocket clockRateControl
Definition: evs.hh:65
FastModel::ScxEvsCortexA76::setCluster
void setCluster(SimObject *cluster) override
Definition: evs.cc:56
cpu.hh
evs.hh
FastModel::SignalReceiver
Definition: signal_receiver.hh:41
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
SimClock::Int::s
Tick s
second
Definition: core.cc:59
ArmInterruptPinGen
This SimObject is instantiated in the python world and serves as an ArmInterruptPin generator.
Definition: base_gic.hh:137
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:71
FastModel::ScxEvsCortexA76::setClkPeriod
void setClkPeriod(Tick clk_period) override
Definition: evs.cc:42
sc_core::sc_module_name
Definition: sc_module_name.hh:41
FastModel::ScxEvsCortexA76::setSysCounterFrq
void setSysCounterFrq(uint64_t sys_counter_frq) override
Definition: evs.cc:49
core.hh
FastModel::ScxEvsCortexA76::before_end_of_elaboration
void before_end_of_elaboration() override
Definition: evs.cc:111
FastModel::ScxEvsCortexA76::redist
std::vector< std::unique_ptr< TlmGicTarget > > redist
Definition: evs.hh:74
name
const std::string & name()
Definition: trace.cc:48
FastModel::SignalReceiver::onChange
void onChange(OnChangeFunc func)
Definition: signal_receiver.hh:64
FastModel::ScxEvsCortexA76::Base
typename Types::Base Base
Definition: evs.hh:60
FastModel::ScxEvsCortexA76::sendFunc
void sendFunc(PacketPtr pkt) override
Definition: evs.cc:101
FastModel::ScxEvsCortexA76::cntpsirq
std::vector< std::unique_ptr< SignalReceiver > > cntpsirq
Definition: evs.hh:78
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:56
FastModel::ScxEvsCortexA76::vcpumntirq
std::vector< std::unique_ptr< SignalReceiver > > vcpumntirq
Definition: evs.hh:83
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
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:258
FastModel::CortexA76Cluster
Definition: cortex_a76.hh:77
logging.hh
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
FastModel::ScxEvsCortexA76::Params
typename Types::Params Params
Definition: evs.hh:61
FastModel::ScxEvsCortexA76::cntvirq
std::vector< std::unique_ptr< SignalReceiver > > cntvirq
Definition: evs.hh:79
FastModel::ScxEvsCortexA76::pmuirq
std::vector< std::unique_ptr< SignalReceiver > > pmuirq
Definition: evs.hh:82
csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:158
FastModel::ScxEvsCortexA76::ScxEvsCortexA76
ScxEvsCortexA76(const Params &p)
Definition: evs.hh:91
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:141

Generated on Tue Mar 23 2021 19:41:18 for gem5 by doxygen 1.8.17