fhdl.specials: add compatibility shim for Tristate.
authorwhitequark <cz@m-labs.hk>
Sat, 19 Jan 2019 02:19:06 +0000 (02:19 +0000)
committerwhitequark <cz@m-labs.hk>
Sat, 19 Jan 2019 02:20:40 +0000 (02:20 +0000)
nmigen/compat/fhdl/specials.py

index 5449ba6f8412c8f77488533af2e5ad3ea8e1a967..2f52c250bc7307425a9b31f2576912ee81453e5e 100644 (file)
@@ -4,7 +4,7 @@ from ...tools import deprecated, extend
 from ...hdl.ast import *
 from ...hdl.mem import Memory as NativeMemory
 from ...hdl.ir import Fragment
-from ...lib.io import TSTriple as NativeTSTriple
+from ...lib.io import TSTriple as NativeTSTriple, Tristate as NativeTristate
 from .module import Module as CompatModule
 
 
@@ -18,11 +18,24 @@ class CompatTSTriple(NativeTSTriple):
                          reset_o=reset_o, reset_oe=reset_oe, reset_i=reset_i,
                          name=name)
 
-    def get_tristate(self, target):
-        raise NotImplementedError("TODO")
+
+class CompatTristate(NativeTristate):
+    def __init__(self, target, o, oe, i=None):
+        triple = TSTriple()
+        triple.o = o
+        triple.oe = oe
+        if i is not None:
+            triple.i = i
+        super().__init__(triple, target)
+
+    @property
+    @deprecated("instead of `Tristate.target`, use `Tristate.io`")
+    def target(self):
+        return self.io
 
 
 TSTriple = CompatTSTriple
+Tristate = CompatTristate
 
 
 (READ_FIRST, WRITE_FIRST, NO_CHANGE) = range(3)