From 38917e4523a5724b1e472d151e2e6f8fe55dbf62 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 4 Jun 2019 13:03:56 +0000 Subject: [PATCH] compat.fhdl.specials: fix platform lowering for TSTriple again. --- nmigen/compat/fhdl/specials.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/nmigen/compat/fhdl/specials.py b/nmigen/compat/fhdl/specials.py index 491b5de..1aef667 100644 --- a/nmigen/compat/fhdl/specials.py +++ b/nmigen/compat/fhdl/specials.py @@ -7,6 +7,7 @@ from ...hdl.mem import Memory as NativeMemory from ...hdl.ir import Fragment, Instance from ...hdl.dsl import Module from .module import Module as CompatModule +from ...lib.io import Pin __all__ = ["TSTriple", "Instance", "Memory", "READ_FIRST", "WRITE_FIRST", "NO_CHANGE"] @@ -32,22 +33,25 @@ class TSTriple: class Tristate(Elaboratable): def __init__(self, target, o, oe, i=None): self.target = target - self.triple = TSTriple() - self.triple.o = o - self.triple.oe = oe - if i is not None: - self.triple.i = i + self.o = o + self.oe = oe + self.i = i if i is not None else None def elaborate(self, platform): if hasattr(platform, "get_input_output"): - return platform.get_input_output(self.triple, self.target, extras={}) + pin = Pin(len(self.target), dir="oe" if self.i is None else "io") + pin.o = self.o + pin.oe = self.oe + if self.i is not None: + pin.i = self.i + return platform.get_input_output(pin, self.target, extras={}) m = Module() - m.d.comb += self.triple.i.eq(self.target) + m.d.comb += self.i.eq(self.target) m.submodules += Instance("$tribuf", p_WIDTH=len(self.target), - i_EN=self.triple.oe, - i_A=self.triple.o, + i_EN=self.oe, + i_A=self.o, o_Y=self.target, ) -- 2.30.2