2
0
mirror of https://github.com/m-labs/artiq.git synced 2025-02-03 06:10:18 +08:00
artiq/artiq/gateware/rtio/rtlink.py
Sebastien Bourdeauducq 542a375305 rtio: remove NOP suppression capability
Back when RTIO was driving TTLs, this functionality made it simpler to use by removing some irrelevant underflows.

The same technique is not applicable to DDS and SPI, so the user will have to deal with such underflows.

This patch makes the behavior of RTIO more consistent and the code simpler.
2016-03-10 09:47:29 +08:00

82 lines
2.0 KiB
Python

from migen import *
class OInterface:
def __init__(self, data_width, address_width=0,
fine_ts_width=0, enable_replace=True):
self.stb = Signal()
self.busy = Signal()
if data_width:
self.data = Signal(data_width)
if address_width:
self.address = Signal(address_width)
if fine_ts_width:
self.fine_ts = Signal(fine_ts_width)
self.enable_replace = enable_replace
@classmethod
def like(cls, other):
return cls(get_data_width(other),
get_address_width(other),
get_fine_ts_width(other),
other.enable_replace)
class IInterface:
def __init__(self, data_width,
timestamped=True, fine_ts_width=0):
self.stb = Signal()
if data_width:
self.data = Signal(data_width)
if fine_ts_width:
self.fine_ts = Signal(fine_ts_width)
self.timestamped = timestamped
assert(not fine_ts_width or timestamped)
@classmethod
def like(cls, other):
return cls(get_data_width(other),
other.timestamped,
get_fine_ts_width(other))
class Interface:
def __init__(self, o, i=None):
self.o = o
self.i = i
@classmethod
def like(cls, other):
if self.i is None:
return cls(OInterface.like(self.o))
else:
return cls(OInterface.like(self.o),
IInterface.like(self.i))
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 hasattr(interface, attr):
return len(getattr(interface, attr))
else:
return 0
def get_data_width(interface):
return _get_or_zero(interface, "data")
def get_address_width(interface):
return _get_or_zero(interface, "address")
def get_fine_ts_width(interface):
return _get_or_zero(interface, "fine_ts")