From: Florent Kermarrec Date: Sun, 1 Dec 2019 20:26:37 +0000 (+0100) Subject: soc/cores/gpio: add GPIO Tristate X-Git-Tag: 24jan2021_ls180~835 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2567a0ae1d9400cf52acd195a29c4d15dd913d3d;p=litex.git soc/cores/gpio: add GPIO Tristate --- diff --git a/litex/soc/cores/gpio.py b/litex/soc/cores/gpio.py index 21028898..a2541072 100644 --- a/litex/soc/cores/gpio.py +++ b/litex/soc/cores/gpio.py @@ -29,3 +29,17 @@ class GPIOInOut(Module): def get_csrs(self): return self.gpio_in.get_csrs() + self.gpio_out.get_csrs() + +# GPIO Tristate ------------------------------------------------------------------------------------ + +class GPIOTristate(Module, AutoCSR): + def __init__(self, pads): + self._oe = CSRStorage(len(pads)) + self._in = CSRStatus(len(pads)) + self._out = CSRStorage(len(pads)) + + t = TSTriple(len(pads)) + self.specials += t.get_tristate(pads) + self.comb += t.oe.eq(self._oe.storage) + self.comb += t.o.eq(self._out.storage) + self.specials += MultiReg(t.i, self._in.status)