Skip to content

Commit

Permalink
vendor.gowin: add support for iobuf (IOBUF) and tristate (TBUF).
Browse files Browse the repository at this point in the history
  • Loading branch information
bl0x committed Dec 22, 2022
1 parent f659572 commit 7e3177a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions amaranth/vendor/gowin.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,16 @@ def get_oneg(a, invert):
i = Signal(pin.width, name="{}_xdr_i".format(pin.name))
if "o" in pin.dir:
o = Signal(pin.width, name="{}_xdr_o".format(pin.name))
if pin.dir in ("oe", "io"):
t = Signal(1, name="{}_xdr_t".format(pin.name))

if pin.xdr == 0:
if "i" in pin.dir:
i = pin_i
if "o" in pin.dir:
o = pin_o
if pin.dir in ("oe", "io"):
t = ~pin.oe

return (i, o, t)

Expand Down Expand Up @@ -214,3 +218,33 @@ def get_output(self, pin, port, attrs, invert):
o_O=port.io[bit]
)
return m

def get_tristate(self, pin, port, attrs, invert):
self._check_feature("single-ended tristate", pin, attrs,
valid_xdrs=(0, 1, 2), valid_attrs=True)
m = Module()
i, o, t = self._get_io_buffer(m, pin, attrs.get("IOSTANDARD"),
o_invert=invert)
for bit in range(pin.width):
m.submodules["{}_{}".format(pin.name, bit)] = Instance("TBUF",
i_OEN=t,
i_I=o[bit],
o_O=port.io[bit]
)
return m

def get_input_output(self, pin, port, attrs, invert):
self._check_feature("single-ended input/output", pin, attrs,
valid_xdrs=(0, 1, 2), valid_attrs=True)
m = Module()
i, o, t = self._get_io_buffer(m, pin, attrs.get("IOSTANDARD"),
i_invert=invert, o_invert=invert)
for bit in range(pin.width):
m.submodules["{}_{}".format(pin.name, bit)] = Instance("IOBUF",
i_OEN=t,
i_I=o[bit],
o_O=i[bit],
io_IO=port.io[bit]
)
return m

0 comments on commit 7e3177a

Please sign in to comment.