@@ -238,8 +238,9 @@ def sim_test():
238238 self .assertEqual ((yield dut .bus .stall ), 1 )
239239 self .assertEqual ((yield dut .bus .dat_r ), 0x5678abcd )
240240
241- with Simulator (dut , vcd_file = open ("test.vcd" , "w" )) as sim :
242- sim .add_process (sim_test ())
241+ sim = Simulator (dut )
242+ sim .add_process (sim_test )
243+ with sim .write_vcd (vcd_file = open ("test.vcd" , "w" )):
243244 sim .run ()
244245
245246 def test_addr_translate (self ):
@@ -348,8 +349,9 @@ def sim_test():
348349
349350 m = Module ()
350351 m .submodules += dut , loop_1 , loop_2 , loop_3 , loop_4
351- with Simulator (m , vcd_file = open ("test.vcd" , "w" )) as sim :
352- sim .add_process (sim_test ())
352+ sim = Simulator (m )
353+ sim .add_process (sim_test )
354+ with sim .write_vcd (vcd_file = open ("test.vcd" , "w" )):
353355 sim .run ()
354356
355357 def test_coarse_granularity (self ):
@@ -369,8 +371,9 @@ def sim_test():
369371 yield Delay (1e-6 )
370372 self .assertEqual ((yield sub .cyc ), 0 )
371373
372- with Simulator (dut , vcd_file = open ("test.vcd" , "w" )) as sim :
373- sim .add_process (sim_test ())
374+ sim = Simulator (dut )
375+ sim .add_process (sim_test )
376+ with sim .write_vcd (vcd_file = open ("test.vcd" , "w" )):
374377 sim .run ()
375378
376379
@@ -475,9 +478,10 @@ def sim_test():
475478 self .assertEqual ((yield intr_2 .rty ), 1 )
476479 self .assertEqual ((yield intr_2 .stall ), 0 )
477480
478- with Simulator (dut , vcd_file = open ("test.vcd" , "w" )) as sim :
479- sim .add_clock (1e-6 )
480- sim .add_sync_process (sim_test ())
481+ sim = Simulator (dut )
482+ sim .add_clock (1e-6 )
483+ sim .add_sync_process (sim_test )
484+ with sim .write_vcd (vcd_file = open ("test.vcd" , "w" )):
481485 sim .run ()
482486
483487 def test_lock (self ):
@@ -526,9 +530,10 @@ def sim_test():
526530 self .assertEqual ((yield intr_1 .ack ), 0 )
527531 self .assertEqual ((yield intr_2 .ack ), 1 )
528532
529- with Simulator (dut , vcd_file = open ("test.vcd" , "w" )) as sim :
530- sim .add_clock (1e-6 )
531- sim .add_sync_process (sim_test ())
533+ sim = Simulator (dut )
534+ sim .add_clock (1e-6 )
535+ sim .add_sync_process (sim_test )
536+ with sim .write_vcd (vcd_file = open ("test.vcd" , "w" )):
532537 sim .run ()
533538
534539 def test_stall (self ):
@@ -551,8 +556,9 @@ def sim_test():
551556 self .assertEqual ((yield intr_1 .stall ), 1 )
552557 self .assertEqual ((yield intr_2 .stall ), 1 )
553558
554- with Simulator (dut , vcd_file = open ("test.vcd" , "w" )) as sim :
555- sim .add_process (sim_test ())
559+ sim = Simulator (dut )
560+ sim .add_process (sim_test )
561+ with sim .write_vcd (vcd_file = open ("test.vcd" , "w" )):
556562 sim .run ()
557563
558564 def test_stall_compat (self ):
@@ -574,8 +580,9 @@ def sim_test():
574580 self .assertEqual ((yield intr_1 .stall ), 0 )
575581 self .assertEqual ((yield intr_2 .stall ), 1 )
576582
577- with Simulator (dut , vcd_file = open ("test.vcd" , "w" )) as sim :
578- sim .add_process (sim_test ())
583+ sim = Simulator (dut )
584+ sim .add_process (sim_test )
585+ with sim .write_vcd (vcd_file = open ("test.vcd" , "w" )):
579586 sim .run ()
580587
581588 def test_roundrobin (self ):
@@ -633,7 +640,8 @@ def sim_test():
633640 self .assertEqual ((yield intr_2 .ack ), 0 )
634641 self .assertEqual ((yield intr_3 .ack ), 1 )
635642
636- with Simulator (dut , vcd_file = open ("test.vcd" , "w" )) as sim :
637- sim .add_clock (1e-6 )
638- sim .add_sync_process (sim_test ())
643+ sim = Simulator (dut )
644+ sim .add_clock (1e-6 )
645+ sim .add_sync_process (sim_test )
646+ with sim .write_vcd (vcd_file = open ("test.vcd" , "w" )):
639647 sim .run ()
0 commit comments