@@ -54,6 +54,26 @@ def __init__(self, width):
54
54
self .comb += gt .i .eq (self .value_rtio ), self .value_sys .eq (gt .o )
55
55
56
56
57
+ class _BlindTransfer (Module ):
58
+ def __init__ (self ):
59
+ self .i = Signal ()
60
+ self .o = Signal ()
61
+
62
+ ps = PulseSynchronizer ("rio" , "rsys" )
63
+ ps_ack = PulseSynchronizer ("rsys" , "rio" )
64
+ self .submodules += ps , ps_ack
65
+ blind = Signal ()
66
+ self .sync .rio += [
67
+ If (self .i , blind .eq (1 )),
68
+ If (ps_ack .o , blind .eq (0 ))
69
+ ]
70
+ self .comb += [
71
+ ps .i .eq (self .i & ~ blind ),
72
+ ps_ack .i .eq (ps .o ),
73
+ self .o .eq (ps .o )
74
+ ]
75
+
76
+
57
77
# CHOOSING A GUARD TIME
58
78
#
59
79
# The buffer must be transferred to the FIFO soon enough to account for:
@@ -221,24 +241,17 @@ def __init__(self, interface, counter, fifo_depth, guard_io_cycles):
221
241
self .comb += fifo .re .eq (fifo .readable & (~ dout_stb | dout_ack ))
222
242
223
243
# FIFO read through buffer
224
- # TODO: report error on stb & busy
225
244
self .comb += [
226
245
dout_ack .eq (
227
246
dout .timestamp [fine_ts_width :] == counter .value_rtio ),
228
247
interface .stb .eq (dout_stb & dout_ack )
229
248
]
230
- busy_sync = PulseSynchronizer ("rio" , "rsys" )
231
- busy_ack_sync = PulseSynchronizer ("rsys" , "rio" )
232
- self .submodules += busy_sync , busy_ack_sync
233
- busy_blind = Signal ()
234
- self .comb += busy_sync .i .eq (interface .stb & interface .busy & ~ busy_blind )
235
- self .sync .rio += [
236
- If (interface .stb & interface .busy , busy_blind .eq (1 )),
237
- If (busy_ack_sync .o , busy_blind .eq (0 ))
238
- ]
249
+
250
+ busy_transfer = _BlindTransfer ()
251
+ self .submodules += busy_transfer
239
252
self .comb += [
240
- busy_ack_sync .i .eq (busy_sync . o ),
241
- self .busy .eq (busy_sync .o )
253
+ busy_transfer .i .eq (interface . stb & interface . busy ),
254
+ self .busy .eq (busy_transfer .o ),
242
255
]
243
256
244
257
if data_width :
@@ -263,7 +276,7 @@ def __init__(self, interface, counter, fifo_depth):
263
276
264
277
self .readable = Signal ()
265
278
self .re = Signal ()
266
-
279
+
267
280
self .overflow = Signal () # pulsed
268
281
269
282
# # #
@@ -296,18 +309,11 @@ def __init__(self, interface, counter, fifo_depth):
296
309
fifo .re .eq (self .re )
297
310
]
298
311
299
- overflow_sync = PulseSynchronizer ("rio" , "rsys" )
300
- overflow_ack_sync = PulseSynchronizer ("rsys" , "rio" )
301
- self .submodules += overflow_sync , overflow_ack_sync
302
- overflow_blind = Signal ()
303
- self .comb += overflow_sync .i .eq (fifo .we & ~ fifo .writable & ~ overflow_blind )
304
- self .sync .rio += [
305
- If (fifo .we & ~ fifo .writable , overflow_blind .eq (1 )),
306
- If (overflow_ack_sync .o , overflow_blind .eq (0 ))
307
- ]
312
+ overflow_transfer = _BlindTransfer ()
313
+ self .submodules += overflow_transfer
308
314
self .comb += [
309
- overflow_ack_sync .i .eq (overflow_sync . o ),
310
- self .overflow .eq (overflow_sync .o )
315
+ overflow_transfer .i .eq (fifo . we & ~ fifo . writable ),
316
+ self .overflow .eq (overflow_transfer .o ),
311
317
]
312
318
313
319
0 commit comments