gem5 v24.0.0.0
Loading...
Searching...
No Matches
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;
96
98{
99 public:
100 typedef PlicBaseParams Params;
102 BasicPioDevice(params, params.pio_size)
103 {}
104
105 // Interrupt interface to send signal to PLIC
106 virtual void post(int src_id) = 0;
107 // Interrupt interface to clear signal to PLIC
108 virtual void clear(int src_id) = 0;
109};
110
111class Plic : public PlicBase
112{
113 // Params
114 protected:
116
117 // Number of interrupt sources
118 int nSrc;
128
129 public:
130 typedef PlicParams Params;
131 Plic(const Params &params);
132
133 // External API
134 public:
138 void post(int src_id) override;
139 void clear(int src_id) override;
140
144 void init() override;
145 void serialize(CheckpointOut &cp) const override;
146 void unserialize(CheckpointIn &cp) override;
147
148 protected:
152 Tick read(PacketPtr pkt) override;
153 Tick write(PacketPtr pkt) override;
154
155 // Register bank
156 private:
157
226
228
232 void writePriority(Register32& reg, const uint32_t& data,
233 const int src_id);
234
235 void writeEnable(Register32& reg, const uint32_t& data,
236 const int src32_id, const int context_id);
237
238 void writeThreshold(Register32& reg, const uint32_t& data,
239 const int context_id);
240
241 uint32_t readClaim(Register32& reg, const int context_id);
242
243 void writeClaim(Register32& reg, const uint32_t& data,
244 const int context_id);
245
246 // Latency Model
247 private:
248
249 // Internal states
250 // per-source pending * priority
252 // per-context, per-source pendingPriority * enable
254 // per-context last-claimed id
257
261 void initContextFromNContexts(int n_contexts);
262 void initContextFromHartConfig(const std::string& hart_config);
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:100
PlicBase(const Params &params)
Definition plic.hh:101
virtual void clear(int src_id)=0
MMIO Registers.
Definition plic.hh:198
std::vector< Register32 > priority
Definition plic.hh:208
const Addr thresholdPadding
Definition plic.hh:204
std::vector< Register32 > pending
Definition plic.hh:209
const Addr enablePadding
Definition plic.hh:203
std::vector< RegisterRaz > enable_holes
Definition plic.hh:213
const Addr enableStart
Definition plic.hh:201
PlicRegisters(const std::string &name, Addr base, Plic *plic)
Definition plic.hh:217
const Addr maxBankSize
Definition plic.hh:205
const Addr thresholdStart
Definition plic.hh:202
std::vector< Register32 > threshold
Definition plic.hh:211
std::vector< std::vector< Register32 > > enable
Definition plic.hh:210
const Addr pendingStart
Definition plic.hh:200
std::vector< RegisterRaz > reserved
Definition plic.hh:215
std::vector< RegisterRaz > claim_holes
Definition plic.hh:214
std::vector< Register32 > claim
Definition plic.hh:212
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition plic.cc:154
int nSrc
Definition plic.hh:118
std::vector< uint32_t > lastID
Definition plic.hh:255
std::map< Tick, PlicOutput > outputQueue
Definition plic.hh:276
void updateOutput()
Trigger:
Definition plic.cc:466
gem5::Plic::PlicRegisters registers
Plic(const Params &params)
Definition plic.cc:56
void post(int src_id) override
Interrupt interface.
Definition plic.cc:75
PlicOutput output
Definition plic.hh:256
std::vector< std::pair< uint32_t, ExceptionCode > > contextConfigs
PLIC hart/pmode address configs, stored in the format {hartID, pmode}.
Definition plic.hh:127
EventFunctionWrapper update
Definition plic.hh:277
Tick read(PacketPtr pkt) override
PioDevice funcitons.
Definition plic.cc:132
PlicRegisters::Register32 Register32
Definition plic.hh:227
void writeEnable(Register32 &reg, const uint32_t &data, const int src32_id, const int context_id)
Definition plic.cc:324
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition plic.cc:553
void clear(int src_id) override
Definition plic.cc:104
void writeThreshold(Register32 &reg, const uint32_t &data, const int context_id)
Definition plic.cc:342
void updateInt()
Trigger:
Definition plic.cc:484
uint32_t readClaim(Register32 &reg, const int context_id)
Definition plic.cc:353
System * system
Definition plic.hh:115
void initContextFromHartConfig(const std::string &hart_config)
Definition plic.cc:443
std::vector< std::vector< uint32_t > > effPriority
Definition plic.hh:253
void propagateOutput()
Trigger:
Definition plic.cc:401
int nSrc32
Number of 32-bit pending registers needed = ceil(nSrc / 32)
Definition plic.hh:123
PlicParams Params
Definition plic.hh:130
void init() override
SimObject functions.
Definition plic.cc:174
std::vector< uint32_t > pendingPriority
Definition plic.hh:251
void writeClaim(Register32 &reg, const uint32_t &data, const int context_id)
Definition plic.cc:384
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition plic.cc:511
void initContextFromNContexts(int n_contexts)
The function for handling context config from params.
Definition plic.cc:433
void writePriority(Register32 &reg, const uint32_t &data, const int src_id)
Register read / write callbacks.
Definition plic.cc:301
const std::string & name() const
Definition reg_bank.hh:1026
STL vector class.
Definition stl.hh:37
const Params & params() const
Bitfield< 5, 3 > reg
Definition types.hh:92
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
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 PLIC is based on he riscv-plic-spec repository: https://github....
Definition plic.hh:92
std::vector< uint32_t > maxPriority
Definition plic.hh:94
std::vector< uint32_t > maxID
Definition plic.hh:93

Generated on Tue Jun 18 2024 16:24:03 for gem5 by doxygen 1.11.0