diff --git a/src/pytest_amaranth_sim/plugin.py b/src/pytest_amaranth_sim/plugin.py index 05e88a0..358930a 100644 --- a/src/pytest_amaranth_sim/plugin.py +++ b/src/pytest_amaranth_sim/plugin.py @@ -66,8 +66,19 @@ class SimulatorFixture: self.sim.add_process(p) if self.vcds: - with self.sim.write_vcd(self.name + ".vcd", self.name + ".gtkw"): - self.sim.run() + import amaranth.sim.pysim + + old_close = amaranth.sim.pysim._VCDWriter.close + def my_close(vcd, ts): + old_close(vcd, self.sim._engine.now) + + amaranth.sim.pysim._VCDWriter.close = my_close + + try: + with self.sim.write_vcd(self.name + ".vcd", self.name + ".gtkw"): + self.sim.run() + except AssertionError as e: + raise else: self.sim.run()