rohd
rohd copied to clipboard
Allow graceful error handling in `Simulator.throwException`
Motivation
As it is currently implemented, whenever there is an Exception
thrown via Simulator.throwException
, the Simulator.run
function will always throw the first exception and halt any remaining progress through the run function. It also will always log a severe
message. Some implications:
- Only the first exception is made visible to the user
- Even if a user catches the exception, there is still a
severe
message which could cause test failures in ROHD-VF testbenches - No end-of-simulation actions will ever execute
These seem like excessive limitations, and we should provide a method of gracefully handling issues from the Simulator
.
=====
Additionally, if the Simulator
is not actively running, then Simulator.throwException
currently does nothing. This doesn't seem like proper behavior, and we should probably be immediately rethrowing in this case.
Desired solution
A way to configure the Simulator
to gracefully handle error before defaulting to throw
ing it and incurring all of the downsides mentioned above. We can maybe look to the event handlers of StreamSubscription
for inspiration: https://api.flutter.dev/flutter/dart-async/StreamSubscription-class.html
It should be possible to handle errors and still execute end-of-simulation actions.
Some thought needs to be put into how to log the messages in a way that is convenient for use cases like ROHD-VF.
======
We should immediately rethrow exceptions passed to Simulator.throwException
if the simulation is not running.
Alternatives considered
No response
Additional details
No response
Additionally, if anything catches the Simulator
's exceptions, the Simulation.simulationEnded
never completes, which also means that any Simulator.reset()
will never complete!