--- /dev/null
+from .flash import SPIFlashResources
--- /dev/null
+from nmigen.build import *
+
+
+__all__ = ["SPIFlashResources"]
+
+
+def SPIFlashResources(number, *, cs_n, clk, mosi, miso, wp_n=None, hold_n=None, attrs=None):
+ resources = []
+
+ io_all = []
+ if attrs is not None:
+ io_all.append(attrs)
+ io_all.append(Subsignal("cs_n", Pins(cs_n, dir="o")))
+ io_all.append(Subsignal("clk", Pins(clk, dir="o")))
+
+ io_1x = list(io_all)
+ io_1x.append(Subsignal("mosi", Pins(mosi, dir="o")))
+ io_1x.append(Subsignal("miso", Pins(miso, dir="i")))
+ if wp_n is not None and hold_n is not None:
+ # Tristate these pins by default, and rely on a pullup on the board or within the flash.
+ # An alternative would be to define them as outputs with reset value of 1, but that's
+ # not currently possible in nMigen.
+ io_1x.append(Subsignal("wp_n", Pins(wp_n, dir="oe")))
+ io_1x.append(Subsignal("hold_n", Pins(hold_n, dir="oe")))
+ resources.append(Resource("spiflash", number, *io_1x))
+
+ io_2x = list(io_all)
+ io_2x.append(Subsignal("dq", Pins(" ".join([mosi, miso]), dir="io")))
+ resources.append(Resource("spiflash2x", number, *io_2x))
+
+ if wp_n is not None and hold_n is not None:
+ io_4x = list(io_all)
+ io_4x.append(Subsignal("dq", Pins(" ".join([mosi, miso, wp_n, hold_n]), dir="io")))
+ resources.append(Resource("spiflash4x", number, *io_4x))
+
+ return resources
from nmigen.build import *
from nmigen.vendor.lattice_ice40 import *
+from .dev import *
__all__ = ["ICE40HX1KBlinkEVNPlatform"]
Resource("user_btn", 2, Pins("54"), Attrs(IO_STANDARD="SB_LVCMOS33")),
Resource("user_btn", 3, Pins("52"), Attrs(IO_STANDARD="SB_LVCMOS33")),
- Resource("spiflash", 0,
- Subsignal("cs_n", Pins("49", dir="o")),
- Subsignal("clk", Pins("48", dir="o")),
- Subsignal("mosi", Pins("45", dir="o")),
- Subsignal("miso", Pins("46", dir="i")),
- Attrs(IO_STANDARD="SB_LVCMOS33")
+ *SPIFlashResources(0,
+ cs_n="49", clk="48",
+ mosi="45", miso="46",
+ attrs=Attrs(IO_STANDARD="SB_LVCMOS33")
),
]
connectors = [
\r
from nmigen.build import *\r
from nmigen.vendor.lattice_ice40 import *\r
+from .dev import *\r
\r
\r
__all__ = ["ICEBreakerPlatform"]\r
Attrs(IO_STANDARD="SB_LVTTL")\r
),\r
\r
- Resource("spiflash", 0,\r
- Subsignal("cs_n", Pins("16", dir="o")),\r
- Subsignal("clk", Pins("15", dir="o")),\r
- Subsignal("mosi", Pins("14", dir="o")),\r
- Subsignal("miso", Pins("17", dir="i")),\r
- Subsignal("wp", Pins("12", dir="o")),\r
- Subsignal("hold", Pins("13", dir="o")),\r
- Attrs(IO_STANDARD="SB_LVCMOS33")\r
- ),\r
-\r
- Resource("spiflash4x", 0,\r
- Subsignal("cs_n", Pins("16", dir="o")),\r
- Subsignal("clk", Pins("15", dir="o")),\r
- Subsignal("dq", Pins("14 17 12 13", dir="io")),\r
- Attrs(IO_STANDARD="SB_LVCMOS33")\r
+ *SPIFlashResources(0,\r
+ cs_n="16", clk="15",\r
+ mosi="14", miso="17",\r
+ wp_n="12", hold_n="13",\r
+ attrs=Attrs(IO_STANDARD="SB_LVCMOS33")\r
),\r
]\r
connectors = [\r
from nmigen.build import *
from nmigen.vendor.lattice_ice40 import *
+from .dev import *
__all__ = ["ICEStickPlatform"]
Attrs(IO_STANDARD="SB_LVCMOS33")
),
- Resource("spiflash", 0,
- Subsignal("cs_n", Pins("71", dir="o")),
- Subsignal("clk", Pins("70", dir="o")),
- Subsignal("mosi", Pins("67", dir="o")),
- Subsignal("miso", Pins("68", dir="i")),
- Attrs(IO_STANDARD="SB_LVCMOS33")
+ *SPIFlashResources(0,
+ cs_n="71", clk="70",
+ mosi="67", miso="68",
+ attrs=Attrs(IO_STANDARD="SB_LVCMOS33")
),
]
connectors = [
from nmigen.build import *
from nmigen.vendor.lattice_ice40 import *
+from .dev import *
__all__ = ["TinyFPGABXPlatform"]
Attrs(IO_STANDARD="SB_LVCMOS33")
),
- Resource("spiflash", 0,
- Subsignal("cs_n", Pins("F7", dir="o")),
- Subsignal("clk", Pins("G7", dir="o")),
- Subsignal("mosi", Pins("G6", dir="o")),
- Subsignal("miso", Pins("H7", dir="i")),
- Subsignal("wp", Pins("H4", dir="o")),
- Subsignal("hold", Pins("J8", dir="o")),
- Attrs(IO_STANDARD="SB_LVCMOS33")
- ),
-
- Resource("spiflash4x", 0,
- Subsignal("cs_n", Pins("F7", dir="o")),
- Subsignal("clk", Pins("G7", dir="o")),
- Subsignal("dq", Pins("G6 H7 H4 J8", dir="io")),
- Attrs(IO_STANDARD="SB_LVCMOS33")
- ),
+ *SPIFlashResources(0,
+ cs_n="F7", clk="G7",
+ mosi="G6", miso="H7", wp_n="H4", hold_n="J8",
+ attrs=Attrs(IO_STANDARD="SB_LVCMOS33")),
]
connectors = [
Connector("gpio", 0,