# # This file is part of LiteX-Boards. # # Copyright (c) 2023 Antmicro # SPDX-License-Identifier: BSD-2-Clause from litex.build.generic_platform import * from litex.build.lattice import LatticeNexusPlatform from litex.build.lattice.programmer import LatticeProgrammer from litex.build.lattice.programmer import EcpprogProgrammer # IOs ---------------------------------------------------------------------------------------------- _io = [ # Clk. ("clk12", 0, Pins("G15"), IOStandard("LVCMOS33")), # Serial. ("serial", 0, Subsignal("tx", Pins("J12"), IOStandard("LVCMOS33")), Subsignal("rx", Pins("J11"), IOStandard("LVCMOS33")), ), # Leds (Section 7.3). ("user_led", 0, Pins("E15"), IOStandard("LVCMOS33")), ("user_led", 1, Pins("E16"), IOStandard("LVCMOS33")), # DIP Switches (Section 7.1). ("user_dip_btn", 0, Pins("F15"), IOStandard("LVCMOS33")), ("user_dip_btn", 1, Pins("H10"), IOStandard("LVCMOS33")), # SPI Flash (Section 6.3.1.). ("spiflash", 0, Subsignal("cs_n", Pins("C15")), Subsignal("clk", Pins("C16")), Subsignal("mosi", Pins("C14")), Subsignal("miso", Pins("D16")), IOStandard("LVCMOS33") ) ] # Connectors --------------------------------------------------------------------------------------- _connectors = [] # Platform ----------------------------------------------------------------------------------------- class Platform(LatticeNexusPlatform): default_clk_name = "clk12" default_clk_period = 1e9/12e6 def __init__(self, device="LIFCL-40-9BG400C", toolchain="radiant", **kwargs): # Accept "LIFCL" for backwards compatibility. # LIFCL just means Crosslink-NX so we can expect every # Crosslink-NX Evaluation Board to have a LIFCL part. if device == "LIFCL": device == "LIFCL-40-9BG400C" assert device in ["LIFCL-40-9BG256C", "LIFCL-40-9BG400C", "LIFCL-40-8BG400CES", "LIFCL-40-8BG400CES2", "LIFCL-40-8BG400C"] LatticeNexusPlatform.__init__(self, device, _io, _connectors, toolchain=toolchain, **kwargs) def create_programmer(self, mode="direct", prog="radiant"): assert mode in ["direct", "flash"] assert prog in ["radiant", "ecpprog"] if prog == "ecpprog": return EcpprogProgrammer() xcf_template_direct = """ JTAG 1 Lattice LIFCL LIFCL-40 0x010f1043 All LIFCL-40 8 11111111 1 0 {bitstream_file} N/A Static Random Access Memory (SRAM) Fast Configuration SEQUENTIAL ENTIRED CHAIN No Override TLR TLR 3 USB2 FTUSB-0 """ xcf_template_flash = """ JTAG2SPI 1 Lattice LIFCL LIFCL-40 All 8 11111111 1 0 {bitstream_file} External SPI Flash Memory (SPI FLASH) Erase,Program,Verify 1 Lattice LIFCL LIFCL-40 0x010f1043 All LIFCL-40 8 11111111 1 0 Static Random Access Memory (SRAM) Refresh Verify ID 1 Macronix SPI Serial Flash MX25L12833F 0x18 8-pin SOP Erase,Program,Verify {bitstream_file} 0x00000000 0x000F0000 128 1016029 1 1 {bitstream_file} SEQUENTIAL ENTIRED CHAIN No Override TLR TLR 3 USB2 FTUSB-0 Lattice CrossLink-NX Eval Board A Location 0000 Serial FT4J4IK9A """ if mode == "direct": xcf_template = xcf_template_direct if mode == "flash": xcf_template = xcf_template_flash return LatticeProgrammer(xcf_template)