-
Notifications
You must be signed in to change notification settings - Fork 400
Description
Feature Request: Immediate Interrupt Processing for CoSimulation (Bypass limitBuffer)
Problem Statement
When using Renode's CoSimulation with HDL simulators (Questa/ModelSim), interrupts sent via the async socket are delayed by the limitBuffer time synchronization parameter. This creates significant latency for interrupt-driven applications.
Current Behavior
- Interrupts are sent from HDL via
renode_inputs.svusingsend_to_async_receiver() - Messages arrive at Renode's async socket immediately
- However, Renode only reads/processes the async socket when the
LimitTimerfires (everylimitBuffernanoseconds) - Result: Interrupt latency =
limitBuffervalue (typically 1,000,000 ns = 1 ms)
Use Case
We have a multi-CPU system where:
- UART/bus transactions need large
limitBuffer(e.g., 1,000,000 ns) for stable logging - Interrupts need immediate processing (<50 ns) for real-time responsiveness
Currently, we must choose between:
- Large
limitBuffer→ stable UART, but 1ms interrupt latency ❌ - Small
limitBuffer(e.g., 100 ns) → fast interrupts, but requires careful tuning⚠️
Desired Behavior
Add support for immediate interrupt processing that bypasses limitBuffer synchronization, while keeping bus transactions synchronized normally.
Ideally via a configuration option like:
emulation ConnectToCoSimulation "miv" "my_connection" \
address="127.0.0.1" \
limitBuffer=1000000 \
immediateInterrupts=true # New parameterOr per-peripheral:
cosimAXI : CoSimulated.CoSimulatedPeripheral @ sysbus <0x70000000, +0x0fffffff>
immediateInterrupts: true # New property
cosimToRenodeSignalRange: <0,+3>
[0,1,2] -> cpu@[24,27,28]Technical Details
Why Current Architecture Delays Interrupts
-
Async socket exists and is used correctly:
- HDL sends interrupts via
sendSender()to async socket - Interrupts use
ActionType.interrupt cosimToRenodeSignalRangeproperly maps signals
- HDL sends interrupts via
-
But processing is gated by LimitTimer:
timer.LimitReached += () => { // THIS is when async messages are processed // Happens every limitBuffer nanoseconds };
-
Documentation states: "asynchronous events are delivered in the synchronization phase automatically"
- This is correct, but "synchronization phase" =
limitBufferinterval - Not truly "asynchronous" from user perspective
- This is correct, but "synchronization phase" =
Proposed Implementation Approach
A safe implementation would need to:
- Single consumer pattern: Modify existing
SocketConnection.ReceiveLoop()to classify messages - Event queue: Don't process GPIO directly; queue interrupt events
- Safe delivery: Let Renode's main emulation thread apply GPIO changes (thread-safe)
- Always ACK: Send acknowledgments immediately to avoid protocol deadlock
- Optional feature: Only enable when
immediateInterrupts=trueto maintain backward compatibility
Critical requirements:
- Single thread reading async socket (avoid race conditions)
- Queue-based approach (avoid thread safety violations)
- Proper ACK handling (avoid protocol deadlock)
Workaround
Current working solution:
limitBuffer=100 # 100ns interrupt latency - acceptable for most casesThis works but:
- Requires tuning per system
- May need adjustment when adding more peripherals
- Not ideal for systems requiring both stable UART and <1µs interrupt latency
- Often introduces freezing of the HDL simulator
Environment
- Renode version: 1.16
- HDL Simulator: Questa/ModelSim
- Connection type: Socket-based CoSimulation
- Use case: Multi-CPU embedded system with interrupt-driven peripherals
Related Documentation
- [Time Framework](https://renode.readthedocs.io/en/latest/advanced/time_framework.html) - "time synchronization only applies to bus transactions"
- [CoSimulation Tutorial](https://renode.readthedocs.io/en/latest/tutorials/co-simulating-custom-hdl.html)
- Integration Library:
renode_inputs.svuses async socket correctly
Questions
- Is this a known limitation?
- Are there plans to support immediate interrupts in a future release?
- Would you accept a pull request implementing this feature?
- Are there alternative approaches we should consider?
Impact
This feature would enable:
- ✅ Real-time interrupt response in co-simulated systems
- ✅ Better match between HDL simulation and real hardware behavior
- ✅ Use of Renode for interrupt-critical applications
- ✅ Maintain stable bus/UART with large
limitBufferwhile having fast interrupts
Thank you for considering this feature request! Renode is an excellent tool and this enhancement would significantly expand its applicability for real-time embedded systems.