gem5  v21.0.1.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 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 FastModel
37 {
38 
39 template <class Types>
40 void
42 {
43  clockRateControl->set_mul_div(SimClock::Int::s, clk_period);
44 }
45 
46 template <class Types>
47 void
49 {
50  panic("Not implemented for R52.");
51 }
52 
53 template <class Types>
54 void
56 {
57  gem5CpuCluster = dynamic_cast<CortexR52Cluster *>(cluster);
58  panic_if(!gem5CpuCluster, "Cluster should be of type CortexR52Cluster");
59 }
60 
61 template <class Types>
63  name(csprintf("%s.cpu%s", _evs->name(), _cpu)),
64  evs(_evs), cpu(_cpu),
65  llpp(evs->llpp[cpu], name + ".llpp", -1),
66  flash(evs->flash[cpu], name + ".flash", -1),
67  amba(evs->amba[cpu], name + ".amba", -1)
68 {
69  for (int i = 0; i < Evs::PpiCount; i++) {
70  ppis.emplace_back(
71  new CoreInt(csprintf("%s.ppi[%d]", name, i), i, this));
72  }
73 }
74 
75 
76 template <class Types>
78  const sc_core::sc_module_name &mod_name, const Params &p) :
79  Base(mod_name),
80  params(p)
81 {
82  for (int i = 0; i < CoreCount; i++)
83  corePins.emplace_back(new CorePins(this, i));
84 
85  for (int i = 0; i < SpiCount; i++) {
86  spis.emplace_back(
87  new ClstrInt(csprintf("%s.spi[%d]", name(), i), i, this));
88  }
89 
90  clockRateControl.bind(this->clock_rate_s);
91  signalInterrupt.bind(this->signal_interrupt);
92 }
93 
94 template <class Types>
95 void
97 {
98  auto *trans = sc_gem5::packet2payload(pkt);
99  panic_if(Base::amba[0]->transport_dbg(*trans) != trans->get_data_length(),
100  "Didn't send entire functional packet!");
101  trans->release();
102 }
103 
104 template <class Types>
105 Port &
106 ScxEvsCortexR52<Types>::gem5_getPort(const std::string &if_name, int idx)
107 {
108  if (if_name == "llpp") {
109  return this->corePins.at(idx)->llpp;
110  } else if (if_name == "flash") {
111  return this->corePins.at(idx)->flash;
112  } else if (if_name == "amba") {
113  return this->corePins.at(idx)->amba;
114  } else if (if_name == "spi") {
115  return *this->spis.at(idx);
116  } else if (if_name.substr(0, 3) == "ppi") {
117  int cpu;
118  try {
119  cpu = std::stoi(if_name.substr(4));
120  } catch (const std::invalid_argument &a) {
121  panic("Couldn't find CPU number in %s.", if_name);
122  }
123  return *this->corePins.at(cpu)->ppis.at(idx);
124  } else {
125  return Base::gem5_getPort(if_name, idx);
126  }
127 }
128 
133 
134 } // namespace FastModel
FastModel::ScxEvsCortexR52::CorePins::name
std::string name
Definition: evs.hh:78
FastModel::ScxEvsCortexR52::clockRateControl
ClockRateControlInitiatorSocket clockRateControl
Definition: evs.hh:70
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
FastModel::ScxEvsCortexR52::SpiCount
static const int SpiCount
Definition: evs.hh:63
gem5_to_tlm.hh
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:104
FastModel::ScxEvsCortexR52::setSysCounterFrq
void setSysCounterFrq(uint64_t sys_counter_frq) override
Definition: evs.cc:48
FastModel::ScxEvsCortexR52::ClstrInt
IntSinkPin< ScxEvsCortexR52 > ClstrInt
Definition: evs.hh:105
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:59
FastModel::ScxEvsCortexR52::setClkPeriod
void setClkPeriod(Tick clk_period) override
Definition: evs.cc:41
FastModel::ScxEvsCortexR52::CorePins
Definition: evs.hh:74
FastModel::ScxEvsCortexR52::CorePins::ppis
std::vector< std::unique_ptr< CoreInt > > ppis
Definition: evs.hh:96
FastModel::ScxEvsCortexR52::Params
typename Types::Params Params
Definition: evs.hh:65
FastModel::ScxEvsCortexR52::setCluster
void setCluster(SimObject *cluster) override
Definition: evs.cc:55
FastModel::ScxEvsCortexR52::CorePins::CorePins
CorePins(Evs *_evs, int _cpu)
Definition: evs.cc:62
cpu.hh
FastModel::ScxEvsCortexR52::ScxEvsCortexR52
ScxEvsCortexR52(const Params &p)
Definition: evs.hh:114
FastModel::ScxEvsCortexR52::PpiCount
static const int PpiCount
Definition: evs.hh:62
FastModel::ScxEvsCortexR52::signalInterrupt
SignalInterruptInitiatorSocket signalInterrupt
Definition: evs.hh:71
ArmISA::a
Bitfield< 8 > a
Definition: miscregs_types.hh:62
FastModel::ScxEvsCortexR52
Definition: evs.hh:58
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
FastModel::ScxEvsCortexR52::sendFunc
void sendFunc(PacketPtr pkt) override
Definition: evs.cc:96
SimClock::Int::s
Tick s
second
Definition: core.cc:59
FastModel::ScxEvsCortexR52::Base
typename Types::Base Base
Definition: evs.hh:64
FastModel::ScxEvsCortexR52::gem5_getPort
Port & gem5_getPort(const std::string &if_name, int idx) override
Definition: evs.cc:106
sc_core::sc_module_name
Definition: sc_module_name.hh:41
cortex_r52.hh
core.hh
name
const std::string & name()
Definition: trace.cc:48
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:197
FastModel
Definition: amba_from_tlm_bridge.cc:32
tlm::tlm_base_initiator_socket::bind
virtual void bind(base_target_socket_type &s)
Definition: initiator_socket.hh:121
evs.hh
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:258
FastModel::ScxEvsCortexR52::spis
std::vector< std::unique_ptr< ClstrInt > > spis
Definition: evs.hh:107
logging.hh
FastModel::CortexR52Cluster
Definition: cortex_r52.hh:75
FastModel::ScxEvsCortexR52::corePins
std::vector< std::unique_ptr< CorePins > > corePins
Definition: evs.hh:103
FastModel::ScxEvsCortexR52::params
const Params & params
Definition: evs.hh:111
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
FastModel::ScxEvsCortexR52::CorePins::CoreInt
IntSinkPin< CorePins > CoreInt
Definition: evs.hh:76
FastModel::ScxEvsCortexR52::CoreCount
static const int CoreCount
Definition: evs.hh:61
csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:158
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:141

Generated on Tue Jun 22 2021 15:28:19 for gem5 by doxygen 1.8.17