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

Generated on Tue Sep 21 2021 12:24:23 for gem5 by doxygen 1.8.17