gem5  v22.1.0.0
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 
36 namespace gem5
37 {
38 
39 GEM5_DEPRECATED_NAMESPACE(FastModel, fastmodel);
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  panic("Not implemented for R52.");
55 }
56 
57 template <class Types>
58 void
60 {
61  gem5CpuCluster = dynamic_cast<CortexR52Cluster *>(cluster);
62  panic_if(!gem5CpuCluster, "Cluster should be of type CortexR52Cluster");
63 }
64 
65 template <class Types>
66 void
68 {
69  this->corePins[core]->cfgvectable.set_state(0, addr);
70 }
71 
72 template <class Types>
74  name(csprintf("%s.cpu%s", _evs->name(), _cpu)),
75  evs(_evs), cpu(_cpu),
76  llpp(evs->llpp[cpu], name + ".llpp", -1),
77  flash(evs->flash[cpu], name + ".flash", -1),
78  amba(evs->amba[cpu], name + ".amba", -1),
79  core_reset(name + ".core_reset", 0),
80  poweron_reset(name + ".poweron_reset", 0),
81  halt(name + ".halt", 0),
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  cfgvectable.bind(evs->cfgvectable[cpu]);
92 }
93 
94 
95 template <class Types>
97  const sc_core::sc_module_name &mod_name, const Params &p) :
98  Base(mod_name),
99  ext_slave(Base::ext_slave, p.name + ".ext_slave", -1),
100  top_reset(p.name + ".top_reset", 0),
101  dbg_reset(p.name + ".dbg_reset", 0),
102  model_reset(p.name + ".model_reset", -1, this),
103  params(p)
104 {
105  for (int i = 0; i < CoreCount; i++)
106  corePins.emplace_back(new CorePins(this, i));
107 
108  for (int i = 0; i < SpiCount; i++) {
109  spis.emplace_back(
110  new ClstrInt(csprintf("%s.spi[%d]", name(), i), i, this));
111  }
112 
113  top_reset.signal_out.bind(Base::top_reset);
114  dbg_reset.signal_out.bind(Base::dbg_reset);
115 
116  clockRateControl.bind(this->clock_rate_s);
117  signalInterrupt.bind(this->signal_interrupt);
118 }
119 
120 template <class Types>
121 void
123 {
124  auto *trans = sc_gem5::packet2payload(pkt);
125  panic_if(Base::amba[0]->transport_dbg(*trans) != trans->get_data_length(),
126  "Didn't send entire functional packet!");
127  trans->release();
128 }
129 
130 template <class Types>
131 Port &
132 ScxEvsCortexR52<Types>::gem5_getPort(const std::string &if_name, int idx)
133 {
134  if (if_name == "llpp") {
135  return this->corePins.at(idx)->llpp;
136  } else if (if_name == "flash") {
137  return this->corePins.at(idx)->flash;
138  } else if (if_name == "amba") {
139  return this->corePins.at(idx)->amba;
140  } else if (if_name == "core_reset") {
141  return this->corePins.at(idx)->core_reset;
142  } else if (if_name == "poweron_reset") {
143  return this->corePins.at(idx)->poweron_reset;
144  } else if (if_name == "halt") {
145  return this->corePins.at(idx)->halt;
146  } else if (if_name == "ext_slave") {
147  return this->ext_slave;
148  } else if (if_name == "top_reset") {
149  return this->top_reset;
150  } else if (if_name == "dbg_reset") {
151  return this->dbg_reset;
152  } else if (if_name == "model_reset") {
153  return this->model_reset;
154  } else if (if_name == "spi") {
155  return *this->spis.at(idx);
156  } else if (if_name.substr(0, 3) == "ppi") {
157  int cpu;
158  try {
159  cpu = std::stoi(if_name.substr(4));
160  } catch (const std::invalid_argument &a) {
161  panic("Couldn't find CPU number in %s.", if_name);
162  }
163  return *this->corePins.at(cpu)->ppis.at(idx);
164  } else {
165  return Base::gem5_getPort(if_name, idx);
166  }
167 }
168 
173 
174 } // namespace fastmodel
175 } // namespace gem5
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
Ports are used to interface objects to each other.
Definition: port.hh:62
Abstract superclass for simulation objects.
Definition: sim_object.hh:148
IntSinkPin< ScxEvsCortexR52 > ClstrInt
Definition: evs.hh:119
static const int SpiCount
Definition: evs.hh:69
void setSysCounterFrq(uint64_t sys_counter_frq) override
Definition: evs.cc:52
static const int PpiCount
Definition: evs.hh:68
std::vector< std::unique_ptr< ClstrInt > > spis
Definition: evs.hh:121
typename Types::Base Base
Definition: evs.hh:70
Port & gem5_getPort(const std::string &if_name, int idx) override
Definition: evs.cc:132
void setCluster(SimObject *cluster) override
Definition: evs.cc:59
void setClkPeriod(Tick clk_period) override
Definition: evs.cc:45
std::vector< std::unique_ptr< CorePins > > corePins
Definition: evs.hh:117
void sendFunc(PacketPtr pkt) override
Definition: evs.cc:122
SignalInterruptInitiatorSocket signalInterrupt
Definition: evs.hh:77
typename Types::Params Params
Definition: evs.hh:71
ResetResponsePort< ScxEvsCortexR52 > model_reset
Definition: evs.hh:129
void setResetAddr(int core, Addr addr, bool secure) override
Definition: evs.cc:67
static const int CoreCount
Definition: evs.hh:67
ScxEvsCortexR52(const Params &p)
Definition: evs.hh:136
ClockRateControlInitiatorSocket clockRateControl
Definition: evs.hh:76
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:178
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:204
Bitfield< 7 > i
Definition: misc_types.hh:67
Bitfield< 8 > a
Definition: misc_types.hh:66
Bitfield< 26 > halt
Definition: dt_constants.hh:47
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 3 > addr
Definition: types.hh:84
Tick s
second
Definition: core.cc:68
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
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
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
tlm::tlm_generic_payload * packet2payload(PacketPtr packet)
Convert a gem5 packet to TLM payload by copying all the relevant information to new payload.
Definition: gem5_to_tlm.cc:131
IntSinkPin< CorePins > CoreInt
Definition: evs.hh:82
std::vector< std::unique_ptr< CoreInt > > ppis
Definition: evs.hh:104
SignalInitiator< uint64_t > cfgvectable
Definition: evs.hh:114
CorePins(Evs *_evs, int _cpu)
Definition: evs.cc:73
const std::string & name()
Definition: trace.cc:49

Generated on Wed Dec 21 2022 10:22:24 for gem5 by doxygen 1.9.1