NuBusFPGA/nubus-to-ztex-gateware/ztex213_nubus.py

246 lines
10 KiB
Python
Raw Normal View History

2021-12-21 07:26:30 +00:00
#
# This file is part of LiteX-Boards.
#
# Support for the ZTEX USB-FGPA Module 2.13:
# <https://www.ztex.de/usb-fpga-2/usb-fpga-2.13.e.html>
# With (no-so-optional) expansion, either the ZTEX Debug board:
# <https://www.ztex.de/usb-fpga-2/debug.e.html>
# Or the NuBusFPGA adapter board:
# <https://github.com/rdolbeau/NuBusFPGA>
#
# Copyright (c) 2015 Yann Sionneau <yann.sionneau@gmail.com>
# Copyright (c) 2015-2019 Florent Kermarrec <florent@enjoy-digital.fr>
# Copyright (c) 2020-2021 Romain Dolbeau <romain@dolbeau.org>
# SPDX-License-Identifier: BSD-2-Clause
from litex.build.generic_platform import *
from litex.build.xilinx import XilinxPlatform
from litex.build.openocd import OpenOCD
from VintageBusFPGA_Common.ztex_21x_common import ZTexPlatform
2021-12-21 07:26:30 +00:00
# IOs ----------------------------------------------------------------------------------------------
2021-12-21 07:26:30 +00:00
# NuBusFPGA I/O
2022-07-17 08:02:26 +00:00
# I/O
2021-12-21 07:26:30 +00:00
_nubus_io_v1_0 = [
## leds on the NuBus board
("user_led", 0, Pins("V5"), IOStandard("lvcmos33")), #LED0
("user_led", 1, Pins("V4"), IOStandard("lvcmos33")), #LED1
## serial header for console
("serial", 0,
Subsignal("tx", Pins("V9")), # FIXME: might be the other way round
Subsignal("rx", Pins("U9")),
IOStandard("LVCMOS33")
),
## USB
("usb", 0,
Subsignal("dp", Pins("B11")),
Subsignal("dm", Pins("A11")),
IOStandard("LVCMOS33")
),
## VGA
("vga", 0,
Subsignal("clk", Pins("K6")),
Subsignal("hsync", Pins("U4")),
Subsignal("vsync", Pins("U3")),
Subsignal("b", Pins("M2 M3 M4 N4 L5 L6 M6 N6")),
Subsignal("g", Pins("N2 N1 M1 L1 K3 L3 L4 K5")),
Subsignal("r", Pins("P5 N5 P4 P3 T1 R1 R2 P2")),
IOStandard("LVCMOS33"),
),
# HDMI
("hdmi", 0,
Subsignal("clk_p", Pins("R6"), IOStandard("TMDS_33")),
Subsignal("clk_n", Pins("R5"), IOStandard("TMDS_33")),
Subsignal("data0_p", Pins("U1"), IOStandard("TMDS_33")),
Subsignal("data0_n", Pins("V1"), IOStandard("TMDS_33")),
Subsignal("data1_p", Pins("U2"), IOStandard("TMDS_33")),
Subsignal("data1_n", Pins("V2"), IOStandard("TMDS_33")),
Subsignal("data2_p", Pins("R3"), IOStandard("TMDS_33")),
Subsignal("data2_n", Pins("T3"), IOStandard("TMDS_33")),
2022-01-29 10:03:47 +00:00
Subsignal("hpd", Pins("T8"), IOStandard("LVCMOS33")),
2021-12-21 07:26:30 +00:00
Subsignal("sda", Pins("R8"), IOStandard("LVCMOS33")),
Subsignal("scl", Pins("R7"), IOStandard("LVCMOS33")),
Subsignal("cec", Pins("T6"), IOStandard("LVCMOS33")),
),
]
2022-07-17 08:02:26 +00:00
_nubus_io_v1_2 = [
2023-01-14 10:03:01 +00:00
## extra 54 MHz clock reference for bank 34
("clk54", 0, Pins("R3"), IOStandard("LVCMOS33")),
2022-07-17 08:02:26 +00:00
## leds on the NuBus board
2023-04-17 20:55:22 +00:00
("user_led", 0, Pins("V9"), IOStandard("lvcmos33")), #LED0
("user_led", 1, Pins("U9"), IOStandard("lvcmos33")), #LED1; both are overlapping with serial TX/RX
2022-07-17 08:02:26 +00:00
## serial header for console
("serial", 0,
Subsignal("tx", Pins("V9")), # FIXME: might be the other way round
Subsignal("rx", Pins("U9")), #<23>both are overlapping with LED0/1
2022-07-17 08:02:26 +00:00
IOStandard("LVCMOS33")
),
## USB
("usb", 0,
Subsignal("dp", Pins("B11")),
Subsignal("dm", Pins("A11")),
IOStandard("LVCMOS33")
),
## HDMI
("hdmi", 0,
Subsignal("clk_p", Pins("M4"), IOStandard("TMDS_33")),
Subsignal("clk_n", Pins("N4"), IOStandard("TMDS_33")),
Subsignal("data0_p", Pins("M3"), IOStandard("TMDS_33")),
Subsignal("data0_n", Pins("M2"), IOStandard("TMDS_33")),
Subsignal("data1_p", Pins("K5"), IOStandard("TMDS_33")),
Subsignal("data1_n", Pins("L4"), IOStandard("TMDS_33")),
Subsignal("data2_p", Pins("K3"), IOStandard("TMDS_33")),
Subsignal("data2_n", Pins("L3"), IOStandard("TMDS_33")),
Subsignal("hpd", Pins("N6"), IOStandard("LVCMOS33")),
Subsignal("sda", Pins("M6"), IOStandard("LVCMOS33")),
Subsignal("scl", Pins("L6"), IOStandard("LVCMOS33")),
Subsignal("cec", Pins("L5"), IOStandard("LVCMOS33")),
),
2022-10-01 06:38:10 +00:00
## micro-sd
("sdcard", 0,
Subsignal("data", Pins("U1 T3 T4 U4"), Misc("PULLUP True")),
Subsignal("cmd", Pins("U3"), Misc("PULLUP True")),
Subsignal("clk", Pins("V1")),
#Subsignal("cd", Pins("")),
Misc("SLEW=FAST"),
IOStandard("LVCMOS33"),
),
2022-07-17 08:02:26 +00:00
]
# NuBus
2021-12-21 07:26:30 +00:00
_nubus_nubus_v1_0 = [
("clk_3v3_n", 0, Pins("H16"), IOStandard("lvttl")),
2022-01-29 10:03:47 +00:00
("clk2x_3v3_n", 0, Pins("T5"), IOStandard("lvttl")),
2021-12-21 07:26:30 +00:00
("ack_3v3_n", 0, Pins("K13"), IOStandard("lvttl")),
("nmrq_3v3_n", 0, Pins("J18"), IOStandard("lvttl")),
("reset_3v3_n", 0, Pins("G17"), IOStandard("lvttl")),
("rqst_3v3_n" , 0, Pins("K16"), IOStandard("lvttl")),
("start_3v3_n", 0, Pins("J15"), IOStandard("lvttl")),
("ad_3v3_n", 0, Pins("A13 A14 C12 B12 B13 B14 A15 A16 "
"D12 D13 D14 C14 B16 B17 D15 C15 "
"B18 A18 C16 C17 E15 E16 F14 F13 "
"D17 D18 E17 E18 F15 F18 F16 G18 "), IOStandard("lvttl")),
2022-04-17 09:25:48 +00:00
# ("nubus_arb_n", 0, Pins(""), IOStandard("lvttl")), # CPLD only, we have 'arbcy_n'/'grant' instead
2021-12-21 07:26:30 +00:00
("id_3v3_n", 0, Pins("U7 V6 V7 U8"), IOStandard("lvttl")),
("tm0_3v3_n", 0, Pins("K15"), IOStandard("lvttl")),
("tm1_3v3_n", 0, Pins("J17"), IOStandard("lvttl")),
2022-01-29 10:03:47 +00:00
("tm2_3v3_n", 0, Pins("T4"), IOStandard("lvttl")),
2021-12-21 07:26:30 +00:00
("nubus_oe", 0, Pins("G13"), IOStandard("lvttl")),
("nubus_ad_dir", 0, Pins("G16"), IOStandard("lvttl")),
("nubus_master_dir", 0, Pins("H17"), IOStandard("lvttl")),
("grant", 0, Pins("H15"), IOStandard("lvttl")),
2022-04-17 09:25:48 +00:00
("arbcy_n", 0, Pins("J13"), IOStandard("lvttl")), # arb in the schematics
2021-12-21 07:26:30 +00:00
("fpga_to_cpld_clk", 0, Pins("H14"), IOStandard("lvttl")),
2022-01-29 10:03:47 +00:00
("tmoen", 0, Pins("U6"), IOStandard("lvttl")),
2021-12-21 07:26:30 +00:00
("fpga_to_cpld_signal",0, Pins("J14"), IOStandard("lvttl")),
("fpga_to_cpld_signal_2",0, Pins("G14"), IOStandard("lvttl")),
]
2022-07-17 08:02:26 +00:00
_nubus_nubus_v1_2 = [
("clk_3v3_n", 0, Pins("H16"), IOStandard("lvttl")),
("clk2x_3v3_n", 0, Pins("T5"), IOStandard("lvttl")),
("ack_3v3_n", 0, Pins("J17"), IOStandard("lvttl")),
("ack_o_n", 0, Pins("H14"), IOStandard("lvttl")),
("ack_oe_n", 0, Pins("J13"), IOStandard("lvttl")),
2022-09-26 17:04:37 +00:00
("nmrq_3v3_n", 0, Pins("K16"), IOStandard("lvttl")), #<23>'irq' line, Output only direct to 74LVT125
2023-01-14 10:03:01 +00:00
("reset_3v3_n", 0, Pins("U8"), IOStandard("lvttl")), # Input only
2022-09-26 17:04:37 +00:00
("rqst_3v3_n" , 0, Pins("J18"), IOStandard("lvttl")), # Open Collector
2022-07-17 08:02:26 +00:00
("rqst_o_n" , 0, Pins("K13"), IOStandard("lvttl")),
("start_3v3_n", 0, Pins("K15"), IOStandard("lvttl")),
("start_o_n", 0, Pins("H15"), IOStandard("lvttl")),
("start_oe_n", 0, Pins("J15"), IOStandard("lvttl")),
("ad_3v3_n", 0, Pins("A13 A14 C12 B12 B13 B14 A15 A16 "
"D12 D13 D14 C14 B16 B17 D15 C15 "
"B18 A18 C16 C17 E15 E16 F14 F13 "
"D17 D18 E17 E18 F15 F18 F16 G18 "), IOStandard("lvttl")),
2022-09-24 06:00:23 +00:00
("arb_3v3_n", 0, Pins("T8 V4 V5 U6"), IOStandard("lvttl")), # Open Collector
2022-07-17 08:02:26 +00:00
("arb_o_n", 0, Pins("J14 G16 G14 H17"), IOStandard("lvttl")),
2023-01-14 10:03:01 +00:00
("id_3v3_n", 0, Pins("U7 V6 V7"), IOStandard("lvttl")),
2022-10-01 06:38:10 +00:00
("tm0_3v3_n", 0, Pins("U2"), IOStandard("lvttl")),
("tm0_o_n", 0, Pins("T6"), IOStandard("lvttl")),
2022-10-01 06:38:10 +00:00
("tm1_3v3_n", 0, Pins("V2"), IOStandard("lvttl")),
("tm1_o_n", 0, Pins("R7"), IOStandard("lvttl")),
("tmx_oe_n", 0, Pins("R8"), IOStandard("lvttl")),
("tm2_3v3_n", 0, Pins("K6"), IOStandard("lvttl")),
("tm2_o_n", 0, Pins("R5"), IOStandard("lvttl")),
("tm2_oe_n", 0, Pins("R6"), IOStandard("lvttl")),
2022-07-17 08:02:26 +00:00
("nubus_oe", 0, Pins("G13"), IOStandard("lvttl")),
2022-11-01 11:41:58 +00:00
("nubus_ad_dir", 0, Pins("G17"), IOStandard("lvttl")),
2022-07-17 08:02:26 +00:00
]
2021-12-21 07:26:30 +00:00
# Connectors ---------------------------------------------------------------------------------------
connectors_v1_0 = [
]
connectors_v1_2 = [
("P1", "M1 L1 N2 N1 R2 P2 T1 R1 P4 P3 P5 N5"), # check sequence! currently in pmod-* order
2021-12-21 07:26:30 +00:00
]
2023-09-16 13:14:35 +00:00
# Extension
def flashtemp_pmod_io(pmod):
return [
# completely inconsistent with the SBus entry as P1 is in a different order...
("spiflash4x", 0,
Subsignal("cs_n", Pins(f"{pmod}:2")),
Subsignal("clk", Pins(f"{pmod}:5")),
Subsignal("dq", Pins(f"{pmod}:7 {pmod}:4 {pmod}:6 {pmod}:3")),
IOStandard("LVCMOS33")
),
]
_flashtemp_pmod_io_v1_2 = flashtemp_pmod_io("P1")
# Ethernet ----------------------------------------------------------------------------------------------
#<23>custom not-quite-pmod
2022-11-01 11:41:58 +00:00
def rmii_eth_extpmod_io(extpmod):
return [
("eth_clocks", 0,
2023-09-16 13:14:35 +00:00
Subsignal("ref_clk", Pins(f"{extpmod}:8")),
IOStandard("LVCMOS33"),
),
("eth", 0,
Subsignal("rst_n", Pins(f"{extpmod}:3")),
2023-09-16 13:14:35 +00:00
Subsignal("rx_data", Pins(f"{extpmod}:11 {extpmod}:10")),
Subsignal("crs_dv", Pins(f"{extpmod}:6")),
Subsignal("tx_en", Pins(f"{extpmod}:2")),
2022-11-01 11:41:58 +00:00
Subsignal("tx_data", Pins(f"{extpmod}:0 {extpmod}:1")),
#Subsignal("mdc", Pins(f"{extpmod}:4")),
#Subsignal("mdio", Pins(f"{extpmod}:7")),
2022-11-01 11:41:58 +00:00
Subsignal("rx_er", Pins(f"{extpmod}:9")),
Subsignal("int_n", Pins(f"{extpmod}:5")),
IOStandard("LVCMOS33"),
),
("sep_mdc", 0, Pins(f"{extpmod}:4"), IOStandard("LVCMOS33")),
("sep_mdio", 0, Pins(f"{extpmod}:7"), IOStandard("LVCMOS33")),
]
_rmii_eth_extpmod_io_v1_2 = rmii_eth_extpmod_io("P1")
2021-12-21 07:26:30 +00:00
# Platform -----------------------------------------------------------------------------------------
class Platform(ZTexPlatform):
2021-12-21 07:26:30 +00:00
def __init__(self, variant="ztex2.13a", version="V1.0"):
2021-12-21 07:26:30 +00:00
nubus_io = {
"V1.0" : _nubus_io_v1_0,
2022-07-17 08:02:26 +00:00
"V1.2" : _nubus_io_v1_2,
2021-12-21 07:26:30 +00:00
}[version]
nubus_nubus = {
"V1.0" : _nubus_nubus_v1_0,
2022-07-17 08:02:26 +00:00
"V1.2" : _nubus_nubus_v1_2,
2021-12-21 07:26:30 +00:00
}[version]
2022-11-01 11:41:58 +00:00
connectors = {
"V1.0" : connectors_v1_0,
"V1.2" : connectors_v1_2,
}[version]
2021-12-21 07:26:30 +00:00
ZTexPlatform.__init__(self, variant=variant, version=version, connectors=connectors)
2021-12-21 07:26:30 +00:00
self.add_extension(nubus_io)
#print(nubus_nubus)
2021-12-21 07:26:30 +00:00
self.add_extension(nubus_nubus)