from gram.modules import MT41K256M16, MT41K64M16
from gram.frontend.wishbone import gramWishbone
+# SPI
+from nmigen.build import Resource
+from nmigen.build import Subsignal
+from nmigen.build import Pins
+
# Board (and simulation) platforms
from nmigen_boards.versa_ecp5 import VersaECP5Platform
from nmigen_boards.versa_ecp5 import VersaECP5Platform85 # custom board
# The main SPI Flash (SPI 1) should be set to at
# least 28 bits (256MB) to allow the use of large 4BA devices.
self.spi0 = Tercel(data_width=32, spi_region_addr_width=24,
+ adr_offset=spi0_addr,
features={'stall'},
clk_freq=clk_freq,
pins=spi_0_pins,
# Get SPI resource pins
spi_0_pins = None
- if platform is not None and fpga in ['rcs_arctic_tern_bmc_card',
- 'isim',
- 'arty_a7',
- 'versa_ecp5_85',
- 'versa_ecp5']:
- # XXX naming-conventions for nmigen_boards/resources/interface.py
- # SPIResource are "spi" not "spi_0", and for SPIFlashResources
- # the name convention is "spi_flash_1x" (or 2x or 4x)
- if toolchain == 'Trellis':
- # The ECP5 series FPGAs handle the SPI clock directly on
- # the FPGA configuration Flash device
- spi_0_pins = platform.request("spi_flash_4x", 0,
- dir={"dq":"io", "cs":"o"},
- xdr={"dq": 1, "cs": 1})
- else:
- spi_0_pins = platform.request("spi_flash_4x", 0,
- dir={"dq":"io", "cs":"o", "clk":"o"},
- xdr={"dq": 1, "cs": 1, "clk": 0})
+ if platform is not None and \
+ fpga in ['versa_ecp5', 'versa_ecp5_85', 'isim']:
+ # Override here to get FlashResource out of the way and enable Tercel
+ # direct access to the SPI flash
+ spi_0_ios = [ Resource("spi_0", 0,
+ Subsignal("dq", Pins("W2 V2 Y2 W1", dir="io")),
+ Subsignal("cs_n", Pins("R2", dir="o")),
+ Attrs(PULLMODE="NONE", DRIVE="4",
+ IO_TYPE="LVCMOS33")) ]
+ platform.add_resources(spi_0_ios)
+ spi_0_pins = platform.request("spi_0", 0, dir={"dq":"io", "cs_n":"o"},
+ xdr={"dq":1, "cs_n":0})
+
print ("spiflash pins", spi_0_pins)
# Get Ethernet RMII resource pins