amaranth icon indicating copy to clipboard operation
amaranth copied to clipboard

Simulation : abort simulation when step() does not converge

Open sporniket opened this issue 3 years ago • 4 comments

Context

Done with writing my code and running a simulation, the simulator is stuck in an infinite loop. After the last yield of the added sync process, PySimEngine.step() is stuck in while not converged.

Summary

  • Specify a threshold to the number of iteration to converge in a step, with a sensible default value (1000 ? 10000 ?)
  • When the number of iteration to converge goes over the threshold
    • break out of the loop
    • flush the vcd_writers, so that one can do analysis
    • raise an Error, with the timestamp of the simulator

sporniket avatar Apr 21 '22 06:04 sporniket

In general, if the simulator doesn't converge, it means an issue with the input netlist. I'd say that the appropriate way to handle this is to reject such netlists before they can be simulated, since by the time the simulator is stuck, the original issue (a logic loop of some kind) becomes very hard to find.

whitequark avatar Apr 21 '22 06:04 whitequark

I understand. Then, as a failsafe, I would not mind to still have a capped number of iterations for the cases that the issue in the netlist is not recognized.

sporniket avatar Apr 21 '22 07:04 sporniket

I think this doesn't need an RFC, it's a simple internal change to the engine. We don't even have to make the configuration mechanism public.

whitequark avatar Feb 06 '23 16:02 whitequark

Ok, I will try to propose something by next week.

edit : life got in the way, will do asap.

sporniket avatar Feb 08 '23 11:02 sporniket