from nmigen.build import *
-__all__ = ["LEDResources", "RGBLEDResource", "ButtonResources", "SwitchResources"]
+__all__ = [
+ "LEDResources", "RGBLEDResource", "ButtonResources", "SwitchResources",
+ "Display7SegResource",
+]
def _SplitResources(*args, pins, invert=False, attrs=None, default_name, dir):
resources = []
for number, pin in pins.items():
- ios = [PinsN(pin, dir=dir) if invert else Pins(pin, dir=dir)]
+ ios = [Pins(pin, dir=dir, invert=invert)]
if attrs is not None:
ios.append(attrs)
resources.append(Resource.family(*args, number, default_name=default_name, ios=ios))
def RGBLEDResource(*args, r, g, b, invert=False, attrs=None):
ios = []
- ios.append(Subsignal("r", Pins(r, dir="o", assert_width=1)))
- ios.append(Subsignal("g", Pins(g, dir="o", assert_width=1)))
- ios.append(Subsignal("b", Pins(b, dir="o", assert_width=1)))
+ ios.append(Subsignal("r", Pins(r, dir="o", invert=invert, assert_width=1)))
+ ios.append(Subsignal("g", Pins(g, dir="o", invert=invert, assert_width=1)))
+ ios.append(Subsignal("b", Pins(b, dir="o", invert=invert, assert_width=1)))
if attrs is not None:
ios.append(attrs)
return Resource.family(*args, default_name="rgb_led", ios=ios)
def SwitchResources(*args, **kwargs):
return _SplitResources(*args, **kwargs, default_name="switch", dir="i")
+
+
+def Display7SegResource(*args, a, b, c, d, e, f, g, dp=None, invert=False, attrs=None):
+ ios = []
+ ios.append(Subsignal("a", Pins(a, dir="o", invert=invert, assert_width=1)))
+ ios.append(Subsignal("b", Pins(b, dir="o", invert=invert, assert_width=1)))
+ ios.append(Subsignal("c", Pins(c, dir="o", invert=invert, assert_width=1)))
+ ios.append(Subsignal("d", Pins(d, dir="o", invert=invert, assert_width=1)))
+ ios.append(Subsignal("e", Pins(e, dir="o", invert=invert, assert_width=1)))
+ ios.append(Subsignal("f", Pins(f, dir="o", invert=invert, assert_width=1)))
+ ios.append(Subsignal("g", Pins(g, dir="o", invert=invert, assert_width=1)))
+ if dp is not None:
+ ios.append(Subsignal("dp", Pins(dp, dir="o", assert_width=1)))
+ if attrs is not None:
+ ios.append(attrs)
+ return Resource.family(*args, default_name="display_7seg", ios=ios)
from nmigen.build import *
from nmigen.vendor.xilinx_spartan_3_6 import *
from .dev import *
+from .dev.user import Display7SegResource
__all__ = ["MercuryPlatform"]
]
_sevenseg = [
- Resource("sevenseg", 0,
- Subsignal("a", PinsN("13", dir="o", conn=("gpio", 0))),
- Subsignal("b", PinsN("14", dir="o", conn=("gpio", 0))),
- Subsignal("c", PinsN("15", dir="o", conn=("gpio", 0))),
- Subsignal("d", PinsN("16", dir="o", conn=("gpio", 0))),
- Subsignal("e", PinsN("17", dir="o", conn=("gpio", 0))),
- Subsignal("f", PinsN("18", dir="o", conn=("gpio", 0))),
- Subsignal("g", PinsN("19", dir="o", conn=("gpio", 0))),
- Subsignal("dp", PinsN("20", dir="o", conn=("gpio", 0))),
- Subsignal("en", Pins("9 10 11 12", dir="o",
- conn=("gpio", 0))),
- Attrs(IOSTANDARD="LVTTL")
+ Display7SegResource(0,
+ a="gpio_0:13", b="gpio_0:14", c="gpio_0:15", d="gpio_0:16",
+ e="gpio_0:17", f="gpio_0:18", g="gpio_0:19", dp="gpio_0:20",
+ invert=True, attrs=Attrs(IOSTANDARD="LVTTL")
+ ),
+ Resource("display_7seg_ctrl", 0,
+ Subsignal("en", Pins("9 10 11 12", dir="o", conn=("gpio", 0))),
+ Attrs(IOSTANDARD="LVTTL")
)
]