forked from M-Labs/artiq
1
0
Fork 0

rtio: clean up error-prone rtlink.get_or_zero()

This commit is contained in:
Sebastien Bourdeauducq 2017-09-17 16:11:36 +08:00
parent 53860868f4
commit 65baca8c57
4 changed files with 16 additions and 15 deletions

View File

@ -190,8 +190,10 @@ class Core(Module, AutoCSR):
self.specials += AsyncResetSynchronizer(self.cd_rio_phy, cmd_reset_phy)
# TSC
fine_ts_width = max(rtlink.get_fine_ts_width(channel.interface)
for channel in channels)
fine_ts_width = max(max(rtlink.get_fine_ts_width(channel.interface.o)
for channel in channels),
max(rtlink.get_fine_ts_width(channel.interface.i)
for channel in channels))
coarse_ts = Signal(64-fine_ts_width)
self.sync.rtio += coarse_ts.eq(coarse_ts + 1)
coarse_ts_cdc = GrayCodeTransfer(len(coarse_ts))

View File

@ -69,10 +69,9 @@ class Interface:
def _get_or_zero(interface, attr):
if isinstance(interface, Interface):
return max(_get_or_zero(interface.i, attr),
_get_or_zero(interface.o, attr))
else:
if interface is None:
return 0
assert isinstance(interface, (OInterface, IInterface))
if hasattr(interface, attr):
return len(getattr(interface, attr))
else:

View File

@ -27,7 +27,7 @@ class SED(Module):
else:
raise ValueError
fine_ts_width = max(rtlink.get_fine_ts_width(c.interface)
fine_ts_width = max(rtlink.get_fine_ts_width(c.interface.o)
for c in channels)
seqn_width = layouts.seqn_width(lane_count, fifo_depth)

View File

@ -4,9 +4,9 @@ from artiq.gateware.rtio import rtlink
def fifo_payload(channels):
address_width = max(rtlink.get_address_width(channel.interface)
address_width = max(rtlink.get_address_width(channel.interface.o)
for channel in channels)
data_width = max(rtlink.get_data_width(channel.interface)
data_width = max(rtlink.get_data_width(channel.interface.o)
for channel in channels)
layout = [
@ -46,11 +46,11 @@ def fifo_egress(seqn_width, layout_payload):
def output_network_payload(channels):
fine_ts_width = max(rtlink.get_fine_ts_width(channel.interface)
fine_ts_width = max(rtlink.get_fine_ts_width(channel.interface.o)
for channel in channels)
address_width = max(rtlink.get_address_width(channel.interface)
address_width = max(rtlink.get_address_width(channel.interface.o)
for channel in channels)
data_width = max(rtlink.get_data_width(channel.interface)
data_width = max(rtlink.get_data_width(channel.interface.o)
for channel in channels)
layout = [("channel", bits_for(len(channels)-1))]