Skip to content

Commit 107e5cf

Browse files
committedMar 9, 2016
gateware/rtio: factor _BlindTransfer
1 parent 10a0912 commit 107e5cf

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed
 

‎artiq/gateware/rtio/core.py

+30-24
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,26 @@ def __init__(self, width):
5454
self.comb += gt.i.eq(self.value_rtio), self.value_sys.eq(gt.o)
5555

5656

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+
5777
# CHOOSING A GUARD TIME
5878
#
5979
# 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):
221241
self.comb += fifo.re.eq(fifo.readable & (~dout_stb | dout_ack))
222242

223243
# FIFO read through buffer
224-
# TODO: report error on stb & busy
225244
self.comb += [
226245
dout_ack.eq(
227246
dout.timestamp[fine_ts_width:] == counter.value_rtio),
228247
interface.stb.eq(dout_stb & dout_ack)
229248
]
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
239252
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),
242255
]
243256

244257
if data_width:
@@ -263,7 +276,7 @@ def __init__(self, interface, counter, fifo_depth):
263276

264277
self.readable = Signal()
265278
self.re = Signal()
266-
279+
267280
self.overflow = Signal() # pulsed
268281

269282
# # #
@@ -296,18 +309,11 @@ def __init__(self, interface, counter, fifo_depth):
296309
fifo.re.eq(self.re)
297310
]
298311

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
308314
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),
311317
]
312318

313319

0 commit comments

Comments
 (0)
Please sign in to comment.