RISC-V AIA Peripherals
The AIA library provides building blocks for integrating the RISC-V Advanced Interrupt Architecture into SpinalHDL systems. The implementation is split into two groups:
APLIC components, used for wired interrupt collection, direct interrupt delivery, MSI delivery, child-domain delegation, and TileLink/Fiber integration.
IMSIC-related components, used for interrupt-file modeling and memory-write trigger decoding.
APLIC
APLIC domain parameters
APlicDomainParam describes where the APLIC domain sits in the APLIC
hierarchy. Only the following helper should be used for mode selection.
Constructor |
Meaning |
|---|---|
|
Root M-domain APLIC. MSI address configuration is owned locally and exported to child domains. |
|
Non-root M-domain APLIC. MSI address configuration is provided by its parent. |
|
Non-root S-domain APLIC. Supervisor MSI address configuration is provided by its parent. |
APLIC generation parameters
APlicGenParam selects which APLIC delivery paths are generated and controls
a few MSI-related implementation options.
Public parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
No default |
Enables generation of the APLIC direct-delivery path. |
|
|
No default |
Enables generation of the APLIC MSI-delivery path. |
|
|
|
Enables generation of per-source pending and enable register logic. |
|
|
|
Enables the optional |
Configuration helpers
Function |
Description |
|---|---|
|
Lock the MSI state (Set the L bit of |
|
Sets |
|
Replaces M mode MSI parameters with the supplied |
|
Replaces M mode MSI parameters with the parameters. |
|
Replaces S mode MSI parameters with the supplied |
|
Replaces S mode MSI parameters with the parameters. |
Note: withMachineMsiParams/withSupervisorMsiParams is valid only if withMsiAddrcfg() is called.
The APlicMsiParam has the following parameters:
Name |
Type |
Default |
Description |
|---|---|---|---|
|
BigInt |
0x0 |
The base address of M mode IMSIC file |
|
Int |
0 |
|
|
Int |
0 |
|
|
Int |
0 |
|
|
Int |
0 |
|
For detailed description of hhxs/lhxs/hhxw/lhxw, see section
Addresses and data for outgoing MSIs of standard AIA document.
Pre-defined configuration
|
Direct mode only |
|
MSI mode only |
|
Both direct and MSI mode |
|
Full configuration, with tested signal ( |
Integration
The TilelinkAPlicFiber and TilelinkAPlicMsiSender is provided for CPU
integration. It can be used as the following:
// Create APLIC device
val aplic = TilelinkAPlicFiber(
APlicDomainParam.root(APlicGenParam.full)
)
// Register IRQ
val irq = aplic.createInternalInterruptSlave(
id = 1,
mode = LEVEL_HIGH
)
// Register master
val h0 = aplic.createInterruptMaster(id = 0)
For MSI delivery, the APLIC expose an MSI stream producer to connect MSI sender.
val msiStream = aplic.createMsiStreamProducer()
val msiSender = TilelinkAPlicMsiSenderFiber(
pendingSize = 4,
addressWidth = 64
)
msiSender.createMsiStreamConsumer() << msiStream
Child domains are handled through the cascaded interrupt-controller fiber
interface. The parent APLIC collects child source IDs and creates
APlicChildInfo entries during fiber elaboration.
Note: VexiiRiscv provides a system-level reference integration for APLIC. It can be used as a reference.
IMSIC
IMSIC file
There are two helper class for IMSIC file implementation. In almost all the
cases, the ImsicFileRam should be used as it provided optimized resource
usage and performance. The ImsicFile should only be used in cases where
performance is critical and resource consumption is extremely abundant.
ImsicFileRam
ImsicFileRam provides a RAM-backed variant with one or more access ports.
This file is constructed by ImsicFileParameters, its parameters is:
Name |
Type |
Description |
|---|---|---|
|
Int |
The hartId of RISC-V hart that this IMSIC file binds to |
|
Int |
The guestId of RISC-V hart that this IMSIC file binds to |
|
Int |
The number of interrupt supports by tis file. It should be pow of 2 |
|
Int |
The XLEN of RISC-V hart, used for provided aligned data |
|
Int |
The number of access ports, default is 2 (1 for CSR and 1 for bus) |
ImsicFile
Name |
Type |
Description |
|---|---|---|
|
Int |
The hartId of RISC-V hart that this IMSIC file binds to |
|
Int |
The guestId of RISC-V hart that this IMSIC file binds to |
|
Int |
The number of interrupt supports by tis file. It should be pow of 2 |
Integration
Check ImsicPlugin of VexiiRiscv for CPU integration for detailed IMSIC.