gem5 v23.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
plic.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Huawei International
3 * Copyright (c) 2023 Google LLC
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder. You may use the software subject to the license
11 * terms below provided that you ensure that this notice is replicated
12 * unmodified and in its entirety in all distributions of the software,
13 * modified or unmodified, in source code or in binary form.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are
17 * met: redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer;
19 * redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution;
22 * neither the name of the copyright holders nor the names of its
23 * contributors may be used to endorse or promote products derived from
24 * this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#ifndef __DEV_RISCV_PLIC_HH__
40#define __DEV_RISCV_PLIC_HH__
41
42#include <bitset>
43#include <map>
44
46#include "dev/io_device.hh"
47#include "dev/reg_bank.hh"
48#include "mem/packet.hh"
49#include "mem/packet_access.hh"
50#include "params/Plic.hh"
51#include "params/PlicBase.hh"
52#include "sim/system.hh"
53
54namespace gem5
55{
56
57using namespace RiscvISA;
94{
97};
98
100{
101 public:
102 typedef PlicBaseParams Params;
104 BasicPioDevice(params, params.pio_size)
105 {}
106
107 // Interrupt interface to send signal to PLIC
108 virtual void post(int src_id) = 0;
109 // Interrupt interface to clear signal to PLIC
110 virtual void clear(int src_id) = 0;
111};
112
113class Plic : public PlicBase
114{
115 // Params
116 protected:
118
119 // Number of interrupt sources
120 int nSrc;
134
135 public:
136 typedef PlicParams Params;
137 Plic(const Params &params);
138
139 // External API
140 public:
144 void post(int src_id) override;
145 void clear(int src_id) override;
146
150 void init() override;
151 void serialize(CheckpointOut &cp) const override;
152 void unserialize(CheckpointIn &cp) override;
153
154 protected:
158 Tick read(PacketPtr pkt) override;
159 Tick write(PacketPtr pkt) override;
160
161 // Register bank
162 private:
163
204 {
205 public:
206 const Addr pendingStart = 0x1000;
207 const Addr enableStart = 0x2000;
208 const Addr thresholdStart = 0x0200000;
209 const Addr enablePadding = 0x80;
210 const Addr thresholdPadding = 0x1000;
211 const Addr maxBankSize = 0x4000000;
212
213
222
223 PlicRegisters(const std::string &name, Addr base, Plic* plic) :
225 plic(plic) {}
226
228
229 void init();
230
232
234
238 void writePriority(Register32& reg, const uint32_t& data,
239 const int src_id);
240
241 void writeEnable(Register32& reg, const uint32_t& data,
242 const int src32_id, const int context_id);
243
244 void writeThreshold(Register32& reg, const uint32_t& data,
245 const int context_id);
246
247 uint32_t readClaim(Register32& reg, const int context_id);
248
249 void writeClaim(Register32& reg, const uint32_t& data,
250 const int context_id);
251
252 // Latency Model
253 private:
254
255 // Internal states
256 // per-source pending * priority
258 // per-context, per-source pendingPriority * enable
260 // per-context last-claimed id
263
275 void propagateOutput();
276 std::map<Tick, PlicOutput> outputQueue;
278
287 void updateOutput();
288
298 void updateInt();
299};
300
301} // namespace gem5
302
303#endif // __DEV_RISCV_PLIC_HH__
const char data[]
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
virtual void post(int src_id)=0
PlicBaseParams Params
Definition plic.hh:102
PlicBase(const Params &params)
Definition plic.hh:103
virtual void clear(int src_id)=0
MMIO Registers.
Definition plic.hh:204
std::vector< Register32 > priority
Definition plic.hh:214
const Addr thresholdPadding
Definition plic.hh:210
std::vector< Register32 > pending
Definition plic.hh:215
const Addr enablePadding
Definition plic.hh:209
std::vector< RegisterRaz > enable_holes
Definition plic.hh:219
const Addr enableStart
Definition plic.hh:207
PlicRegisters(const std::string &name, Addr base, Plic *plic)
Definition plic.hh:223
const Addr maxBankSize
Definition plic.hh:211
const Addr thresholdStart
Definition plic.hh:208
std::vector< Register32 > threshold
Definition plic.hh:217
std::vector< std::vector< Register32 > > enable
Definition plic.hh:216
const Addr pendingStart
Definition plic.hh:206
std::vector< RegisterRaz > reserved
Definition plic.hh:221
std::vector< RegisterRaz > claim_holes
Definition plic.hh:220
std::vector< Register32 > claim
Definition plic.hh:218
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition plic.cc:146
int nSrc
Definition plic.hh:120
std::vector< uint32_t > lastID
Definition plic.hh:261
int nContext
Number of interrupt contexts = nThread * 2 e.g.
Definition plic.hh:133
std::map< Tick, PlicOutput > outputQueue
Definition plic.hh:276
void updateOutput()
Trigger:
Definition plic.cc:425
gem5::Plic::PlicRegisters registers
void post(int src_id) override
Interrupt interface.
Definition plic.cc:67
PlicOutput output
Definition plic.hh:262
EventFunctionWrapper update
Definition plic.hh:277
Tick read(PacketPtr pkt) override
PioDevice funcitons.
Definition plic.cc:124
PlicRegisters::Register32 Register32
Definition plic.hh:233
void writeEnable(Register32 &reg, const uint32_t &data, const int src32_id, const int context_id)
Definition plic.cc:316
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition plic.cc:514
void clear(int src_id) override
Definition plic.cc:96
void writeThreshold(Register32 &reg, const uint32_t &data, const int context_id)
Definition plic.cc:334
void updateInt()
Trigger:
Definition plic.cc:443
uint32_t readClaim(Register32 &reg, const int context_id)
Definition plic.cc:345
System * system
Definition plic.hh:117
std::vector< std::vector< uint32_t > > effPriority
Definition plic.hh:259
void propagateOutput()
Trigger:
Definition plic.cc:393
int nSrc32
Number of 32-bit pending registers needed = ceil(nSrc / 32)
Definition plic.hh:125
PlicParams Params
Definition plic.hh:136
void init() override
SimObject functions.
Definition plic.cc:166
std::vector< uint32_t > pendingPriority
Definition plic.hh:257
void writeClaim(Register32 &reg, const uint32_t &data, const int context_id)
Definition plic.cc:376
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition plic.cc:472
void writePriority(Register32 &reg, const uint32_t &data, const int src_id)
Register read / write callbacks.
Definition plic.cc:293
const std::string & name() const
Definition reg_bank.hh:942
STL vector class.
Definition stl.hh:37
const Params & params() const
Bitfield< 5, 3 > reg
Definition types.hh:92
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::ostream CheckpointOut
Definition serialize.hh:66
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
Declaration of the Packet class.
NOTE: This implementation of CLINT is based on the SiFive U54MC datasheet: https://sifive....
Definition plic.hh:94
std::vector< uint32_t > maxPriority
Definition plic.hh:96
std::vector< uint32_t > maxID
Definition plic.hh:95

Generated on Mon Jul 10 2023 14:24:31 for gem5 by doxygen 1.9.7