|
| 1 | +from litex.build.generic_platform import * |
| 2 | +from litex.build.lattice import LatticePlatform |
| 3 | +from litex.build.lattice.programmer import IceStormProgrammer |
| 4 | + |
| 5 | + |
| 6 | +_io = [ |
| 7 | + ("user_led_n", 0, Pins("47"), IOStandard("LVCMOS33")), |
| 8 | + # RGB LED |
| 9 | + ("user_ledr_n", 0, Pins("41"), IOStandard("LVCMOS33")), |
| 10 | + ("user_ledg_n", 0, Pins("40"), IOStandard("LVCMOS33")), |
| 11 | + ("user_ledb_n", 0, Pins("39"), IOStandard("LVCMOS33")), |
| 12 | + |
| 13 | + ("serial", 0, |
| 14 | + Subsignal("rx", Pins("23")), |
| 15 | + Subsignal("tx", Pins("21"), Misc("PULLUP")), |
| 16 | + IOStandard("LVCMOS33") |
| 17 | + ), |
| 18 | + |
| 19 | + ("spiflash", 0, |
| 20 | + Subsignal("cs_n", Pins("16"), IOStandard("LVCMOS33")), |
| 21 | + Subsignal("clk", Pins("15"), IOStandard("LVCMOS33")), |
| 22 | + Subsignal("miso", Pins("17"), IOStandard("LVCMOS33")), |
| 23 | + Subsignal("mosi", Pins("14"), IOStandard("LVCMOS33")), |
| 24 | + # TODO: Do not need these |
| 25 | + Subsignal("wp", Pins("12"), IOStandard("LVCMOS33")), |
| 26 | + Subsignal("hold", Pins("13"), IOStandard("LVCMOS33")), |
| 27 | + ), |
| 28 | + |
| 29 | + ("spiflash4x", 0, |
| 30 | + Subsignal("cs_n", Pins("16"), IOStandard("LVCMOS33")), |
| 31 | + Subsignal("clk", Pins("15"), IOStandard("LVCMOS33")), |
| 32 | + # TODO: Find out quad-spi pins |
| 33 | + Subsignal("dq", Pins("14 17 12 13"), IOStandard("LVCMOS33")), |
| 34 | + ), |
| 35 | + |
| 36 | + ("clk12", 0, Pins("35"), IOStandard("LVCMOS33")) |
| 37 | +] |
| 38 | + |
| 39 | +_connectors = [ |
| 40 | + ("RGBLED", "6 4 3"), |
| 41 | +] |
| 42 | + |
| 43 | +rgb_led = [ |
| 44 | + ("rgbled", 0, |
| 45 | + Subsignal("rgb0", Pins("RGBLED:0")), |
| 46 | + Subsignal("rgb1", Pins("RGBLED:1")), |
| 47 | + Subsignal("rgb2", Pins("RGBLED:2")), |
| 48 | + IOStandard("LVCMOS33") |
| 49 | + ), |
| 50 | +] |
| 51 | + |
| 52 | + |
| 53 | +class Platform(LatticePlatform): |
| 54 | + default_clk_name = "clk12" |
| 55 | + default_clk_period = 83.333 |
| 56 | + |
| 57 | + gateware_size = 0x20000 |
| 58 | + |
| 59 | + # FIXME: Create a "spi flash module" object in the same way we have SDRAM |
| 60 | + spiflash_model = "n25q128" |
| 61 | + spiflash_read_dummy_bits = 8 |
| 62 | + spiflash_clock_div = 2 |
| 63 | + spiflash_total_size = int((128/8)*1024*1024) # 128Mbit |
| 64 | + spiflash_page_size = 256 |
| 65 | + # Winbond calls 32kb/64kb sectors "blocks". |
| 66 | + spiflash_sector_size = 0x10000 |
| 67 | + |
| 68 | + def __init__(self): |
| 69 | + LatticePlatform.__init__(self, "ice40-up5k-sg48", _io, _connectors, |
| 70 | + toolchain="icestorm") |
| 71 | + |
| 72 | + def create_programmer(self): |
| 73 | + return IceStormProgrammer() |
0 commit comments