|
| 1 | +# |
| 2 | +# This file is part of LiteX-Boards. |
| 3 | +# |
| 4 | +# Copyright (c) 2026 Yu Jin <lambda.jinyu@gmail.com> |
| 5 | +# SPDX-License-Identifier: BSD-2-Clause |
| 6 | + |
| 7 | +from litex.build.generic_platform import * |
| 8 | +from litex.build.openfpgaloader import OpenFPGALoader |
| 9 | +from litex.build.xilinx import XilinxUSPPlatform |
| 10 | + |
| 11 | +# IOs ---------------------------------------------------------------------------------------------- |
| 12 | + |
| 13 | +_io = [ |
| 14 | + # Clk / Rst. |
| 15 | + ("clk100", 0, Pins("AH18"), IOStandard("LVCMOS18")), |
| 16 | + ("clk100_ddr", 0, |
| 17 | + Subsignal("p", Pins("AK17")), |
| 18 | + Subsignal("n", Pins("AK16")), |
| 19 | + IOStandard("DIFF_SSTL12") |
| 20 | + ), |
| 21 | + ("cpu_resetn", 0, Pins("J23"), IOStandard("LVCMOS18"), Misc("PULLTYPE PULLUP")), |
| 22 | + |
| 23 | + # Buttons. |
| 24 | + ("user_btn", 0, Pins("G26"), IOStandard("LVCMOS18")), |
| 25 | + ("user_btn", 1, Pins("G25"), IOStandard("LVCMOS18")), |
| 26 | + ("user_btn", 2, Pins("H24"), IOStandard("LVCMOS18")), |
| 27 | + |
| 28 | + # Leds. |
| 29 | + ("user_led", 0, Pins("AP9"), IOStandard("LVCMOS33")), |
| 30 | + ("user_led", 1, Pins("AN9"), IOStandard("LVCMOS33")), |
| 31 | + ("user_led", 2, Pins("AP8"), IOStandard("LVCMOS33")), |
| 32 | + ("user_led", 3, Pins("AN8"), IOStandard("LVCMOS33")), |
| 33 | + ("user_led", 4, Pins("AL10"), IOStandard("LVCMOS33")), |
| 34 | + ("user_led", 5, Pins("AM10"), IOStandard("LVCMOS33")), |
| 35 | + ("user_led", 6, Pins("AE11"), IOStandard("LVCMOS33")), |
| 36 | + |
| 37 | + # Serial. |
| 38 | + ("serial", 0, |
| 39 | + Subsignal("tx", Pins("AN13")), |
| 40 | + Subsignal("rx", Pins("AP13")), |
| 41 | + IOStandard("LVCMOS33") |
| 42 | + ), |
| 43 | + |
| 44 | + # SDCard. |
| 45 | + ("sdcard", 0, |
| 46 | + Subsignal("clk", Pins("B9")), |
| 47 | + Subsignal("cmd", Pins("A10"), Misc("PULLTYPE PULLUP")), |
| 48 | + Subsignal("data", Pins("B11 A9 C8 B10"), Misc("PULLTYPE PULLUP")), |
| 49 | + Subsignal("cd", Pins("C11"), Misc("PULLTYPE PULLUP")), |
| 50 | + IOStandard("LVCMOS18") |
| 51 | + ), |
| 52 | + |
| 53 | + # Runtime QSPI is intentionally omitted. The source pin table assigns C8 |
| 54 | + # to both SD D2 and flash CS, and the dedicated flash clock needs STARTUPE3. |
| 55 | + |
| 56 | + # I2C EEPROM / RTC. |
| 57 | + ("i2c", 0, |
| 58 | + Subsignal("scl", Pins("AP11")), |
| 59 | + Subsignal("sda", Pins("AP10")), |
| 60 | + IOStandard("LVCMOS33") |
| 61 | + ), |
| 62 | + |
| 63 | + # 4GB DDR4 SDRAM: 4 x Hynix H5AN8G6NCJR-VKI, modeled as MT40A512M16. |
| 64 | + ("ddram", 0, |
| 65 | + Subsignal("a", Pins( |
| 66 | + "AM34 AN26 AP34 AK26 AL32 AK28 AK32 AL30", |
| 67 | + "AL34 AP26 AK31 AL33 AH32 AM32"), |
| 68 | + IOStandard("SSTL12_DCI")), |
| 69 | + Subsignal("ba", Pins("AJ31 AK27"), IOStandard("SSTL12_DCI")), |
| 70 | + Subsignal("bg", Pins("AJ30"), IOStandard("SSTL12_DCI")), |
| 71 | + Subsignal("ras_n", Pins("AJ33"), IOStandard("SSTL12_DCI")), |
| 72 | + Subsignal("cas_n", Pins("AJ34"), IOStandard("SSTL12_DCI")), |
| 73 | + Subsignal("we_n", Pins("AJ28"), IOStandard("SSTL12_DCI")), |
| 74 | + Subsignal("cs_n", Pins("AH33"), IOStandard("SSTL12_DCI")), |
| 75 | + Subsignal("act_n", Pins("AH31"), IOStandard("SSTL12_DCI")), |
| 76 | + Subsignal("dm", Pins("Y26 V27 AA22 W23 AE25 AD21 AM21 AJ21"), |
| 77 | + IOStandard("POD12_DCI")), |
| 78 | + Subsignal("dq", Pins( |
| 79 | + "AD25 AA27 AC24 AB25 AB24 AB27 AD26 AB26", |
| 80 | + "U25 W28 W26 W29 U24 V29 V26 Y28", |
| 81 | + "AB20 Y23 AC22 AA24 AA20 AA25 AC23 AA23", |
| 82 | + "U22 T22 T23 W21 U21 Y25 V21 W25", |
| 83 | + "AJ23 AF23 AJ24 AG25 AH23 AF24 AH22 AG24", |
| 84 | + "AG20 AE22 AF20 AF22 AD20 AE23 AG22 AE20", |
| 85 | + "AM22 AM24 AN22 AN24 AN23 AP24 AP23 AP25", |
| 86 | + "AL24 AL25 AK22 AL22 AK23 AM20 AL20 AL23"), |
| 87 | + IOStandard("POD12_DCI")), |
| 88 | + Subsignal("dqs_p", Pins("AC26 U26 AB21 V22 AH24 AG21 AP20 AJ20"), |
| 89 | + IOStandard("DIFF_POD12_DCI")), |
| 90 | + Subsignal("dqs_n", Pins("AC27 U27 AC21 V23 AJ25 AH21 AP21 AK20"), |
| 91 | + IOStandard("DIFF_POD12_DCI")), |
| 92 | + Subsignal("clk_p", Pins("AJ29"), IOStandard("DIFF_SSTL12_DCI")), |
| 93 | + Subsignal("clk_n", Pins("AK30"), IOStandard("DIFF_SSTL12_DCI")), |
| 94 | + Subsignal("cke", Pins("AH27"), IOStandard("SSTL12_DCI")), |
| 95 | + Subsignal("odt", Pins("AH28"), IOStandard("SSTL12_DCI")), |
| 96 | + Subsignal("reset_n", Pins("AJ26"), IOStandard("LVCMOS12")), |
| 97 | + Misc("SLEW=FAST") |
| 98 | + ), |
| 99 | +] |
| 100 | + |
| 101 | +# Platform ----------------------------------------------------------------------------------------- |
| 102 | + |
| 103 | +class Platform(XilinxUSPPlatform): |
| 104 | + default_clk_name = "clk100" |
| 105 | + default_clk_period = 1e9/100e6 |
| 106 | + |
| 107 | + def __init__(self, toolchain="vivado"): |
| 108 | + XilinxUSPPlatform.__init__(self, "xcku15p-ffva1156-2-e", _io, toolchain=toolchain) |
| 109 | + |
| 110 | + def create_programmer(self): |
| 111 | + return OpenFPGALoader(fpga_part="xcku15p-ffva1156", cable="ft2232") |
| 112 | + |
| 113 | + def do_finalize(self, fragment): |
| 114 | + self.add_platform_command("set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]") |
| 115 | + self.add_platform_command("set_property BITSTREAM.CONFIG.CONFIGRATE 85.0 [current_design]") |
| 116 | + self.add_platform_command("set_property BITSTREAM.CONFIG.SPI_FALL_EDGE YES [current_design]") |
| 117 | + self.add_platform_command("set_property BITSTREAM.GENERAL.COMPRESS true [current_design]") |
| 118 | + self.add_platform_command("set_property CONFIG_VOLTAGE 1.8 [current_design]") |
| 119 | + self.add_platform_command("set_property CFGBVS GND [current_design]") |
| 120 | + self.add_platform_command("set_property CONFIG_MODE SPIx4 [current_design]") |
| 121 | + self.add_platform_command("set_property BITSTREAM.CONFIG.UNUSEDPIN pulldown [current_design]") |
| 122 | + XilinxUSPPlatform.do_finalize(self, fragment) |
| 123 | + self.add_period_constraint(self.lookup_request("clk100", loose=True), 1e9/100e6) |
0 commit comments