@@ -357,3 +357,79 @@ def test_async_buffered_fifo_level_full(self):
357
357
def test_async_buffered_fifo_level_empty (self ):
358
358
fifo = AsyncFIFOBuffered (width = 32 , depth = 9 , r_domain = "read" , w_domain = "write" )
359
359
self .check_async_fifo_level (fifo , fill_in = 0 , expected_level = 0 , read = True )
360
+
361
+ def check_async_fifo_reset (self , fifo , fill_in , r_period , w_period ):
362
+ m = Module ()
363
+ m .submodules .fifo = fifo
364
+ write_rst = Signal ()
365
+ m .d .comb += ResetSignal ("write" ).eq (write_rst )
366
+ read_por_done = Signal ()
367
+
368
+ def write_process ():
369
+ while not (yield read_por_done ):
370
+ yield
371
+
372
+ yield fifo .w_en .eq (1 )
373
+ for _ in range (fill_in ):
374
+ yield
375
+ yield fifo .w_en .eq (0 )
376
+ yield
377
+
378
+ while not (yield fifo .r_rdy ):
379
+ yield
380
+
381
+ yield write_rst .eq (1 )
382
+ yield
383
+ yield write_rst .eq (0 )
384
+ yield
385
+ yield Passive ()
386
+ while True :
387
+ self .assertEqual ((yield fifo .w_level ), 0 )
388
+ yield
389
+
390
+ def read_process ():
391
+ while not (yield fifo .r_rst ):
392
+ yield
393
+ while (yield fifo .r_rst ):
394
+ yield
395
+ yield read_por_done .eq (1 )
396
+
397
+ while not (yield fifo .r_rst ):
398
+ yield
399
+ while (yield fifo .r_rst ):
400
+ yield
401
+ for _ in range (10 ):
402
+ self .assertEqual ((yield fifo .r_level ), 0 )
403
+ yield
404
+
405
+ simulator = Simulator (m )
406
+ simulator .add_clock (w_period , domain = "write" )
407
+ simulator .add_clock (r_period , domain = "read" )
408
+ simulator .add_sync_process (write_process , domain = "write" )
409
+ simulator .add_sync_process (read_process , domain = "read" )
410
+ with simulator .write_vcd ("test.vcd" ):
411
+ simulator .run ()
412
+
413
+ def test_async_fifo_reset_r10w10 (self ):
414
+ fifo = AsyncFIFO (width = 1 , depth = 8 , r_domain = "read" , w_domain = "write" )
415
+ self .check_async_fifo_reset (fifo , fill_in = 4 , r_period = 10e-9 , w_period = 10e-9 )
416
+
417
+ def test_async_fifo_reset_r10w27 (self ):
418
+ fifo = AsyncFIFO (width = 1 , depth = 8 , r_domain = "read" , w_domain = "write" )
419
+ self .check_async_fifo_reset (fifo , fill_in = 4 , r_period = 10e-9 , w_period = 27e-9 )
420
+
421
+ def test_async_fifo_reset_r27w10 (self ):
422
+ fifo = AsyncFIFO (width = 1 , depth = 8 , r_domain = "read" , w_domain = "write" )
423
+ self .check_async_fifo_reset (fifo , fill_in = 4 , r_period = 27e-9 , w_period = 10e-9 )
424
+
425
+ def test_async_buffered_fifo_reset_r10w10 (self ):
426
+ fifo = AsyncFIFOBuffered (width = 1 , depth = 8 , r_domain = "read" , w_domain = "write" )
427
+ self .check_async_fifo_reset (fifo , fill_in = 4 , r_period = 10e-9 , w_period = 10e-9 )
428
+
429
+ def test_async_buffered_fifo_reset_r10w27 (self ):
430
+ fifo = AsyncFIFOBuffered (width = 1 , depth = 8 , r_domain = "read" , w_domain = "write" )
431
+ self .check_async_fifo_reset (fifo , fill_in = 4 , r_period = 10e-9 , w_period = 27e-9 )
432
+
433
+ def test_async_buffered_fifo_reset_r27w10 (self ):
434
+ fifo = AsyncFIFOBuffered (width = 1 , depth = 8 , r_domain = "read" , w_domain = "write" )
435
+ self .check_async_fifo_reset (fifo , fill_in = 4 , r_period = 27e-9 , w_period = 10e-9 )
0 commit comments