gem5  [DEVELOP-FOR-23.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 gem5
38 {
39 
40 namespace fastmodel
41 {
42 
43 template <class Types>
44 void
46 {
47  clockRateControl->set_mul_div(sim_clock::as_int::s, clk_period);
48 }
49 
50 template <class Types>
51 void
53 {
54  periphClockRateControl->set_mul_div(sys_counter_frq, 1);
55 }
56 
57 template <class Types>
58 void
60 {
61  gem5CpuCluster = dynamic_cast<CortexA76Cluster *>(cluster);
62  panic_if(!gem5CpuCluster, "Cluster should be of type CortexA76Cluster");
63 }
64 
65 template <class Types>
66 void
68 {
69  this->rvbaraddr[core]->set_state(0, addr);
70 }
71 
72 template <class Types>
74  const sc_core::sc_module_name &mod_name, const Params &p) :
75  Base(mod_name),
76  amba(Base::amba, p.name + ".amba", -1),
77  top_reset(p.name + ".top_reset", 0),
78  dbg_reset(p.name + ".dbg_reset", 0),
79  model_reset(p.name + ".model_reset"),
80  params(p)
81 {
82  model_reset.onChange([this](const bool &new_val) {
83  // Set reset for all cores.
84  for (auto &poweron_reset : poweron_reset)
85  poweron_reset->signal_out.set_state(0, new_val);
86  // Set reset for DSU.
87  top_reset.signal_out.set_state(0, new_val);
88  // Set reset for debug APB.
89  dbg_reset.signal_out.set_state(0, new_val);
90  });
91 
92  for (int i = 0; i < CoreCount; i++) {
93  redist.emplace_back(new TlmGicTarget(this->redistributor[i],
94  csprintf("%s.redistributor[%d]", name(), i), i));
95  cnthpirq.emplace_back(new SignalReceiver(csprintf("cnthpirq[%d]", i)));
96  cnthvirq.emplace_back(new SignalReceiver(csprintf("cnthvirq[%d]", i)));
97  cntpsirq.emplace_back(new SignalReceiver(csprintf("cntpsirq[%d]", i)));
98  cntvirq.emplace_back(new SignalReceiver(csprintf("cntvirq[%d]", i)));
99  commirq.emplace_back(new SignalReceiver(csprintf("commirq[%d]", i)));
100  ctidbgirq.emplace_back(
101  new SignalReceiver(csprintf("ctidbgirq[%d]", i)));
102  pmuirq.emplace_back(new SignalReceiver(csprintf("pmuirq[%d]", i)));
103  vcpumntirq.emplace_back(
104  new SignalReceiver(csprintf("vcpumntirq[%d]", i)));
105  cntpnsirq.emplace_back(
106  new SignalReceiver(csprintf("cntpnsirq[%d]", i)));
107  rvbaraddr.emplace_back(new SignalInitiator<uint64_t>(
108  csprintf("rvbaraddr[%d]", i).c_str()));
109  core_reset.emplace_back(
110  new SignalSender(csprintf("core_reset[%d]", i), 0));
111  poweron_reset.emplace_back(
112  new SignalSender(csprintf("poweron_reset[%d]", i), 0));
113 
114  Base::cnthpirq[i].bind(cnthpirq[i]->signal_in);
115  Base::cnthvirq[i].bind(cnthvirq[i]->signal_in);
116  Base::cntpsirq[i].bind(cntpsirq[i]->signal_in);
117  Base::cntvirq[i].bind(cntvirq[i]->signal_in);
118  Base::commirq[i].bind(commirq[i]->signal_in);
119  Base::ctidbgirq[i].bind(ctidbgirq[i]->signal_in);
120  Base::pmuirq[i].bind(pmuirq[i]->signal_in);
121  Base::vcpumntirq[i].bind(vcpumntirq[i]->signal_in);
122  Base::cntpnsirq[i].bind(cntpnsirq[i]->signal_in);
123  rvbaraddr[i]->bind(Base::rvbaraddr[i]);
124  core_reset[i]->signal_out.bind(Base::core_reset[i]);
125  poweron_reset[i]->signal_out.bind(Base::poweron_reset[i]);
126  }
127 
128  top_reset.signal_out.bind(Base::top_reset);
129  dbg_reset.signal_out.bind(Base::dbg_reset);
130 
131  clockRateControl.bind(this->clock_rate_s);
132  periphClockRateControl.bind(this->periph_clock_rate_s);
133 }
134 
135 template <class Types>
136 void
138 {
139  Base::before_end_of_elaboration();
140 
141  auto set_on_change = [this](
142  SignalReceiver &recv, ArmInterruptPinGen *gen, int num)
143  {
144  auto *pin = gen->get(gem5CpuCluster->getCore(num)->getContext(0));
145  auto handler = [pin](bool status)
146  {
147  status ? pin->raise() : pin->clear();
148  };
149  recv.onChange(handler);
150  };
151 
152  for (int i = 0; i < CoreCount; i++) {
153  set_on_change(*cnthpirq[i], gem5CpuCluster->params().cnthpirq, i);
154  set_on_change(*cnthvirq[i], gem5CpuCluster->params().cnthvirq, i);
155  set_on_change(*cntpsirq[i], gem5CpuCluster->params().cntpsirq, i);
156  set_on_change(*cntvirq[i], gem5CpuCluster->params().cntvirq, i);
157  set_on_change(*commirq[i], gem5CpuCluster->params().commirq, i);
158  set_on_change(*ctidbgirq[i], gem5CpuCluster->params().ctidbgirq, i);
159  set_on_change(*pmuirq[i], gem5CpuCluster->params().pmuirq, i);
160  set_on_change(*vcpumntirq[i], gem5CpuCluster->params().vcpumntirq, i);
161  set_on_change(*cntpnsirq[i], gem5CpuCluster->params().cntpnsirq, i);
162  }
163 }
164 
165 template <class Types>
166 Port &
167 ScxEvsCortexA76<Types>::gem5_getPort(const std::string &if_name, int idx)
168 {
169  if (if_name == "redistributor")
170  return *redist.at(idx);
171  else if (if_name == "core_reset")
172  return *core_reset.at(idx);
173  else if (if_name == "poweron_reset")
174  return *poweron_reset.at(idx);
175  else if (if_name == "amba")
176  return amba;
177  else if (if_name == "top_reset")
178  return top_reset;
179  else if (if_name == "dbg_reset")
180  return dbg_reset;
181  else if (if_name == "model_reset")
182  return model_reset;
183  else
184  return Base::gem5_getPort(if_name, idx);
185 }
186 
191 
192 } // namespace fastmodel
193 } // namespace gem5
cortex_a76.hh
gem5::fastmodel::ScxEvsCortexA76::rvbaraddr
std::vector< std::unique_ptr< SignalInitiator< uint64_t > > > rvbaraddr
Definition: evs.hh:93
gem5::fastmodel::ScxEvsCortexA76::cntpsirq
std::vector< std::unique_ptr< SignalReceiver > > cntpsirq
Definition: evs.hh:86
gem5::SignalSinkPort::onChange
void onChange(OnChangeFunc func)
Definition: signal.hh:74
gem5_to_tlm.hh
base_gic.hh
gem5::fastmodel::ScxEvsCortexA76::periphClockRateControl
ClockRateControlInitiatorSocket periphClockRateControl
Definition: evs.hh:71
gem5::fastmodel::ScxEvsCortexA76::setResetAddr
void setResetAddr(int core, Addr addr, bool secure) override
Definition: evs.cc:67
gem5::fastmodel::ScxEvsCortexA76::pmuirq
std::vector< std::unique_ptr< SignalReceiver > > pmuirq
Definition: evs.hh:90
gem5::fastmodel::ScxEvsCortexA76::cnthpirq
std::vector< std::unique_ptr< SignalReceiver > > cnthpirq
Definition: evs.hh:84
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:65
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:67
cpu.hh
gem5::fastmodel::ScxEvsCortexA76::commirq
std::vector< std::unique_ptr< SignalReceiver > > commirq
Definition: evs.hh:88
evs.hh
gem5::fastmodel::SignalSender
Definition: signal_sender.hh:44
gem5::fastmodel::ScxEvsCortexA76::top_reset
SignalSender top_reset
Definition: evs.hh:97
gem5::fastmodel::ScxEvsCortexA76::setCluster
void setCluster(SimObject *cluster) override
Definition: evs.cc:59
gem5::fastmodel::SignalSender::signal_out
amba_pv::signal_master_port< bool > signal_out
Definition: signal_sender.hh:47
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::fastmodel::ScxEvsCortexA76::cntpnsirq
std::vector< std::unique_ptr< SignalReceiver > > cntpnsirq
Definition: evs.hh:92
gem5::fastmodel::ScxEvsCortexA76::before_end_of_elaboration
void before_end_of_elaboration() override
Definition: evs.cc:137
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::fastmodel::ScxEvsCortexA76
Definition: evs.hh:61
gem5::fastmodel::ScxEvsCortexA76::CoreCount
static const int CoreCount
Definition: evs.hh:64
gem5::fastmodel::ScxEvsCortexA76::cntvirq
std::vector< std::unique_ptr< SignalReceiver > > cntvirq
Definition: evs.hh:87
sc_core::sc_module_name
Definition: sc_module_name.hh:41
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::fastmodel::ScxEvsCortexA76::poweron_reset
std::vector< std::unique_ptr< SignalSender > > poweron_reset
Definition: evs.hh:95
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
name
const std::string & name()
Definition: trace.cc:48
gem5::fastmodel::ScxEvsCortexA76::ScxEvsCortexA76
ScxEvsCortexA76(const Params &p)
Definition: evs.hh:108
gem5::fastmodel::ScxEvsCortexA76::setSysCounterFrq
void setSysCounterFrq(uint64_t sys_counter_frq) override
Definition: evs.cc:52
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: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:214
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:73
gem5::fastmodel::ScxEvsCortexA76::redist
std::vector< std::unique_ptr< TlmGicTarget > > redist
Definition: evs.hh:82
gem5::fastmodel::ScxEvsCortexA76::setClkPeriod
void setClkPeriod(Tick clk_period) override
Definition: evs.cc:45
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
gem5::fastmodel::ScxEvsCortexA76::model_reset
SignalSinkPort< bool > model_reset
Definition: evs.hh:101
gem5::fastmodel::ScxEvsCortexA76::Base
typename Types::Base Base
Definition: evs.hh:65
gem5::fastmodel::ScxEvsCortexA76::vcpumntirq
std::vector< std::unique_ptr< SignalReceiver > > vcpumntirq
Definition: evs.hh:91
core.hh
gem5::fastmodel::ScxEvsCortexA76::dbg_reset
SignalSender dbg_reset
Definition: evs.hh:99
gem5::fastmodel::ScxEvsCortexA76::clockRateControl
ClockRateControlInitiatorSocket clockRateControl
Definition: evs.hh:70
logging.hh
gem5::fastmodel::CortexA76Cluster
Definition: cortex_a76.hh:82
gem5::fastmodel::ScxEvsCortexA76::SignalInitiator
amba_pv::signal_master_port< T > SignalInitiator
Definition: evs.hh:79
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::fastmodel::ScxEvsCortexA76::Params
typename Types::Params Params
Definition: evs.hh:66
gem5::fastmodel::ScxEvsCortexA76::gem5_getPort
Port & gem5_getPort(const std::string &if_name, int idx) override
Definition: evs.cc:167
gem5::fastmodel::ScxEvsCortexA76::cnthvirq
std::vector< std::unique_ptr< SignalReceiver > > cnthvirq
Definition: evs.hh:85
gem5::fastmodel::ScxEvsCortexA76::core_reset
std::vector< std::unique_ptr< SignalSender > > core_reset
Definition: evs.hh:94
gem5::fastmodel::SignalReceiver
Definition: signal_receiver.hh:50
gem5::fastmodel::ScxEvsCortexA76::ctidbgirq
std::vector< std::unique_ptr< SignalReceiver > > ctidbgirq
Definition: evs.hh:89
gem5::ArmISA::status
Bitfield< 5, 0 > status
Definition: misc_types.hh:480
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84
gem5::ArmInterruptPinGen
This SimObject is instantiated in the python world and serves as an ArmInterruptPin generator.
Definition: base_gic.hh:144

Generated on Sun Jul 30 2023 01:56:47 for gem5 by doxygen 1.8.17