@@ -82,12 +82,14 @@ def test_err_frame(self):
82
82
83
83
def test_err_overflow (self ):
84
84
self .dut = AsyncSerialRX (divisor = 7 )
85
+
85
86
def process ():
86
87
self .assertFalse ((yield self .dut .rdy ))
87
88
yield from self .tx_bits ([0 , 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , 1 ])
88
89
yield from self .tx_period ()
89
90
self .assertFalse ((yield self .dut .rdy ))
90
91
self .assertTrue ((yield self .dut .err .overflow ))
92
+
91
93
simulation_test (self .dut , process )
92
94
93
95
@@ -104,7 +106,7 @@ def process():
104
106
yield self .dut .ack .eq (0 )
105
107
for _ in range (10 ):
106
108
yield from self .tx_period ()
107
- yield from self .tx_period () # Check 1 more period
109
+ yield from self .tx_period () # Check 1 more period
108
110
simulation_test (self .dut , process )
109
111
110
112
def test_8n1 (self ):
@@ -225,15 +227,15 @@ def elaborate(self, platform):
225
227
Assert (rx_fsm .ongoing ("DONE" )),
226
228
Assert (tx_fsm .ongoing ("DONE" ))
227
229
]
228
- ## RX r_rdy
230
+ # RX r_rdy
229
231
with m .If (Past (rx .busy , 2 ) & ~ Stable (rx .busy , 1 )):
230
232
m .d .comb += Assert (rx .r_rdy )
231
233
with m .If (Stable (rx .r_rdy ) & rx .r_rdy ):
232
- m .d .comb += Assert (Stable (rx .data ) &
234
+ m .d .comb += Assert (Stable (rx .data ) &
233
235
Stable (rx .err .overflow ) &
234
236
Stable (rx .err .frame ) &
235
237
Stable (rx .err .parity ))
236
- ## TX w_done
238
+ # TX w_done
237
239
with m .If (Past (tx .busy ) & ~ Stable (tx .busy )):
238
240
m .d .comb += Assert (tx .w_done )
239
241
@@ -243,7 +245,9 @@ def elaborate(self, platform):
243
245
class AsyncSerialLoopbackTestCase (FHDLTestCase ):
244
246
def check_formal (self , * , divisor , data_bits , parity ):
245
247
depth = (divisor + 1 ) * (data_bits + (3 if parity != "none" else 2 ) + 2 )
246
- self .assertFormal (AsyncSerialLoopbackSpec (divisor = divisor , data_bits = data_bits , parity = parity ),
248
+ self .assertFormal (AsyncSerialLoopbackSpec (divisor = divisor ,
249
+ data_bits = data_bits ,
250
+ parity = parity ),
247
251
mode = "bmc" , depth = depth )
248
252
249
253
def test_all_div7 (self ):
@@ -290,18 +294,20 @@ def elaborate(self, platform):
290
294
ResetSignal ("sync" ).eq (0 ),
291
295
ResetSignal ("txclk" ).eq (0 )
292
296
]
293
-
297
+
294
298
# Assumptions for TX
295
299
fv_tx_bitstream_val = AnyConst (len_bitstream )
296
300
# Assume the bitstream doesn't have 1-bit delay
297
301
m .d .comb += Assume (fv_tx_bitstream_val [0 ] != 1 )
298
302
fv_tx_bitstream = Signal (len_bitstream + 1 )
299
- fv_tx_extra_bit = AnyConst (1 ) # A const bit representing the extra bit after the bitstream
300
- fv_tx_overflow = AnyConst (1 ) # A const flag to determine if the rx_fifo is always full
303
+ fv_tx_extra_bit = AnyConst (1 ) # A const bit representing
304
+ # the extra bit after the bitstream
305
+ fv_tx_overflow = AnyConst (1 ) # A const flag to determine if
306
+ # the rx_fifo is always full
301
307
fv_tx_bitno = Signal (range (len (fv_tx_bitstream )+ 1 ))
302
308
fv_tx_timer = Signal .like (rx .divisor )
303
309
fv_rx_data = Signal (self .data_bits )
304
- #
310
+ #
305
311
fv_txfifo_num_bits = Signal (range (len (fv_tx_bitstream )+ 2 ))
306
312
with m .FSM (domain = "txclk" ) as txfifo_fsm :
307
313
with m .State ("WRITE-PREP" ):
@@ -322,7 +328,7 @@ def elaborate(self, platform):
322
328
m .d .txclk += txbit_fifo .w_en .eq (0 )
323
329
m .next = "DONE"
324
330
txfifo_fsm .state .name = "fv_txfifo_fsm_state"
325
- #
331
+ #
326
332
fv_tx_extra_done = Signal ()
327
333
with m .FSM (domain = "txclk" ) as tx_fsm :
328
334
with m .State ("TX-PREP" ):
@@ -394,11 +400,11 @@ def elaborate(self, platform):
394
400
# Assertions
395
401
with m .If (Past (rx_fsm .state ) == rx_fsm .encoding ["CHECK" ]):
396
402
m .d .comb += Assert (rx_fsm .ongoing ("DONE" ) | rx_fsm .ongoing ("ERROR" ))
397
- ## RX r_rdy
403
+ # RX r_rdy
398
404
with m .If (Past (rx .busy , 2 ) & ~ Stable (rx .busy , 1 )):
399
405
m .d .comb += Assert (rx .r_rdy )
400
406
with m .If (Stable (rx .r_rdy ) & rx .r_rdy ):
401
- m .d .comb += Assert (Stable (rx .data ) &
407
+ m .d .comb += Assert (Stable (rx .data ) &
402
408
Stable (rx .err .overflow ) &
403
409
Stable (rx .err .frame ) &
404
410
Stable (rx .err .parity ))
@@ -454,7 +460,9 @@ def elaborate(self, platform):
454
460
class AsyncSerialBitstreamTestCase (FHDLTestCase ):
455
461
def check_formal (self , * , divisor , data_bits , parity ):
456
462
depth = (divisor + 1 ) * (data_bits + (3 if parity != "none" else 2 ) + 2 )
457
- self .assertFormal (AsyncSerialBitstreamSpec (divisor = divisor , data_bits = data_bits , parity = parity ),
463
+ self .assertFormal (AsyncSerialBitstreamSpec (divisor = divisor ,
464
+ data_bits = data_bits ,
465
+ parity = parity ),
458
466
mode = "bmc" , depth = depth )
459
467
460
468
def test_all_div7 (self ):
0 commit comments