From 32080adadd5d7a109690de4902eeaf80e021d725 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 19 Jan 2019 02:19:06 +0000 Subject: [PATCH] fhdl.specials: add compatibility shim for Tristate. --- nmigen/compat/fhdl/specials.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/nmigen/compat/fhdl/specials.py b/nmigen/compat/fhdl/specials.py index 5449ba6..2f52c25 100644 --- a/nmigen/compat/fhdl/specials.py +++ b/nmigen/compat/fhdl/specials.py @@ -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) -- 2.30.2