leds = []
for n in itertools.count():
try:
- leds.append(platform.request("user_led", n))
+ leds.append(platform.request("led", n))
except ResourceError:
break
leds = Cat(led.o for led in leds)
speed = "1L"
default_clk = "clk100"
resources = [
- Resource("clk100", 0, Pins("E3", dir="i"), Clock(100e6), Attrs(IOSTANDARD="LVCMOS33")),
+ Resource("clk100", 0, Pins("E3", dir="i"),
+ Clock(100e6), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_led", 0, Pins("H5", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_led", 1, Pins("J5", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_led", 2, Pins("T9", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_led", 3, Pins("T10", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
+ *LEDResources(pins="H5 J5 T9 T10", attrs=Attrs(IOSTANDARD="LVCMOS33")),
- Resource("rgb_led", 0,
- Subsignal("r", Pins("G6", dir="o")),
- Subsignal("g", Pins("F6", dir="o")),
- Subsignal("b", Pins("E1", dir="o")),
- Attrs(IOSTANDARD="LVCMOS33")
- ),
-
- Resource("rgb_led", 1,
- Subsignal("r", Pins("G3", dir="o")),
- Subsignal("g", Pins("J4", dir="o")),
- Subsignal("b", Pins("G4", dir="o")),
- Attrs(IOSTANDARD="LVCMOS33")
- ),
-
- Resource("rgb_led", 2,
- Subsignal("r", Pins("J3", dir="o")),
- Subsignal("g", Pins("J2", dir="o")),
- Subsignal("b", Pins("H4", dir="o")),
- Attrs(IOSTANDARD="LVCMOS33")
- ),
-
- Resource("rgb_led", 3,
- Subsignal("r", Pins("K1", dir="o")),
- Subsignal("g", Pins("H6", dir="o")),
- Subsignal("b", Pins("K2", dir="o")),
- Attrs(IOSTANDARD="LVCMOS33")
- ),
-
- Resource("user_sw", 0, Pins("A8" , dir="i"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_sw", 1, Pins("C11", dir="i"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_sw", 2, Pins("C10", dir="i"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_sw", 3, Pins("A10", dir="i"), Attrs(IOSTANDARD="LVCMOS33")),
+ RGBLEDResource(0, r="G6", g="F6", b="E1", attrs=Attrs(IOSTANDARD="LVCMOS33")),
+ RGBLEDResource(1, r="G3", g="J4", b="G4", attrs=Attrs(IOSTANDARD="LVCMOS33")),
+ RGBLEDResource(2, r="J3", g="J2", b="H4", attrs=Attrs(IOSTANDARD="LVCMOS33")),
+ RGBLEDResource(3, r="K1", g="H6", b="K2", attrs=Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_btn", 0, Pins("D9", dir="i"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_btn", 1, Pins("C9", dir="i"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_btn", 2, Pins("B9", dir="i"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_btn", 3, Pins("B8", dir="i"), Attrs(IOSTANDARD="LVCMOS33")),
+ *ButtonResources(pins="D9 C9 B9 B8 ", attrs=Attrs(IOSTANDARD="LVCMOS33")),
+ *SwitchResources(pins="A8 C11 C10 A10", attrs=Attrs(IOSTANDARD="LVCMOS33")),
UARTResource(0,
rx="A9", tx="D10",
"""Platform file for Digilent Atlys Spartan 6 board.
https://reference.digilentinc.com/reference/programmable-logic/atlys/start"""
- device = "xc6slx45"
- package = "csg324"
- speed = "3"
+ device = "xc6slx45"
+ package = "csg324"
+ speed = "3"
def __init__(self, *, JP12="2V5", **kwargs):
super().__init__(**kwargs)
default_clk = "clk100"
resources = [
- Resource("clk100" , 0, Pins("L15", dir="i"), Attrs(IOSTANDARD="LVCMOS33"), Clock(100e6)), # GCLK
-
- Resource("user_led", 0, Pins("U18", dir="o"), Attrs(IOSTANDARD="LVCMOS33")), # LD0
- Resource("user_led", 1, Pins("M14", dir="o"), Attrs(IOSTANDARD="LVCMOS33")), # LD1
- Resource("user_led", 2, Pins("N14", dir="o"), Attrs(IOSTANDARD="LVCMOS33")), # LD2
- Resource("user_led", 3, Pins("L14", dir="o"), Attrs(IOSTANDARD="LVCMOS33")), # LD3
- Resource("user_led", 4, Pins("M13", dir="o"), Attrs(IOSTANDARD="LVCMOS33")), # LD4
- Resource("user_led", 5, Pins("D4", dir="o"), Attrs(IOSTANDARD="LVCMOS33")), # LD5
- Resource("user_led", 6, Pins("P16", dir="o"), Attrs(IOSTANDARD="LVCMOS33")), # LD6
- Resource("user_led", 7, Pins("N12", dir="o"), Attrs(IOSTANDARD=bank2_iostandard)), # LD7
-
- Resource("user_btn", 0, PinsN("T15", dir="i"), Attrs(IOSTANDARD=bank2_iostandard)), # RESET
- Resource("reset" , 0, PinsN("T15", dir="i"), Attrs(IOSTANDARD=bank2_iostandard)), # RESET
- Resource("user_btn", 1, Pins("N4", dir="i"), Attrs(IOSTANDARD="LVCMOS18")), # BTNU
- Resource("user_btn", 2, Pins("P4", dir="i"), Attrs(IOSTANDARD="LVCMOS18")), # BTNL
- Resource("user_btn", 3, Pins("P3", dir="i"), Attrs(IOSTANDARD="LVCMOS18")), # BTND
- Resource("user_btn", 4, Pins("F6", dir="i"), Attrs(IOSTANDARD="LVCMOS18")), # BTNR
- Resource("user_btn", 5, Pins("F5", dir="i"), Attrs(IOSTANDARD="LVCMOS18")), # BTNC
-
- Resource("user_sw" , 0, Pins("A10", dir="i"), Attrs(IOSTANDARD="LVCMOS33")), # SW0
- Resource("user_sw" , 1, Pins("D14", dir="i"), Attrs(IOSTANDARD="LVCMOS33")), # SW1
- Resource("user_sw" , 2, Pins("C14", dir="i"), Attrs(IOSTANDARD="LVCMOS33")), # SW2
- Resource("user_sw" , 3, Pins("P15", dir="i"), Attrs(IOSTANDARD="LVCMOS33")), # SW3
- Resource("user_sw" , 4, Pins("P12", dir="i"), Attrs(IOSTANDARD=bank2_iostandard)), # SW4
- Resource("user_sw" , 5, Pins("R5", dir="i"), Attrs(IOSTANDARD=bank2_iostandard)), # SW5
- Resource("user_sw" , 6, Pins("T5", dir="i"), Attrs(IOSTANDARD=bank2_iostandard)), # SW6
- Resource("user_sw" , 7, Pins("E4", dir="i"), Attrs(IOSTANDARD="LVCMOS18")), # SW7
-
- UARTResource(0, rx="A16", tx="B16", attrs=Attrs(IOSTANDARD="LVCMOS33")), # J17/UART
+ Resource("clk100", 0, Pins("L15", dir="i"),
+ Clock(100e6), Attrs(IOSTANDARD="LVCMOS33")), # GCLK
+
+ Resource("led", 0, Pins("U18", dir="o"), Attrs(IOSTANDARD="LVCMOS33")), # LD0
+ Resource("led", 1, Pins("M14", dir="o"), Attrs(IOSTANDARD="LVCMOS33")), # LD1
+ Resource("led", 2, Pins("N14", dir="o"), Attrs(IOSTANDARD="LVCMOS33")), # LD2
+ Resource("led", 3, Pins("L14", dir="o"), Attrs(IOSTANDARD="LVCMOS33")), # LD3
+ Resource("led", 4, Pins("M13", dir="o"), Attrs(IOSTANDARD="LVCMOS33")), # LD4
+ Resource("led", 5, Pins("D4", dir="o"), Attrs(IOSTANDARD="LVCMOS33")), # LD5
+ Resource("led", 6, Pins("P16", dir="o"), Attrs(IOSTANDARD="LVCMOS33")), # LD6
+ Resource("led", 7, Pins("N12", dir="o"), Attrs(IOSTANDARD=bank2_iostandard)), # LD7
+
+ Resource("button", 0, PinsN("T15", dir="i"), Attrs(IOSTANDARD=bank2_iostandard)), # RESET
+ Resource("reset", 0, PinsN("T15", dir="i"), Attrs(IOSTANDARD=bank2_iostandard)), # RESET
+ Resource("button", 1, Pins("N4", dir="i"), Attrs(IOSTANDARD="LVCMOS18")), # BTNU
+ Resource("button", 2, Pins("P4", dir="i"), Attrs(IOSTANDARD="LVCMOS18")), # BTNL
+ Resource("button", 3, Pins("P3", dir="i"), Attrs(IOSTANDARD="LVCMOS18")), # BTND
+ Resource("button", 4, Pins("F6", dir="i"), Attrs(IOSTANDARD="LVCMOS18")), # BTNR
+ Resource("button", 5, Pins("F5", dir="i"), Attrs(IOSTANDARD="LVCMOS18")), # BTNC
+
+ Resource("switch", 0, Pins("A10", dir="i"), Attrs(IOSTANDARD="LVCMOS33")), # SW0
+ Resource("switch", 1, Pins("D14", dir="i"), Attrs(IOSTANDARD="LVCMOS33")), # SW1
+ Resource("switch", 2, Pins("C14", dir="i"), Attrs(IOSTANDARD="LVCMOS33")), # SW2
+ Resource("switch", 3, Pins("P15", dir="i"), Attrs(IOSTANDARD="LVCMOS33")), # SW3
+ Resource("switch", 4, Pins("P12", dir="i"), Attrs(IOSTANDARD=bank2_iostandard)), # SW4
+ Resource("switch", 5, Pins("R5", dir="i"), Attrs(IOSTANDARD=bank2_iostandard)), # SW5
+ Resource("switch", 6, Pins("T5", dir="i"), Attrs(IOSTANDARD=bank2_iostandard)), # SW6
+ Resource("switch", 7, Pins("E4", dir="i"), Attrs(IOSTANDARD="LVCMOS18")), # SW7
+
+ UARTResource(0, rx="A16", tx="B16", attrs=Attrs(IOSTANDARD="LVCMOS33")), # J17/UART
Resource("ps2", 0, # PS/2 keyboard interface converted from J13 "HOST" USB connector
Subsignal("clk", Pins("P17", dir="i")),
default_clk = "clk100"
resources = [
Resource("clk100", 0, Pins("129", dir="i"),
- Clock(100e6), Attrs(GLOBAL=True, IO_STANDARD="SB_LVCMOS")
- ),
-
- Resource("user_led", 0, Pins("71", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 1, Pins("67", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 2, Pins("68", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 3, Pins("70", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- # Color aliases
- Resource("user_ledb", 0, Pins("71", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_ledg", 0, Pins("67", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_ledo", 0, Pins("68", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_ledr", 0, Pins("70", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ Clock(100e6), Attrs(GLOBAL=True, IO_STANDARD="SB_LVCMOS")),
- Resource("user_btn", 0, PinsN("63", dir="i"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_btn", 1, PinsN("64", dir="i"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ *LEDResources(pins="71 67 68 70", attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
+ # Semantic aliases
+ Resource("led_b", 0, Pins("71", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ Resource("led_g", 0, Pins("67", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ Resource("led_o", 0, Pins("68", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ Resource("led_r", 0, Pins("70", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_sw", 0, PinsN("37", dir="i"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_sw", 1, PinsN("38", dir="i"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_sw", 2, PinsN("39", dir="i"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_sw", 3, PinsN("41", dir="i"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ *ButtonResources(pins="63 64", invert=True, attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
+ *SwitchResources(pins="37 38 39 41", invert=True, attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
UARTResource(0,
rx="88", tx="85", rts="91", cts="94",
Clock(100e6), Attrs(GLOBAL=True, IO_STANDARD="SB_LVCMOS")
),
- Resource("user_led", 0, Pins("71", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 1, Pins("67", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 2, Pins("68", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 3, Pins("70", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ *LEDResources(pins="71 67 68 70", attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
# Color aliases
- Resource("user_ledb", 0, Pins("71", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_ledg", 0, Pins("67", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_ledo", 0, Pins("68", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_ledr", 0, Pins("70", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ Resource("led_b", 0, Pins("71", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ Resource("led_g", 0, Pins("67", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ Resource("led_o", 0, Pins("68", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ Resource("led_r", 0, Pins("70", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_btn", 0, PinsN("63", dir="i"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_btn", 1, PinsN("64", dir="i"), Attrs(IO_STANDARD="SB_LVCMOS")),
-
- Resource("user_sw", 0, PinsN("37", dir="i"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_sw", 1, PinsN("38", dir="i"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_sw", 2, PinsN("39", dir="i"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_sw", 3, PinsN("41", dir="i"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ *ButtonResources(pins="63 64", invert=True, attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
+ *SwitchResources(pins="37 38 39 41", invert=True, attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
UARTResource(0,
rx="88", tx="85", rts="91", cts="94",
+from .user import LEDResources, RGBLEDResource, ButtonResources, SwitchResources
from .uart import UARTResource
-from .flash import SPIFlashResources
from .spi import SPIResource
+from .flash import SPIFlashResources
from .sram import SRAMResource
--- /dev/null
+from nmigen.build import *
+
+
+__all__ = ["UserLEDResource"]
+
+
+def _SplitResources(*args, pins, invert=False, attrs=None, default_name, dir):
+ assert isinstance(pins, (str, list, dict))
+
+ if isinstance(pins, str):
+ pins = pins.split()
+ if isinstance(pins, list):
+ pins = dict(enumerate(pins))
+
+ resources = []
+ for number, pin in pins.items():
+ ios = [PinsN(pin, dir=dir) if invert else Pins(pin, dir=dir)]
+ if attrs is not None:
+ ios.append(attrs)
+ resources.append(Resource.family(*args, number, default_name=default_name, ios=ios))
+ return resources
+
+
+def LEDResources(*args, **kwargs):
+ return _SplitResources(*args, **kwargs, default_name="led", dir="o")
+
+
+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)))
+ if attrs is not None:
+ ios.append(attrs)
+ return Resource.family(*args, default_name="rgb_led", ios=ios)
+
+
+def ButtonResources(*args, **kwargs):
+ return _SplitResources(*args, **kwargs, default_name="button", dir="i")
+
+
+def SwitchResources(*args, **kwargs):
+ return _SplitResources(*args, **kwargs, default_name="switch", dir="i")
Resource("clk48", 0, Pins("F5", dir="i"),
Clock(48e6), Attrs(GLOBAL=True, IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 0, PinsN("A5", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("rgb_led", 0,
- Subsignal("r", PinsN("C5")),
- Subsignal("g", PinsN("B5")),
- Subsignal("b", PinsN("A5")),
- Attrs(IO_STANDARD="SB_LVCMOS"),
+ *LEDResources(pins="A5", invert=True, attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
+ RGBLEDResource(0,
+ r="C5", g="B5", b="A5", invert=True,
+ attrs=Attrs(IO_STANDARD="SB_LVCMOS")
),
Resource("usb", 0,
Resource("clk3p3", 0, Pins("13", dir="i"), Clock(3.3e6),
Attrs(GLOBAL=True, IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 0, Pins("59", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 1, Pins("56", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 2, Pins("53", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 3, Pins("51", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
-
- Resource("user_btn", 0, Pins("60"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_btn", 1, Pins("57"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_btn", 2, Pins("54"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_btn", 3, Pins("52"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ *LEDResources(pins="59 56 53 51", attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
+
+ Resource("touch", 0, Pins("60"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ Resource("touch", 1, Pins("57"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ Resource("touch", 2, Pins("54"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ Resource("touch", 3, Pins("52"), Attrs(IO_STANDARD="SB_LVCMOS")),
*SPIFlashResources(0,
cs="49", clk="48", mosi="45", miso="46",
Resource("clk12", 0, Pins("J3", dir="i"),
Clock(12e6), Attrs(GLOBAL=True, IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 0, Pins("C3", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")), # D2
- Resource("user_led", 1, Pins("B3", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")), # D3
- Resource("user_led", 2, Pins("C4", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")), # D4
- Resource("user_led", 3, Pins("C5", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")), # D5
- Resource("user_led", 4, Pins("A1", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")), # D6
- Resource("user_led", 5, Pins("A2", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")), # D7
- Resource("user_led", 6, Pins("B4", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")), # D8
- Resource("user_led", 7, Pins("B5", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")), # D9
+ *LEDResources(
+ pins="C3 B3 C4 C5 A1 A2 B4 B5",
+ attrs=Attrs(IO_STANDARD="SB_LVCMOS")
+ ), # D2..D9
UARTResource(0,
rx="B10", tx="B12", rts="B13", cts="A15", dtr="A16", dsr="B14", dcd="B15",
Resource("clk12", 0, Pins("35", dir="i"),
Clock(12e6), Attrs(GLOBAL=True, IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 0, PinsN("11", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 1, PinsN("37", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- # Color-specific aliases
- Resource("user_ledr", 0, PinsN("11", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_ledg", 0, PinsN("37", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ *LEDResources(pins="11 37", invert=True, attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
+ # Semantic aliases
+ Resource("led_r", 0, PinsN("11", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ Resource("led_g", 0, PinsN("37", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_btn", 0, PinsN("10", dir="i"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ *ButtonResources(pins="10", invert=True, attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
UARTResource(0,
rx="6", tx="9",
Resource("clk12", 0, Pins("21", dir="i"),
Clock(12e6), Attrs(GLOBAL=True, IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 0, Pins("99", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 1, Pins("98", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 2, Pins("97", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 3, Pins("96", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 4, Pins("95", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ *LEDResources(pins="99 98 97 96 95", attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
UARTResource(0,
rx="9", tx="8", rts="7", cts="4", dtr="3", dsr="2", dcd="1",
Resource("clk156", 0, DiffPairs("K28", "K29", dir="i"),
Clock(156e6), Attrs(IOSTANDARD="LVDS_25")),
- Resource("user_led", 0, Pins("AB8", dir="o"), Attrs(IOSTANDARD="LVCMOS15")),
- Resource("user_led", 1, Pins("AA8", dir="o"), Attrs(IOSTANDARD="LVCMOS15")),
- Resource("user_led", 2, Pins("AC9", dir="o"), Attrs(IOSTANDARD="LVCMOS15")),
- Resource("user_led", 3, Pins("AB9", dir="o"), Attrs(IOSTANDARD="LVCMOS15")),
- Resource("user_led", 4, Pins("AE26", dir="o"), Attrs(IOSTANDARD="LVCMOS15")),
- Resource("user_led", 5, Pins("G19", dir="o"), Attrs(IOSTANDARD="LVCMOS15")),
- Resource("user_led", 6, Pins("E18", dir="o"), Attrs(IOSTANDARD="LVCMOS15")),
- Resource("user_led", 7, Pins("F16", dir="o"), Attrs(IOSTANDARD="LVCMOS15")),
+ *LEDResources(pins="AB8 AA8 AC9 AB9 AE26 G19 E18 F16",
+ attrs=Attrs(IOSTANDARD="LVCMOS15")),
UARTResource(0,
rx="M19", tx="K24",
# Some default useful extensions. Attach to platform using:
# p.add_resources(p.leds)
- # pmod_btn = plat.request("user_led")
+ # pmod_btn = plat.request("led")
leds = [
- Resource("user_led", 0, Pins("1", dir="o", conn=("led", 0)),
+ Resource("led", 0, Pins("1", dir="o", conn=("led", 0)),
Attrs(IOSTANDARD="LVTTL")),
- Resource("user_led", 1, Pins("2", dir="o", conn=("led", 0)),
+ Resource("led", 1, Pins("2", dir="o", conn=("led", 0)),
Attrs(IOSTANDARD="LVTTL")),
- Resource("user_led", 2, Pins("3", dir="o", conn=("led", 0)),
+ Resource("led", 2, Pins("3", dir="o", conn=("led", 0)),
Attrs(IOSTANDARD="LVTTL")),
- Resource("user_led", 3, Pins("4", dir="o", conn=("led", 0)),
+ Resource("led", 3, Pins("4", dir="o", conn=("led", 0)),
Attrs(IOSTANDARD="LVTTL")),
]
# The remaining peripherals only make sense w/ the Baseboard installed.
# See: http://www.micro-nova.com/mercury-baseboard/
- _user_sw = [
- Resource("user_sw", 0, Pins("1", dir="i", conn=("gpio", 0)),
+ _switches = [
+ Resource("switch", 0, Pins("1", dir="i", conn=("gpio", 0)),
Attrs(IOSTANDARD="LVTTL")),
- Resource("user_sw", 1, Pins("2", dir="i", conn=("gpio", 0)),
+ Resource("switch", 1, Pins("2", dir="i", conn=("gpio", 0)),
Attrs(IOSTANDARD="LVTTL")),
- Resource("user_sw", 2, Pins("3", dir="i", conn=("gpio", 0)),
+ Resource("switch", 2, Pins("3", dir="i", conn=("gpio", 0)),
Attrs(IOSTANDARD="LVTTL")),
- Resource("user_sw", 3, Pins("4", dir="i", conn=("gpio", 0)),
+ Resource("switch", 3, Pins("4", dir="i", conn=("gpio", 0)),
Attrs(IOSTANDARD="LVTTL")),
- Resource("user_sw", 4, Pins("5", dir="i", conn=("gpio", 0)),
+ Resource("switch", 4, Pins("5", dir="i", conn=("gpio", 0)),
Attrs(IOSTANDARD="LVTTL")),
- Resource("user_sw", 5, Pins("6", dir="i", conn=("gpio", 0)),
+ Resource("switch", 5, Pins("6", dir="i", conn=("gpio", 0)),
Attrs(IOSTANDARD="LVTTL")),
- Resource("user_sw", 6, Pins("7", dir="i", conn=("gpio", 0)),
+ Resource("switch", 6, Pins("7", dir="i", conn=("gpio", 0)),
Attrs(IOSTANDARD="LVTTL")),
- Resource("user_sw", 7, Pins("8", dir="i", conn=("gpio", 0)),
+ Resource("switch", 7, Pins("8", dir="i", conn=("gpio", 0)),
Attrs(IOSTANDARD="LVTTL"))
]
- _user_btn = [
- Resource("user_btn", 1, Pins("1", dir="i", conn=("input", 0)),
+ _buttons = [
+ Resource("button", 1, Pins("1", dir="i", conn=("input", 0)),
Attrs(IOSTANDARD="LVTTL")),
- Resource("user_btn", 2, Pins("2", dir="i", conn=("input", 0)),
+ Resource("button", 2, Pins("2", dir="i", conn=("input", 0)),
Attrs(IOSTANDARD="LVTTL")),
- Resource("user_btn", 3, Pins("3", dir="i", conn=("input", 0)),
+ Resource("button", 3, Pins("3", dir="i", conn=("input", 0)),
Attrs(IOSTANDARD="LVTTL")),
- Resource("user_btn", 4, Pins("4", dir="i", conn=("input", 0)),
+ Resource("button", 4, Pins("4", dir="i", conn=("input", 0)),
Attrs(IOSTANDARD="LVTTL"))
]
)
]
- baseboard_sram = _user_btn + _vga + _extclk + _ps2
- baseboard_no_sram = _user_btn + _vga + _extclk + _ps2 + \
- _user_sw + _sevenseg + _audio
+ baseboard_sram = _buttons + _vga + _extclk + _ps2
+ baseboard_no_sram = baseboard_sram + _switches + _sevenseg + _audio
def toolchain_program(self, products, name):
# https://github.com/cr1901/mercpcl
Resource("clk100", 0, Pins("P126", dir="i"),
Clock(100e6), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_led", 0, Pins("P119", dir="o"),
- Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_led", 1, Pins("P118", dir="o"),
- Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_led", 2, Pins("P117", dir="o"),
- Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_led", 3, Pins("P116", dir="o"),
- Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_led", 4, Pins("P115", dir="o"),
- Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_led", 5, Pins("P114", dir="o"),
- Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_led", 6, Pins("P112", dir="o"),
- Attrs(IOSTANDARD="LVCMOS33")),
- Resource("user_led", 7, Pins("P111", dir="o"),
- Attrs(IOSTANDARD="LVCMOS33")),
-
- Resource("user_btn", 0, Pins("P124", dir="i"),
- Attrs(IOSTANDARD="LVCMOS33", PULLUP="TRUE")),
- Resource("user_btn", 1, Pins("P123", dir="i"),
- Attrs(IOSTANDARD="LVCMOS33", PULLUP="TRUE")),
- Resource("user_btn", 2, Pins("P121", dir="i"),
- Attrs(IOSTANDARD="LVCMOS33", PULLUP="TRUE")),
- Resource("user_btn", 3, Pins("P120", dir="i"),
- Attrs(IOSTANDARD="LVCMOS33", PULLUP="TRUE")),
+ *LEDResources(pins="P119 P118 P117 P116 P115 P114 P112 P111",
+ attrs=Attrs(IOSTANDARD="LVCMOS33")),
+ *ButtonResources(pins="P124 P123 P121 P120",
+ attrs=Attrs(IOSTANDARD="LVCMOS33", PULLUP="TRUE")),
*SPIFlashResources(0,
cs="P38", clk="P70", mosi="P64", miso="65",
Resource("clk16", 0, Pins("B2", dir="i"),
Clock(16e6), Attrs(IO_STANDARD="SB_LVCMOS")),
- Resource("user_led", 0, Pins("B3", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS")),
+ *LEDResources(pins="B3", attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
Resource("usb", 0,
Subsignal("d_p", Pins("B4", dir="io")),
Resource("pclk", 0, DiffPairs("A4", "A5", dir="i"),
Attrs(IO_TYPE="LVDS")),
- Resource("user_led", 0, PinsN("E16", dir="o"), Attrs(IO_TYPE="LVCMOS25")),
- Resource("user_led", 1, PinsN("D17", dir="o"), Attrs(IO_TYPE="LVCMOS25")),
- Resource("user_led", 2, PinsN("D18", dir="o"), Attrs(IO_TYPE="LVCMOS25")),
- Resource("user_led", 3, PinsN("E18", dir="o"), Attrs(IO_TYPE="LVCMOS25")),
- Resource("user_led", 4, PinsN("F17", dir="o"), Attrs(IO_TYPE="LVCMOS25")),
- Resource("user_led", 5, PinsN("F18", dir="o"), Attrs(IO_TYPE="LVCMOS25")),
- Resource("user_led", 6, PinsN("E17", dir="o"), Attrs(IO_TYPE="LVCMOS25")),
- Resource("user_led", 7, PinsN("F16", dir="o"), Attrs(IO_TYPE="LVCMOS25")),
+ *LEDResources(pins="E16 D17 D18 E18 F17 F18 E17 F16",
+ attrs=Attrs(IO_TYPE="LVCMOS25")),
Resource("alnum_led", 0,
Subsignal("a", PinsN("M20", dir="o")),
Attrs(IO_TYPE="LVCMOS25")
),
- Resource("user_sw", 0, PinsN("H2", dir="i"), Attrs(IO_TYPE="LVCMOS15")),
- Resource("user_sw", 1, PinsN("K3", dir="i"), Attrs(IO_TYPE="LVCMOS15")),
- Resource("user_sw", 2, PinsN("G3", dir="i"), Attrs(IO_TYPE="LVCMOS15")),
- Resource("user_sw", 3, PinsN("F2", dir="i"), Attrs(IO_TYPE="LVCMOS15")),
- Resource("user_sw", 4, PinsN("J18", dir="i"), Attrs(IO_TYPE="LVCMOS25")),
- Resource("user_sw", 5, PinsN("K18", dir="i"), Attrs(IO_TYPE="LVCMOS25")),
- Resource("user_sw", 6, PinsN("K19", dir="i"), Attrs(IO_TYPE="LVCMOS25")),
- Resource("user_sw", 7, PinsN("K20", dir="i"), Attrs(IO_TYPE="LVCMOS25")),
+ *SwitchResources(pins={0: "H2", 1: "K3", 2: "G3", 3: "F2" },
+ attrs=Attrs(IO_TYPE="LVCMOS15")),
+ *SwitchResources(pins={4: "J18", 5: "K18", 6: "K19", 7: "K20"},
+ attrs=Attrs(IO_TYPE="LVCMOS15")),
UARTResource(0,
rx="C11", tx="A11",