gem5 v24.0.0.0
Loading...
Searching...
No Matches
pl330.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
30#include <cctype>
31
32#include "params/FastModelPL330.hh"
33#include "sim/core.hh"
34
35namespace gem5
36{
37
38namespace fastmodel
39{
40
41PL330::PL330(const FastModelPL330Params &params,
43 scx_evs_PL330(_name), clockPeriod(params.clock),
44 dma(amba_m, params.name + ".dma", -1),
45 pioS(amba_s, params.name + ".pio_s", -1),
46 pioNs(amba_s_ns, params.name + ".pio_ns", -1),
47 irqAbortReceiver("irq_abort_receiver"),
48 resetIn("reset_in", 0)
49{
50 set_parameter("pl330.fifo_size", params.fifo_size);
51 set_parameter("pl330.max_transfer", params.max_transfer);
52 set_parameter("pl330.generate_clear", params.generate_clear);
53 set_parameter("pl330.activate_delay", params.activate_delay);
54 set_parameter("pl330.revision", params.revision);
55 set_parameter("pl330.p_max_irqs", params.max_irqs);
56 set_parameter("pl330.p_buffer_depth", params.buffer_depth);
57 set_parameter("pl330.p_lsq_read_size", params.lsq_read_size);
58 set_parameter("pl330.p_lsq_write_size", params.lsq_write_size);
59 set_parameter("pl330.p_read_issuing_capability",
60 params.read_issuing_capability);
61 set_parameter("pl330.p_write_issuing_capability",
62 params.write_issuing_capability);
63 set_parameter("pl330.p_axi_bus_width_param", params.axi_bus_width);
64 set_parameter("pl330.p_cache_line_words", params.cache_line_words);
65 set_parameter("pl330.p_cache_lines", params.cache_lines);
66 set_parameter("pl330.p_max_channels", params.max_channels);
67 set_parameter("pl330.p_controller_nsecure", params.controller_nsecure);
68 set_parameter("pl330.p_irq_nsecure", params.irq_nsecure);
69 set_parameter("pl330.p_periph_nsecure", params.periph_nsecure);
70 set_parameter("pl330.p_controller_boots", params.controller_boots);
71 set_parameter("pl330.p_reset_pc", params.reset_pc);
72 set_parameter("pl330.p_max_periph", params.max_periph);
73 set_parameter("pl330.p_perip_request_acceptance_0",
74 params.perip_request_acceptance_0);
75 set_parameter("pl330.p_perip_request_acceptance_1",
76 params.perip_request_acceptance_1);
77 set_parameter("pl330.p_perip_request_acceptance_2",
78 params.perip_request_acceptance_2);
79 set_parameter("pl330.p_perip_request_acceptance_3",
80 params.perip_request_acceptance_3);
81 set_parameter("pl330.p_perip_request_acceptance_4",
82 params.perip_request_acceptance_4);
83 set_parameter("pl330.p_perip_request_acceptance_5",
84 params.perip_request_acceptance_5);
85 set_parameter("pl330.p_perip_request_acceptance_6",
86 params.perip_request_acceptance_6);
87 set_parameter("pl330.p_perip_request_acceptance_7",
88 params.perip_request_acceptance_7);
89 set_parameter("pl330.p_perip_request_acceptance_8",
90 params.perip_request_acceptance_8);
91 set_parameter("pl330.p_perip_request_acceptance_9",
92 params.perip_request_acceptance_9);
93 set_parameter("pl330.p_perip_request_acceptance_10",
94 params.perip_request_acceptance_10);
95 set_parameter("pl330.p_perip_request_acceptance_11",
96 params.perip_request_acceptance_11);
97 set_parameter("pl330.p_perip_request_acceptance_12",
98 params.perip_request_acceptance_12);
99 set_parameter("pl330.p_perip_request_acceptance_13",
100 params.perip_request_acceptance_13);
101 set_parameter("pl330.p_perip_request_acceptance_14",
102 params.perip_request_acceptance_14);
103 set_parameter("pl330.p_perip_request_acceptance_15",
104 params.perip_request_acceptance_15);
105 set_parameter("pl330.p_perip_request_acceptance_16",
106 params.perip_request_acceptance_16);
107 set_parameter("pl330.p_perip_request_acceptance_17",
108 params.perip_request_acceptance_17);
109 set_parameter("pl330.p_perip_request_acceptance_18",
110 params.perip_request_acceptance_18);
111 set_parameter("pl330.p_perip_request_acceptance_19",
112 params.perip_request_acceptance_19);
113 set_parameter("pl330.p_perip_request_acceptance_20",
114 params.perip_request_acceptance_20);
115 set_parameter("pl330.p_perip_request_acceptance_21",
116 params.perip_request_acceptance_21);
117 set_parameter("pl330.p_perip_request_acceptance_22",
118 params.perip_request_acceptance_22);
119 set_parameter("pl330.p_perip_request_acceptance_23",
120 params.perip_request_acceptance_23);
121 set_parameter("pl330.p_perip_request_acceptance_24",
122 params.perip_request_acceptance_24);
123 set_parameter("pl330.p_perip_request_acceptance_25",
124 params.perip_request_acceptance_25);
125 set_parameter("pl330.p_perip_request_acceptance_26",
126 params.perip_request_acceptance_26);
127 set_parameter("pl330.p_perip_request_acceptance_27",
128 params.perip_request_acceptance_27);
129 set_parameter("pl330.p_perip_request_acceptance_28",
130 params.perip_request_acceptance_28);
131 set_parameter("pl330.p_perip_request_acceptance_29",
132 params.perip_request_acceptance_29);
133 set_parameter("pl330.p_perip_request_acceptance_30",
134 params.perip_request_acceptance_30);
135 set_parameter("pl330.p_perip_request_acceptance_31",
136 params.perip_request_acceptance_31);
137
138 // Plumb up the mechanism which lets us set the clock rate inside the EVS.
139 clockRateControl.bind(this->clock_rate_s);
140
141 // Allocate all the source pins for each interrupt port.
142 allocateIrq(0, params.port_irq_0_connection_count);
143 allocateIrq(1, params.port_irq_1_connection_count);
144 allocateIrq(2, params.port_irq_2_connection_count);
145 allocateIrq(3, params.port_irq_3_connection_count);
146 allocateIrq(4, params.port_irq_4_connection_count);
147 allocateIrq(5, params.port_irq_5_connection_count);
148 allocateIrq(6, params.port_irq_6_connection_count);
149 allocateIrq(7, params.port_irq_7_connection_count);
150 allocateIrq(8, params.port_irq_8_connection_count);
151 allocateIrq(9, params.port_irq_9_connection_count);
152 allocateIrq(10, params.port_irq_10_connection_count);
153 allocateIrq(11, params.port_irq_11_connection_count);
154 allocateIrq(12, params.port_irq_12_connection_count);
155 allocateIrq(13, params.port_irq_13_connection_count);
156 allocateIrq(14, params.port_irq_14_connection_count);
157 allocateIrq(15, params.port_irq_15_connection_count);
158 allocateIrq(16, params.port_irq_16_connection_count);
159 allocateIrq(17, params.port_irq_17_connection_count);
160 allocateIrq(18, params.port_irq_18_connection_count);
161 allocateIrq(19, params.port_irq_19_connection_count);
162 allocateIrq(20, params.port_irq_20_connection_count);
163 allocateIrq(21, params.port_irq_21_connection_count);
164 allocateIrq(22, params.port_irq_22_connection_count);
165 allocateIrq(23, params.port_irq_23_connection_count);
166 allocateIrq(24, params.port_irq_24_connection_count);
167 allocateIrq(25, params.port_irq_25_connection_count);
168 allocateIrq(26, params.port_irq_26_connection_count);
169 allocateIrq(27, params.port_irq_27_connection_count);
170 allocateIrq(28, params.port_irq_28_connection_count);
171 allocateIrq(29, params.port_irq_29_connection_count);
172 allocateIrq(30, params.port_irq_30_connection_count);
173 allocateIrq(31, params.port_irq_31_connection_count);
174
175 // Plumb the interrupts from inside the EVS to any external sinks.
176 for (int i = 0; i < 32; i++) {
177 // Create a receiver to receive interrupts from the EVS.
178 irqReceiver.emplace_back(
179 new SignalReceiver(csprintf("irq_receiver[%d]", i)));
180
181 // Attach the receiver to the socket coming out of the EVS.
182 irq[i].bind(irqReceiver[i]->signal_in);
183
184 // Set up a handler for when the signal changes state.
185 auto on_change = [&port = irqPort[i]](bool status)
186 {
187 // Loop through all the connections and propogate the signal.
188 for (auto &pin: port)
189 status ? pin->raise() : pin->lower();
190 };
191
192 // Install the handler.
193 irqReceiver[i]->onChange(on_change);
194 }
195
196 // Set up the abort IRQ pins.
197 for (int i = 0; i < params.port_irq_abort_connection_count; i++) {
198 irqAbortPort.emplace_back(new IntSourcePin<PL330>(
199 csprintf("%s.irq_abort_master_port[%d]", name(), i),
200 i, this));
201 }
202
203 // Attach the receiver (already set up) to the EVS.
204 irq_abort.bind(irqAbortReceiver.signal_in);
205
206 // Set up a handler.
207 auto abort_change = [this](bool status) {
208 for (auto &pin: irqAbortPort)
209 status ? pin->raise() : pin->lower();
210 };
211
212 // And install it.
213 irqAbortReceiver.onChange(abort_change);
214
215 // Plumb the reset signal.
216 resetIn.signal_out.bind(this->reset_in);
217}
218
219void
221{
222 for (int i = 0; i < count; i++) {
223 irqPort[idx].emplace_back(new IntSourcePin<PL330>(
224 csprintf("%s.irq_master_port[%d][%d]", name(), idx, i),
225 i, this));
226 }
227}
228
230PL330::gem5_getPort(const std::string &if_name, int idx)
231{
232 if (if_name == "dma") {
233 return dma;
234 } else if (if_name == "pio_s") {
235 return pioS;
236 } else if (if_name == "pio_ns") {
237 return pioNs;
238 } else if (if_name.substr(0, 4) == "irq_") {
239 auto suffix = if_name.substr(4);
240
241 if (suffix == "abort")
242 return *irqAbortPort.at(idx);
243
244 // Existing functions like stoull, and to_number which uses it, skip
245 // leading whitespace and ignore non-numeric characters at the end of
246 // the string. We're going to be more picky than that.
247 int port = -1;
248 if (suffix.size() == 1 && isdigit(suffix[0])) {
249 port = suffix[0] - '0';
250 } else if (suffix.size() == 2 && isdigit(suffix[0]) &&
251 isdigit(suffix[1])) {
252 port = (suffix[0] - '0') * 10 + (suffix[1] - '0');
253 }
254 if (port != -1 && port < irqPort.size())
255 return *irqPort[port].at(idx);
256 } else if (if_name == "reset_in") {
257 return resetIn;
258 }
259
260 return scx_evs_PL330::gem5_getPort(if_name, idx);
261}
262
263void
265{
266 // Set the clock rate using the divider inside the EVS.
268}
269
270} // namespace fastmodel
271} // namespace gem5
Ports are used to interface objects to each other.
Definition port.hh:62
std::vector< std::unique_ptr< IntSource > > irqAbortPort
Definition pl330.hh:71
gem5::Port & gem5_getPort(const std::string &if_name, int idx=-1) override
Definition pl330.cc:230
std::array< std::vector< std::unique_ptr< IntSource > >, 32 > irqPort
Definition pl330.hh:68
ClockRateControlInitiatorSocket clockRateControl
Definition pl330.hh:64
AmbaTarget pioNs
Definition pl330.hh:62
SignalSender resetIn
Definition pl330.hh:76
std::vector< std::unique_ptr< SignalReceiver > > irqReceiver
Definition pl330.hh:69
PL330(const FastModelPL330Params &params, sc_core::sc_module_name _name)
Definition pl330.cc:41
AmbaInitiator dma
Definition pl330.hh:61
void allocateIrq(int idx, int count)
Definition pl330.cc:220
AmbaTarget pioS
Definition pl330.hh:62
void start_of_simulation() override
Definition pl330.cc:264
SignalReceiver irqAbortReceiver
Definition pl330.hh:72
amba_pv::signal_slave_export< bool > signal_in
void onChange(OnChangeFunc func)
amba_pv::signal_master_port< bool > signal_out
virtual void bind(base_target_socket_type &s)
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 35, 32 > at
Bitfield< 5, 0 > status
Bitfield< 1 > irq
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
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