cores/spi_flash: add non-memory mapped S7SPIFlash modules based on SPIMaster (for...
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 5 Jul 2019 17:01:55 +0000 (19:01 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 5 Jul 2019 17:01:55 +0000 (19:01 +0200)
litex/soc/cores/spi_flash.py

index 65e32cd42f3169775c8e0ed334593dbc741247a2..caf81b809f3cb73db06af2445cf2057eb2151516 100644 (file)
@@ -12,8 +12,10 @@ from migen.genlib.misc import timeline
 from litex.gen import *
 
 from litex.soc.interconnect import wishbone
-from litex.soc.interconnect.csr import AutoCSR, CSRStorage, CSRStatus
+from litex.soc.interconnect.csr import *
+from litex.soc.cores.spi import SPIMaster
 
+# SpiFlash Quad/Dual/Single (memory-mapped) --------------------------------------------------------
 
 _FAST_READ = 0x0b
 _DIOFR = 0xbb
@@ -275,3 +277,31 @@ def SpiFlash(pads, *args, **kw):
         return SpiFlashSingle(pads, *args, **kw)
     else:
         return SpiFlashDualQuad(pads, *args, **kw)
+
+
+# Xilinx 7-Series FPGAs SPI Flash (non-memory-mapped) ----------------------------------------------
+
+class S7SPIFlash(Module, AutoCSR):
+    def __init__(self, pads, sys_clk_freq, spi_clk_freq=25e6):
+        self.submodules.spi = spi = SPIMaster(None, 40, sys_clk_freq, spi_clk_freq)
+        self.specials += Instance("STARTUPE2",
+                i_CLK=0,
+                i_GSR=0,
+                i_GTS=0,
+                i_KEYCLEARB=0,
+                i_PACK=0,
+                i_USRCCLKO=spi.pads.clk,
+                i_USRCCLKTS=0,
+                i_USRDONEO=1,
+                i_USRDONETS=1
+        )
+        if hasattr(pads, "vpp"):
+            pads.vpp.reset = 1
+        if hasattr(pads, "hold"):
+            pads.hold.reset = 1
+
+        self.comb += [
+            pads.cs_n.eq(spi.pads.cs_n),
+            pads.mosi.eq(spi.pads.mosi),
+            spi.pads.miso.eq(pads.miso)
+        ]