Save and restore simulation state