gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
37namespace gem5
38{
39
40namespace fastmodel
41{
42
43template <class Types>
44void
46{
47 clockRateControl->set_mul_div(sim_clock::as_int::s, clk_period);
48}
49
50template <class Types>
51void
53{
54 periphClockRateControl->set_mul_div(sys_counter_frq, 1);
55}
56
57template <class Types>
58void
60{
61 gem5CpuCluster = dynamic_cast<CortexA76Cluster *>(cluster);
62 panic_if(!gem5CpuCluster, "Cluster should be of type CortexA76Cluster");
63}
64
65template <class Types>
66void
68{
69 this->rvbaraddr[core]->set_state(0, addr);
70}
71
72template <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
135template <class Types>
136void
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
165template <class Types>
166Port &
167ScxEvsCortexA76<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
Base class for ARM GIC implementations.
This SimObject is instantiated in the python world and serves as an ArmInterruptPin generator.
Definition base_gic.hh:145
Ports are used to interface objects to each other.
Definition port.hh:62
void onChange(OnChangeFunc func)
Definition signal.hh:76
Abstract superclass for simulation objects.
std::vector< std::unique_ptr< SignalReceiver > > cntvirq
Definition evs.hh:87
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:73
typename Types::Base Base
Definition evs.hh:65
amba_pv::signal_master_port< T > SignalInitiator
Definition evs.hh:79
std::vector< std::unique_ptr< SignalReceiver > > cntpnsirq
Definition evs.hh:92
std::vector< std::unique_ptr< SignalReceiver > > pmuirq
Definition evs.hh:90
void setResetAddr(int core, Addr addr, bool secure) override
Definition evs.cc:67
std::vector< std::unique_ptr< SignalInitiator< uint64_t > > > rvbaraddr
Definition evs.hh:93
static const int CoreCount
Definition evs.hh:64
SignalSinkPort< bool > model_reset
Definition evs.hh:101
void setCluster(SimObject *cluster) override
Definition evs.cc:59
std::vector< std::unique_ptr< TlmGicTarget > > redist
Definition evs.hh:82
std::vector< std::unique_ptr< SignalSender > > poweron_reset
Definition evs.hh:95
std::vector< std::unique_ptr< SignalReceiver > > cnthpirq
Definition evs.hh:84
std::vector< std::unique_ptr< SignalReceiver > > ctidbgirq
Definition evs.hh:89
std::vector< std::unique_ptr< SignalSender > > core_reset
Definition evs.hh:94
std::vector< std::unique_ptr< SignalReceiver > > cnthvirq
Definition evs.hh:85
void before_end_of_elaboration() override
Definition evs.cc:137
typename Types::Params Params
Definition evs.hh:66
ClockRateControlInitiatorSocket clockRateControl
Definition evs.hh:70
ClockRateControlInitiatorSocket periphClockRateControl
Definition evs.hh:71
ScxEvsCortexA76(const Params &p)
Definition evs.hh:108
void setClkPeriod(Tick clk_period) override
Definition evs.cc:45
std::vector< std::unique_ptr< SignalReceiver > > cntpsirq
Definition evs.hh:86
std::vector< std::unique_ptr< SignalReceiver > > vcpumntirq
Definition evs.hh:91
std::vector< std::unique_ptr< SignalReceiver > > commirq
Definition evs.hh:88
Port & gem5_getPort(const std::string &if_name, int idx) override
Definition evs.cc:167
void setSysCounterFrq(uint64_t sys_counter_frq) override
Definition evs.cc:52
void onChange(OnChangeFunc func)
amba_pv::signal_master_port< bool > signal_out
virtual void bind(base_target_socket_type &s)
#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
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 5, 0 > status
Bitfield< 0 > p
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58
std::string csprintf(const char *format, const Args &...args)
Definition cprintf.hh:161
const std::string & name()
Definition trace.cc:48

Generated on Tue Jun 18 2024 16:23:55 for gem5 by doxygen 1.11.0