dev: Refactor resource abstractions to use Resource.family.
authorWilliam D. Jones <thor0505@comcast.net>
Wed, 10 Jul 2019 16:05:45 +0000 (12:05 -0400)
committerwhitequark <whitequark@whitequark.org>
Wed, 10 Jul 2019 16:05:45 +0000 (16:05 +0000)
nmigen_boards/dev/flash.py
nmigen_boards/dev/uart.py

index 747d2395e31aef0b446546755741554b65ce8dfa..9cb8d90b975e6a586a9bca62a68661f47600706e 100644 (file)
@@ -4,7 +4,7 @@ from nmigen.build import *
 __all__ = ["SPIFlashResources"]
 
 
-def SPIFlashResources(number, *, cs, clk, mosi, miso, wp=None, hold=None, attrs=None):
+def SPIFlashResources(*args, cs, clk, mosi, miso, wp=None, hold=None, attrs=None):
     resources = []
 
     io_all = []
@@ -19,15 +19,18 @@ def SPIFlashResources(number, *, cs, clk, mosi, miso, wp=None, hold=None, attrs=
     if wp is not None and hold is not None:
         io_1x.append(Subsignal("wp",   PinsN(wp,   dir="o")))
         io_1x.append(Subsignal("hold", PinsN(hold, dir="o")))
-    resources.append(Resource("spi_flash", number, *io_1x))
+    resources.append(Resource.family(*args, default_name="spi_flash", ios=io_1x,
+                                     name_suffix="1x"))
 
     io_2x = list(io_all)
     io_2x.append(Subsignal("dq", Pins(" ".join([mosi, miso]), dir="io")))
-    resources.append(Resource("spi_flash_2x", number, *io_2x))
+    resources.append(Resource.family(*args, default_name="spi_flash", ios=io_2x,
+                                     name_suffix="2x"))
 
     if wp is not None and hold is not None:
         io_4x = list(io_all)
         io_4x.append(Subsignal("dq", Pins(" ".join([mosi, miso, wp, hold]), dir="io")))
-        resources.append(Resource("spi_flash_4x", number, *io_4x))
+        resources.append(Resource.family(*args, default_name="spi_flash", ios=io_4x,
+                                         name_suffix="4x"))
 
     return resources
index 495dbcfb4b90ac3f54dc5bc0f614eed9b608f9ac..ba2c1b04059401450bc8ed87b6d8ca6c427125cb 100644 (file)
@@ -4,7 +4,7 @@ from nmigen.build import *
 __all__ = ["UARTResource", "IrDAResource"]
 
 
-def UARTResource(number, *, rx, tx, rts=None, cts=None, dtr=None, dsr=None, dcd=None, ri=None,
+def UARTResource(*args, rx, tx, rts=None, cts=None, dtr=None, dsr=None, dcd=None, ri=None,
                  attrs=None):
     io = []
     io.append(Subsignal("rx", Pins(rx, dir="i")))
@@ -23,7 +23,7 @@ def UARTResource(number, *, rx, tx, rts=None, cts=None, dtr=None, dsr=None, dcd=
         io.append(Subsignal("ri", Pins(ri, dir="i")))
     if attrs is not None:
         io.append(attrs)
-    return Resource("uart", number, *io)
+    return Resource.family(*args, default_name="uart", ios=io)
 
 
 def IrDAResource(number, *, rx, tx, en=None, sd=None, attrs=None):