2021-09-01 11:33:54 -04:00
|
|
|
#
|
|
|
|
# This file is part of LiteX-Boards.
|
|
|
|
#
|
|
|
|
# Copyright (c) 2021 Greg Davill <greg.davill@gmail.com>
|
|
|
|
# Copyright (c) 2021 Florent Kermarrec <florent@enjoy-digital.fr>
|
|
|
|
# SPDX-License-Identifier: BSD-2-Clause
|
2022-09-10 12:45:57 -04:00
|
|
|
|
2021-09-01 11:33:54 -04:00
|
|
|
from litex.build.generic_platform import *
|
|
|
|
from litex.build.lattice import LatticePlatform
|
|
|
|
from litex.build.lattice.programmer import OpenOCDJTAGProgrammer
|
2022-09-10 12:45:57 -04:00
|
|
|
from litex.build.dfu import DFUProg
|
2021-09-01 11:33:54 -04:00
|
|
|
|
|
|
|
# IOs ----------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
_io_r1_0 = [
|
|
|
|
# Clk
|
|
|
|
("clk30", 0, Pins("B12"), IOStandard("LVCMOS33")),
|
|
|
|
|
|
|
|
# Leds
|
|
|
|
("user_led", 0, Pins("C13"), IOStandard("LVCMOS33")),
|
|
|
|
("user_led", 1, Pins("D12"), IOStandard("LVCMOS33")),
|
|
|
|
("user_led", 2, Pins(" U2"), IOStandard("LVCMOS33")),
|
|
|
|
("user_led", 3, Pins(" T3"), IOStandard("LVCMOS33")),
|
|
|
|
("user_led", 4, Pins("D13"), IOStandard("LVCMOS33")),
|
|
|
|
("user_led", 5, Pins("E13"), IOStandard("LVCMOS33")),
|
|
|
|
("user_led", 6, Pins("C16"), IOStandard("LVCMOS33")),
|
|
|
|
("user_led_color", 0, Pins("T1 R1 U1"), IOStandard("LVCMOS33")),
|
|
|
|
|
|
|
|
# Buttons
|
|
|
|
("user_btn", 0, Pins("U16"), IOStandard("SSTL135_I")),
|
|
|
|
("user_btn", 1, Pins("T17"), IOStandard("SSTL135_I")),
|
2021-09-01 12:03:13 -04:00
|
|
|
|
2021-09-02 05:28:21 -04:00
|
|
|
# SPIFlash
|
|
|
|
("spiflash4x", 0,
|
|
|
|
Subsignal("cs_n", Pins("R2")),
|
|
|
|
#Subsignal("clk", Pins("U3")),
|
|
|
|
Subsignal("dq", Pins("W2 V2 Y2 W1")),
|
|
|
|
IOStandard("LVCMOS33")
|
|
|
|
),
|
|
|
|
|
2021-09-02 05:51:07 -04:00
|
|
|
|
|
|
|
# SDCard
|
|
|
|
("spisdcard", 0,
|
|
|
|
Subsignal("clk", Pins(f"B15")),
|
|
|
|
Subsignal("mosi", Pins(f"A13"), Misc("PULLMODE=UP")),
|
|
|
|
Subsignal("cs_n", Pins(f"A14"), Misc("PULLMODE=UP")),
|
|
|
|
Subsignal("miso", Pins(f"C12"), Misc("PULLMODE=UP")),
|
|
|
|
Misc("SLEWRATE=FAST"),
|
|
|
|
IOStandard("LVCMOS33"),
|
|
|
|
),
|
|
|
|
("sdcard", 0,
|
|
|
|
Subsignal("data", Pins("C12 A12 D14 A14"), Misc("PULLMODE=UP")),
|
|
|
|
Subsignal("cmd", Pins("A13"), Misc("PULLMODE=UP")),
|
|
|
|
Subsignal("clk", Pins("B13")),
|
2021-12-06 23:02:13 -05:00
|
|
|
Subsignal("cd", Pins("B15"), Misc("PULLMODE=UP")),
|
2021-09-02 05:51:07 -04:00
|
|
|
Misc("SLEWRATE=FAST"),
|
|
|
|
IOStandard("LVCMOS33"),
|
|
|
|
),
|
|
|
|
|
gsd_butterstick: Add initial DDR3 support.
Validated with:
./gsd_butterstick.py --uart-name=crossover --with-etherbone --csr-csv=csr.csv --build --load
litex_server --udp
litex_term bridge
__ _ __ _ __
/ / (_) /____ | |/_/
/ /__/ / __/ -_)> <
/____/_/\__/\__/_/|_|
Build your hardware, easily!
(c) Copyright 2012-2021 Enjoy-Digital
(c) Copyright 2007-2015 M-Labs
BIOS built on Sep 1 2021 19:09:52
BIOS CRC passed (3d349845)
Migen git sha1: 27dbf03
LiteX git sha1: 315fbe18
--=============== SoC ==================--
CPU: VexRiscv @ 75MHz
BUS: WISHBONE 32-bit @ 4GiB
CSR: 32-bit data
ROM: 128KiB
SRAM: 8KiB
L2: 8KiB
SDRAM: 524288KiB 16-bit @ 300MT/s (CL-6 CWL-5)
--========== Initialization ============--
Initializing SDRAM @0x40000000...
Switching SDRAM to software control.
Read leveling:
m0, b00: |01110000| delays: 02+-01
m0, b01: |00000000| delays: -
m0, b02: |00000000| delays: -
m0, b03: |00000000| delays: -
best: m0, b00 delays: 02+-01
m1, b00: |01110000| delays: 02+-01
m1, b01: |00000000| delays: -
m1, b02: |00000000| delays: -
m1, b03: |00000000| delays: -
best: m1, b00 delays: 02+-01
Switching SDRAM to hardware control.
Memtest at 0x40000000 (2.0MiB)...
Write: 0x40000000-0x40200000 2.0MiB
Read: 0x40000000-0x40200000 2.0MiB
Memtest OK
Memspeed at 0x40000000 (Sequential, 2.0MiB)...
Write speed: 13.6MiB/s
Read speed: 15.6MiB/s
--============== Boot ==================--
Booting from serial...
Press Q or ESC to abort boot completely.
sL5DdSMmkekro
Timeout
No boot medium found
--============= Console ================--
litex>
2021-09-01 13:21:16 -04:00
|
|
|
# DDR3 SDRAM
|
|
|
|
("ddram", 0,
|
|
|
|
Subsignal("a", Pins(
|
|
|
|
"G16 E19 E20 F16 F19 E16 F17 L20 "
|
|
|
|
"M20 E18 G18 D18 H18 C18 D17 G20 "),
|
|
|
|
IOStandard("SSTL135_I")),
|
|
|
|
Subsignal("ba", Pins("H16 F20 H20"), IOStandard("SSTL135_I")),
|
|
|
|
Subsignal("ras_n", Pins("K18"), IOStandard("SSTL135_I")),
|
|
|
|
Subsignal("cas_n", Pins("J17"), IOStandard("SSTL135_I")),
|
|
|
|
Subsignal("we_n", Pins("G19"), IOStandard("SSTL135_I")),
|
|
|
|
Subsignal("cs_n", Pins("J20 J16"), IOStandard("SSTL135_I")),
|
|
|
|
Subsignal("dm", Pins("U20 L18"), IOStandard("SSTL135_I")),
|
|
|
|
Subsignal("dq", Pins(
|
|
|
|
"U19 T18 U18 R20 P18 P19 P20 N20",
|
|
|
|
"L19 L17 L16 R16 N18 R17 N17 P17"),
|
|
|
|
IOStandard("SSTL135_I"),
|
|
|
|
Misc("TERMINATION=75")),
|
|
|
|
Subsignal("dqs_p", Pins("T19 N16"), IOStandard("SSTL135D_I"),
|
|
|
|
Misc("TERMINATION=OFF"),
|
|
|
|
Misc("DIFFRESISTOR=100")),
|
|
|
|
Subsignal("clk_p", Pins("C20 J19"), IOStandard("SSTL135D_I")),
|
|
|
|
Subsignal("cke", Pins("F18 J18"), IOStandard("SSTL135_I")),
|
|
|
|
Subsignal("odt", Pins("K20 H17"), IOStandard("SSTL135_I")),
|
|
|
|
Subsignal("reset_n", Pins("E17"), IOStandard("SSTL135_I")),
|
|
|
|
Misc("SLEWRATE=FAST")
|
|
|
|
),
|
2021-09-01 12:03:13 -04:00
|
|
|
|
2021-12-05 05:03:28 -05:00
|
|
|
("vccio_ctrl", 0,
|
|
|
|
Subsignal("pdm", Pins("V1 E11 T2")),
|
|
|
|
Subsignal("en", Pins("E12"))
|
|
|
|
),
|
|
|
|
|
2021-09-01 12:03:13 -04:00
|
|
|
# RGMII Ethernet
|
|
|
|
("eth_clocks", 0,
|
|
|
|
Subsignal("tx", Pins("E15")),
|
|
|
|
Subsignal("rx", Pins("D11")),
|
|
|
|
IOStandard("LVCMOS33"),
|
|
|
|
Misc("SLEWRATE=FAST"),
|
|
|
|
),
|
|
|
|
|
|
|
|
("eth", 0,
|
|
|
|
Subsignal("rst_n", Pins("B20")),
|
|
|
|
Subsignal("mdio", Pins("D16")),
|
|
|
|
Subsignal("mdc", Pins("A19")),
|
|
|
|
Subsignal("rx_data", Pins("A16 C17 B17 A17")),
|
|
|
|
Subsignal("tx_ctl", Pins("D15")),
|
|
|
|
Subsignal("rx_ctl", Pins("B18")),
|
|
|
|
Subsignal("tx_data", Pins("C15 B16 A18 B19")),
|
|
|
|
IOStandard("LVCMOS33"),
|
|
|
|
Misc("SLEWRATE=FAST")
|
|
|
|
),
|
2021-12-05 05:03:28 -05:00
|
|
|
|
|
|
|
("ulpi", 0,
|
|
|
|
Subsignal("data", Pins("B9 C6 A7 E9 A8 D9 C10 C7")),
|
|
|
|
Subsignal("clk", Pins("B6")),
|
|
|
|
Subsignal("dir", Pins("A6")),
|
|
|
|
Subsignal("nxt", Pins("B8")),
|
|
|
|
Subsignal("stp", Pins("C8")),
|
|
|
|
Subsignal("rst", Pins("C9")),
|
|
|
|
IOStandard("LVCMOS18"),Misc("SLEWRATE=FAST")
|
|
|
|
),
|
2021-09-01 11:33:54 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
# Connectors ---------------------------------------------------------------------------------------
|
|
|
|
|
2021-09-02 04:26:18 -04:00
|
|
|
_connectors_r1_0 = [
|
|
|
|
("SYZYGY0", {
|
2021-12-04 01:32:36 -05:00
|
|
|
# single ended
|
2021-12-05 05:03:28 -05:00
|
|
|
"S0": "G2", "S1": "J3",
|
|
|
|
"S2": "F1", "S3": "K3",
|
|
|
|
"S4": "J4", "S5": "K2",
|
|
|
|
"S6": "J5", "S7": "J1",
|
|
|
|
"S8": "N2", "S9": "L3",
|
2021-09-02 04:26:18 -04:00
|
|
|
"S10":"M1", "S11":"L2",
|
|
|
|
"S12":"N3", "S13":"N4",
|
|
|
|
"S14":"M3", "S15":"P5",
|
|
|
|
"S16":"H1", "S17":"K5",
|
|
|
|
"S18":"K4", "S19":"K1",
|
|
|
|
"S20":"L4", "S21":"L1",
|
|
|
|
"S22":"L5", "S23":"M4",
|
|
|
|
"S24":"N1", "S25":"N5",
|
|
|
|
"S26":"P3", "S27":"P4",
|
|
|
|
"S28":"H2", "S29":"P1",
|
|
|
|
"S30":"G1", "S31":"P2",
|
|
|
|
}
|
|
|
|
),
|
|
|
|
("SYZYGY1", {
|
2021-12-04 01:32:36 -05:00
|
|
|
# single ended
|
2021-12-05 05:03:28 -05:00
|
|
|
"S0": "E4", "S1": "A4",
|
|
|
|
"S2": "D5", "S3": "A5",
|
|
|
|
"S4": "C4", "S5": "B2",
|
|
|
|
"S6": "B4", "S7": "C2",
|
|
|
|
"S8": "A2", "S9": "C1",
|
2021-12-04 01:32:36 -05:00
|
|
|
"S10":"B1", "S11":"D1",
|
|
|
|
"S12":"F4", "S13":"D2",
|
|
|
|
"S14":"E3", "S15":"E1",
|
|
|
|
"S16":"B5", "S17":"E5",
|
|
|
|
"S18":"F5", "S19":"C5",
|
|
|
|
"S20":"B3", "S21":"A3",
|
|
|
|
"S22":"D3", "S23":"C3",
|
|
|
|
"S24":"H5", "S25":"G5",
|
|
|
|
"S26":"H3", "S27":"H4",
|
|
|
|
"S28":"G3", "S29":"F2",
|
|
|
|
"S30":"F3", "S31":"E2",
|
|
|
|
}
|
|
|
|
),
|
|
|
|
("SYZYGY2", {
|
|
|
|
# single ended
|
2021-12-05 05:03:28 -05:00
|
|
|
"S0": "C11", "S1": "B11",
|
|
|
|
"S2": "D6", "S3": "D7",
|
|
|
|
"S4": "E6", "S5": "E7",
|
|
|
|
"S6": "D8", "S7": "E8",
|
|
|
|
"S8": "E10", "S9": "D10",
|
|
|
|
"S10":"A9", "S11":"A10",
|
2021-12-04 01:32:36 -05:00
|
|
|
"S12":"B10", "S13":"A11"
|
2021-09-02 04:26:18 -04:00
|
|
|
}
|
|
|
|
),
|
|
|
|
]
|
2021-09-01 11:33:54 -04:00
|
|
|
|
2022-01-06 12:37:42 -05:00
|
|
|
# SYZYGY -------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def raw_syzygy_io(syzygy, iostandard="LVCMOS33"):
|
|
|
|
return [(syzygy, 0, Pins(" ".join([f"{syzygy}:S{i:d}" for i in range(32)])), IOStandard(iostandard))]
|
|
|
|
|
2021-09-01 11:33:54 -04:00
|
|
|
# Platform -----------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class Platform(LatticePlatform):
|
|
|
|
default_clk_name = "clk30"
|
|
|
|
default_clk_period = 1e9/30e6
|
|
|
|
|
|
|
|
def __init__(self, revision="1.0", device="85F", toolchain="trellis", **kwargs):
|
|
|
|
assert revision in ["1.0"]
|
2022-03-18 05:44:16 -04:00
|
|
|
assert device in ["25F", "45F", "85F"]
|
2021-09-01 11:33:54 -04:00
|
|
|
self.revision = revision
|
|
|
|
io = {"1.0": _io_r1_0}[revision]
|
|
|
|
connectors = {"1.0": _connectors_r1_0}[revision]
|
|
|
|
LatticePlatform.__init__(self, f"LFE5UM5G-{device}-8BG381C", io, connectors, toolchain=toolchain, **kwargs)
|
|
|
|
|
2022-09-10 13:16:04 -04:00
|
|
|
def create_programmer(self, programmer):
|
|
|
|
if programmer == "jtag":
|
2022-09-10 12:45:57 -04:00
|
|
|
return OpenOCDJTAGProgrammer("openocd_butterstick.cfg")
|
2022-09-10 13:16:04 -04:00
|
|
|
elif programmer == "dfu":
|
2022-09-10 12:45:57 -04:00
|
|
|
return DFUProg(vid="1209", pid="5af1", alt=0)
|
|
|
|
else:
|
2022-09-10 13:16:04 -04:00
|
|
|
print("Could not program board. " + programmer + " is not a valid argument. Please use 'jtag' or 'dfu'.")
|
2021-09-01 11:33:54 -04:00
|
|
|
|
|
|
|
def do_finalize(self, fragment):
|
|
|
|
LatticePlatform.do_finalize(self, fragment)
|
|
|
|
self.add_period_constraint(self.lookup_request("clk30", loose=True), 1e9/30e6)
|