Skip to content

Commit b0a4176

Browse files
committedMar 3, 2016
cores/gpio: remove GPIOInOut, add GPIOTristate
1 parent 79c89a3 commit b0a4176

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed
 

Diff for: ‎misoc/cores/gpio.py

+16-7
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,22 @@ def __init__(self, signal):
1616
self.comb += signal.eq(self._out.storage)
1717

1818

19-
class GPIOInOut(Module):
20-
def __init__(self, in_signal, out_signal):
21-
self.submodules.gpio_in = GPIOIn(in_signal)
22-
self.submodules.gpio_out = GPIOOut(out_signal)
23-
24-
def get_csrs(self):
25-
return self.gpio_in.get_csrs() + self.gpio_out.get_csrs()
19+
class GPIOTristate(Module, AutoCSR):
20+
def __init__(self, signals):
21+
l = len(signals)
22+
self._in = CSRStatus(l)
23+
self._out = CSRStorage(l)
24+
self._oe = CSRStorage(l)
25+
26+
for n, signal in enumerate(signals):
27+
ts = TSTriple(1)
28+
self.specials += ts.get_tristate(signal)
29+
30+
self.specials += MultiReg(ts.i, self._in.status)
31+
self.comb += [
32+
ts.o.eq(self._out.storage),
33+
ts.oe.eq(self._oe.storage)
34+
]
2635

2736

2837
class Blinker(Module):

0 commit comments

Comments
 (0)
Please sign in to comment.