From: whitequark Date: Sat, 19 Jan 2019 02:19:06 +0000 (+0000) Subject: fhdl.specials: add compatibility shim for Tristate. X-Git-Tag: working~64 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e3b5b2acc87ce474123b29c87fa09184f47c06f1;p=nmigen.git fhdl.specials: add compatibility shim for Tristate. --- 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)