[breaking-change] Factor out "sram" resource.
authorwhitequark <whitequark@whitequark.org>
Sun, 4 Aug 2019 11:08:45 +0000 (11:08 +0000)
committerwhitequark <whitequark@whitequark.org>
Sun, 4 Aug 2019 11:08:45 +0000 (11:08 +0000)
Fixes #9.

nmigen_boards/blackice.py
nmigen_boards/blackice_ii.py
nmigen_boards/dev/__init__.py
nmigen_boards/dev/sram.py [new file with mode: 0644]

index aa84d5eb073eb6e9a4858a250e6c57106081005e..51d09e49e84571686e36e747c79176beccbf93d3 100644 (file)
@@ -41,19 +41,11 @@ class BlackIcePlatform(LatticeICE40Platform):
             attrs=Attrs(IO_STANDARD="SB_LVCMOS33", PULLUP="1")
         ),
 
-        Resource("sram", 0,
-            Subsignal("address", Pins(
-                "137 138 139 141 142 42 43 44 73 74 75 76 115 116 117 118 119 78",
-                dir="o"
-            )),
-            Subsignal("data", Pins(
-                "135 134 130 128 125 124 122 121 61 60 56 55 52 49 48 47",
-                dir="io"
-            )),
-            Subsignal("oe", PinsN("45", dir="o")),
-            Subsignal("we", PinsN("120", dir="o")),
-            Subsignal("cs", PinsN("136", dir="o")),
-            Attrs(IO_STANDARD="SB_LVCMOS33"),
+        SRAMResource(0,
+            cs="136", oe="45", we="120",
+            a="137 138 139 141 142 42 43 44 73 74 75 76 115 116 117 118 119 78",
+            d="135 134 130 128 125 124 122 121 61 60 56 55 52 49 48 47",
+            attrs=Attrs(IO_STANDARD="SB_LVCMOS33"),
         ),
     ]
     connectors  = [
index b17221c955f0745856eb6b032f9457f40ed37867..040a8f8c73db4d0714a78ef0ae36311ab8779c22 100644 (file)
@@ -41,21 +41,12 @@ class BlackIceIIPlatform(LatticeICE40Platform):
             attrs=Attrs(IO_STANDARD="SB_LVCMOS33", PULLUP="1")
         ),
 
-        Resource("sram", 0,
-            Subsignal("address", Pins(
-                "137 138 139 141 142 42 43 44 73 74 75 76 115 116 117 118 119 78",
-                dir="o"
-            )),
-            Subsignal("data", Pins(
-                "136 135 134 130 125 124 122 121 62 61 60 56 55 48 47 45",
-                dir="io"
-            )),
-            Subsignal("oe", PinsN("29", dir="o")),
-            Subsignal("we", PinsN("120", dir="o")),
-            Subsignal("cs", PinsN("136", dir="o")),
-            Subsignal("ub", PinsN("28", dir="o")),
-            Subsignal("lb", PinsN("24", dir="o")),
-            Attrs(IO_STANDARD="SB_LVCMOS33"),
+        SRAMResource(0,
+            cs="136", oe="29", we="120",
+            a="137 138 139 141 142 42 43 44 73 74 75 76 115 116 117 118 119 78",
+            d="136 135 134 130 125 124 122 121 62 61 60 56 55 48 47 45",
+            dm="24 28",
+            attrs=Attrs(IO_STANDARD="SB_LVCMOS33"),
         ),
     ]
     connectors  = [
index 1af4fe2b255bcb136f74925230b8cdfaf619af55..242b0f9aeffaba3be8eddf4f82adfe4af5779da4 100644 (file)
@@ -1,3 +1,4 @@
 from .uart import UARTResource
 from .flash import SPIFlashResources
 from .spi import SPIResource
+from .sram import SRAMResource
diff --git a/nmigen_boards/dev/sram.py b/nmigen_boards/dev/sram.py
new file mode 100644 (file)
index 0000000..4e2cd91
--- /dev/null
@@ -0,0 +1,18 @@
+from nmigen.build import *
+
+
+__all__ = ["SRAMResource"]
+
+
+def SRAMResource(*args, cs, oe, we, a, d, dm=None, attrs=None):
+    io = []
+    io.append(Subsignal("cs", PinsN(cs, dir="o")))
+    io.append(Subsignal("oe", PinsN(oe, dir="o")))
+    io.append(Subsignal("we", PinsN(we, dir="o")))
+    io.append(Subsignal("a", Pins(a, dir="o")))
+    io.append(Subsignal("d", Pins(d, dir="io")))
+    if dm is not None:
+        io.append(Subsignal("dm", PinsN(dm, dir="o"))) # dm="LB# UB#"
+    if attrs is not None:
+        io.append(attrs)
+    return Resource.family(*args, default_name="sram", ios=io)