old_close = amaranth.sim.pysim._VCDWriter.close def my_close(vcd, ts): print("hi!") old_close(vcd, ts) amaranth.sim.pysim._VCDWriter.close = my_close