2020-08-23 09:00:17 -04:00
|
|
|
#
|
|
|
|
# This file is part of LiteX-Boards.
|
|
|
|
#
|
|
|
|
# Copyright (c) 2018 William D. Jones <thor0505@comcast.net>
|
|
|
|
# Copyright (c) 2019 Florent Kermarrec <florent@enjoy-digital.fr>
|
|
|
|
# SPDX-License-Identifier: BSD-2-Clause
|
2019-07-12 13:19:01 -04:00
|
|
|
|
2019-06-10 11:09:51 -04:00
|
|
|
from litex.build.generic_platform import *
|
2022-11-05 03:07:14 -04:00
|
|
|
from litex.build.lattice import LatticeiCE40Platform
|
2019-06-10 11:09:51 -04:00
|
|
|
from litex.build.lattice.programmer import TinyProgProgrammer
|
|
|
|
|
|
|
|
# IOs ----------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
_io = [
|
2020-11-03 04:48:41 -05:00
|
|
|
# Clk / Rst
|
|
|
|
("clk16", 0, Pins("B2"), IOStandard("LVCMOS33")),
|
|
|
|
|
|
|
|
# Leds
|
2019-06-10 11:09:51 -04:00
|
|
|
("user_led", 0, Pins("B3"), IOStandard("LVCMOS33")),
|
|
|
|
|
2020-11-03 04:48:41 -05:00
|
|
|
# USB
|
2019-06-10 11:09:51 -04:00
|
|
|
("usb", 0,
|
|
|
|
Subsignal("d_p", Pins("B4")),
|
|
|
|
Subsignal("d_n", Pins("A4")),
|
|
|
|
Subsignal("pullup", Pins("A3")),
|
|
|
|
IOStandard("LVCMOS33")
|
|
|
|
),
|
|
|
|
|
2020-11-03 04:48:41 -05:00
|
|
|
# SPIFlash
|
2019-06-10 11:09:51 -04:00
|
|
|
("spiflash", 0,
|
|
|
|
Subsignal("cs_n", Pins("F7"), IOStandard("LVCMOS33")),
|
2020-04-09 14:02:02 -04:00
|
|
|
Subsignal("clk", Pins("G7"), IOStandard("LVCMOS33")),
|
2019-06-10 11:09:51 -04:00
|
|
|
Subsignal("mosi", Pins("G6"), IOStandard("LVCMOS33")),
|
|
|
|
Subsignal("miso", Pins("H7"), IOStandard("LVCMOS33")),
|
2020-04-09 14:02:02 -04:00
|
|
|
Subsignal("wp", Pins("H4"), IOStandard("LVCMOS33")),
|
2019-06-10 11:09:51 -04:00
|
|
|
Subsignal("hold", Pins("J8"), IOStandard("LVCMOS33"))
|
|
|
|
),
|
|
|
|
("spiflash4x", 0,
|
|
|
|
Subsignal("cs_n", Pins("F7"), IOStandard("LVCMOS33")),
|
2020-04-09 14:02:02 -04:00
|
|
|
Subsignal("clk", Pins("G7"), IOStandard("LVCMOS33")),
|
|
|
|
Subsignal("dq", Pins("G6 H7 H4 J8"), IOStandard("LVCMOS33"))
|
2019-06-10 11:09:51 -04:00
|
|
|
),
|
|
|
|
]
|
|
|
|
|
|
|
|
# Connectors ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
_connectors = [
|
|
|
|
# A2-H2, Pins 1-13
|
|
|
|
# H9-A6, Pins 14-24
|
|
|
|
# G1-J2, Pins 25-31
|
2020-04-09 14:02:02 -04:00
|
|
|
("GPIO", "A2 A1 B1 C2 C1 D2 D1 E2 E1 G2 H1 J1 H2 H9 D9 D8 C9 A9 B8 A8 B7 A7 B6 A6"),
|
2019-06-10 11:09:51 -04:00
|
|
|
("EXTRA", "G1 J3 J4 G9 J9 E8 J2")
|
|
|
|
]
|
|
|
|
|
|
|
|
# Default peripherals
|
|
|
|
serial = [
|
|
|
|
("serial", 0,
|
|
|
|
Subsignal("tx", Pins("GPIO:0")),
|
|
|
|
Subsignal("rx", Pins("GPIO:1")),
|
|
|
|
IOStandard("LVCMOS33")
|
|
|
|
)
|
|
|
|
]
|
|
|
|
|
|
|
|
# Platform -----------------------------------------------------------------------------------------
|
|
|
|
|
2022-11-05 03:07:14 -04:00
|
|
|
class Platform(LatticeiCE40Platform):
|
2020-04-09 14:02:02 -04:00
|
|
|
default_clk_name = "clk16"
|
2019-08-07 02:47:08 -04:00
|
|
|
default_clk_period = 1e9/16e6
|
2019-06-10 11:09:51 -04:00
|
|
|
|
2020-11-12 07:33:30 -05:00
|
|
|
def __init__(self, toolchain="icestorm"):
|
2022-11-05 03:07:14 -04:00
|
|
|
LatticeiCE40Platform.__init__(self, "ice40-lp8k-cm81", _io, _connectors, toolchain=toolchain)
|
2019-08-07 02:47:08 -04:00
|
|
|
self.add_extension(serial)
|
2019-06-10 11:09:51 -04:00
|
|
|
|
|
|
|
def create_programmer(self):
|
|
|
|
return TinyProgProgrammer()
|
2020-05-05 05:45:41 -04:00
|
|
|
|
|
|
|
def do_finalize(self, fragment):
|
2022-11-05 03:07:14 -04:00
|
|
|
LatticeiCE40Platform.do_finalize(self, fragment)
|
2020-05-05 05:45:41 -04:00
|
|
|
self.add_period_constraint(self.lookup_request("clk16", loose=True), 1e9/16e6)
|