From 26003781b45db4f0a512b51f6c756a38c2ba0220 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 16 Apr 2015 13:02:39 +0800 Subject: [PATCH] rtio/rtlink: add 'like' methods to clone interfaces --- artiq/gateware/rtio/rtlink.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/artiq/gateware/rtio/rtlink.py b/artiq/gateware/rtio/rtlink.py index 73fc8c08d..0d131b98e 100644 --- a/artiq/gateware/rtio/rtlink.py +++ b/artiq/gateware/rtio/rtlink.py @@ -17,6 +17,13 @@ class OInterface: self.latency = latency self.suppress_nop = suppress_nop + @classmethod + def like(cls, other): + return cls(get_data_width(other), + get_address_width(other), + get_fine_ts_width(other), + other.latency, other.suppress_nop) + class IInterface: def __init__(self, data_width, @@ -32,12 +39,27 @@ class IInterface: 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), + other.latency) + 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):