gem5 v24.0.0.0
Loading...
Searching...
No Matches
evs.cc
Go to the documentation of this file.
1/*
2 * Copyright 2020 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 "sim/core.hh"
35
36namespace gem5
37{
38
39namespace fastmodel
40{
41
42template <class Types>
43void
45{
46 clockRateControl->set_mul_div(sim_clock::as_int::s, clk_period);
47}
48
49template <class Types>
50void
52{
53 panic("Not implemented for R52.");
54}
55
56template <class Types>
57void
59{
60 gem5CpuCluster = dynamic_cast<CortexR52Cluster *>(cluster);
61 panic_if(!gem5CpuCluster, "Cluster should be of type CortexR52Cluster");
62}
63
64template <class Types>
65void
67{
68 this->corePins[core]->cfgvectable.set_state(0, addr);
69}
70
71template <class Types>
73 name(csprintf("%s.cpu%s", _evs->name(), _cpu)),
74 evs(_evs), cpu(_cpu),
75 llpp(evs->llpp[cpu], name + ".llpp", -1),
76 flash(evs->flash[cpu], name + ".flash", -1),
77 amba(evs->amba[cpu], name + ".amba", -1),
78 core_reset(name + ".core_reset", 0),
79 poweron_reset(name + ".poweron_reset", 0),
80 halt(name + ".halt", 0),
81 standbywfi(name + ".standbywfi"),
82 cfgvectable((name + "cfgvectable").c_str())
83{
84 for (int i = 0; i < Evs::PpiCount; i++) {
85 ppis.emplace_back(
86 new CoreInt(csprintf("%s.ppi[%d]", name, i), i, this));
87 }
88 core_reset.signal_out.bind(evs->core_reset[cpu]);
89 poweron_reset.signal_out.bind(evs->poweron_reset[cpu]);
90 halt.signal_out.bind(evs->halt[cpu]);
91 evs->standbywfi[cpu].bind(standbywfi.signal_in);
92 cfgvectable.bind(evs->cfgvectable[cpu]);
93}
94
95
96template <class Types>
98 const sc_core::sc_module_name &mod_name, const Params &p) :
99 Base(mod_name),
100 ext_slave(Base::ext_slave, p.name + ".ext_slave", -1),
101 top_reset(p.name + ".top_reset", 0),
102 dbg_reset(p.name + ".dbg_reset", 0),
103 model_reset(p.name + ".model_reset"),
104 params(p)
105{
106 model_reset.onChange([this](const bool &new_val) {
107 // Set reset for all cores.
108 for (auto &core_pin : corePins)
109 core_pin->poweron_reset.signal_out.set_state(0, new_val);
110 // Set reset for L2 system.
111 top_reset.signal_out.set_state(0, new_val);
112 // Set reset for debug APB.
113 dbg_reset.signal_out.set_state(0, new_val);
114 });
115
116 for (int i = 0; i < CoreCount; i++)
117 corePins.emplace_back(new CorePins(this, i));
118
119 for (int i = 0; i < SpiCount; i++) {
120 spis.emplace_back(
121 new ClstrInt(csprintf("%s.spi[%d]", name(), i), i, this));
122 }
123
124 top_reset.signal_out.bind(Base::top_reset);
125 dbg_reset.signal_out.bind(Base::dbg_reset);
126
127 clockRateControl.bind(this->clock_rate_s);
128 signalInterrupt.bind(this->signal_interrupt);
129}
130
131template <class Types>
132Port &
133ScxEvsCortexR52<Types>::gem5_getPort(const std::string &if_name, int idx)
134{
135 if (if_name == "llpp") {
136 return this->corePins.at(idx)->llpp;
137 } else if (if_name == "flash") {
138 return this->corePins.at(idx)->flash;
139 } else if (if_name == "amba") {
140 return this->corePins.at(idx)->amba;
141 } else if (if_name == "core_reset") {
142 return this->corePins.at(idx)->core_reset;
143 } else if (if_name == "poweron_reset") {
144 return this->corePins.at(idx)->poweron_reset;
145 } else if (if_name == "halt") {
146 return this->corePins.at(idx)->halt;
147 } else if (if_name == "ext_slave") {
148 return this->ext_slave;
149 } else if (if_name == "top_reset") {
150 return this->top_reset;
151 } else if (if_name == "dbg_reset") {
152 return this->dbg_reset;
153 } else if (if_name == "model_reset") {
154 return this->model_reset;
155 } else if (if_name == "spi") {
156 return *this->spis.at(idx);
157 } else if (if_name.substr(0, 3) == "ppi") {
158 int cpu;
159 try {
160 cpu = std::stoi(if_name.substr(4));
161 } catch (const std::invalid_argument &a) {
162 panic("Couldn't find CPU number in %s.", if_name);
163 }
164 return *this->corePins.at(cpu)->ppis.at(idx);
165 } else if (if_name.substr(0, 10) == "standbywfi") {
166 int cpu;
167 try {
168 cpu = std::stoi(if_name.substr(11));
169 } catch (const std::invalid_argument &a) {
170 panic("Couldn't find CPU number in %s.", if_name);
171 }
172 return this->corePins.at(cpu)->standbywfi.getSignalOut(idx);
173 } else {
174 return Base::gem5_getPort(if_name, idx);
175 }
176}
177
182
183} // namespace fastmodel
184} // namespace gem5
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.
IntSinkPin< ScxEvsCortexR52 > ClstrInt
Definition evs.hh:119
static const int SpiCount
Definition evs.hh:68
void setSysCounterFrq(uint64_t sys_counter_frq) override
Definition evs.cc:51
static const int PpiCount
Definition evs.hh:67
SignalSinkPort< bool > model_reset
Definition evs.hh:129
std::vector< std::unique_ptr< ClstrInt > > spis
Definition evs.hh:121
typename Types::Base Base
Definition evs.hh:69
Port & gem5_getPort(const std::string &if_name, int idx) override
Definition evs.cc:133
void setCluster(SimObject *cluster) override
Definition evs.cc:58
void setClkPeriod(Tick clk_period) override
Definition evs.cc:44
std::vector< std::unique_ptr< CorePins > > corePins
Definition evs.hh:117
SignalInterruptInitiatorSocket signalInterrupt
Definition evs.hh:76
typename Types::Params Params
Definition evs.hh:70
void setResetAddr(int core, Addr addr, bool secure) override
Definition evs.cc:66
static const int CoreCount
Definition evs.hh:66
ScxEvsCortexR52(const Params &p)
Definition evs.hh:136
ClockRateControlInitiatorSocket clockRateControl
Definition evs.hh:75
amba_pv::signal_slave_export< bool > signal_in
amba_pv::signal_master_port< bool > signal_out
virtual void bind(base_target_socket_type &s)
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
#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< 8 > a
Definition misc_types.hh:66
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
IntSinkPin< CorePins > CoreInt
Definition evs.hh:81
std::vector< std::unique_ptr< CoreInt > > ppis
Definition evs.hh:103
SignalInitiator< uint64_t > cfgvectable
Definition evs.hh:114
const std::string & name()
Definition trace.cc:48

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