|
| 1 | +# |
| 2 | +# This file is part of LiteX-Boards. |
| 3 | +# |
| 4 | +# Copyright (c) 2024 Yu-Ti Kuo <[email protected]> |
| 5 | +# SPDX-License-Identifier: BSD-2-Clause |
| 6 | +# embedfire rise pro FPGA: https://detail.tmall.com/item.htm?id=645153441975 |
| 7 | + |
| 8 | +from litex.build.generic_platform import * |
| 9 | +from litex.build.xilinx import Xilinx7SeriesPlatform |
| 10 | +from litex.build.openocd import OpenOCD |
| 11 | +from litex.build.xilinx.programmer import VivadoProgrammer |
| 12 | + |
| 13 | +# IOs ---------------------------------------------------------------------------------------------- |
| 14 | + |
| 15 | +_io = [ |
| 16 | + # Clk / Rst |
| 17 | + ("clk50" , 0, Pins("W19"), IOStandard("LVCMOS33")), |
| 18 | + ("cpu_reset", 0, Pins("N15"), IOStandard("LVCMOS33")), |
| 19 | + |
| 20 | + # Leds |
| 21 | + ("user_led", 0, Pins("M21"), IOStandard("LVCMOS33")), |
| 22 | + ("user_led", 1, Pins("L21"), IOStandard("LVCMOS33")), |
| 23 | + ("user_led", 2, Pins("K21"), IOStandard("LVCMOS33")), |
| 24 | + ("user_led", 3, Pins("K22"), IOStandard("LVCMOS33")), |
| 25 | + |
| 26 | + # Buttons |
| 27 | + ("user_sw", 0, Pins("V17"), IOStandard("LVCMOS33")), |
| 28 | + ("user_sw", 1, Pins("W17"), IOStandard("LVCMOS33")), |
| 29 | + ("user_sw", 2, Pins("AA18"), IOStandard("LVCMOS33")), |
| 30 | + ("user_sw", 3, Pins("AB18"), IOStandard("LVCMOS33")), |
| 31 | + |
| 32 | + # Beeper (Buzzer) |
| 33 | + ("beeper", 0, Pins("M17"), IOStandard("LVCMOS33")), |
| 34 | + |
| 35 | + # Fan |
| 36 | + ("fan", 0, Pins("W22"), IOStandard("LVCMOS33")), |
| 37 | + |
| 38 | + # Serial CH340G |
| 39 | + ("serial", 0, |
| 40 | + Subsignal("tx", Pins("N17")), |
| 41 | + Subsignal("rx", Pins("P17")), |
| 42 | + IOStandard("LVCMOS33") |
| 43 | + ), |
| 44 | + |
| 45 | + # I2C EEPROM 24C64 |
| 46 | + ("i2c", 0, |
| 47 | + Subsignal("scl", Pins("E22")), |
| 48 | + Subsignal("sda", Pins("D22")), |
| 49 | + IOStandard("LVCMOS33"), |
| 50 | + ), |
| 51 | + |
| 52 | + # DDR3 SDRAM MT41K256M16 |
| 53 | + ("ddram", 0, |
| 54 | + Subsignal("a", Pins( |
| 55 | + "AA4 AB2 AA5 AB3 AB1 U2 W1 R2", |
| 56 | + "V2 U3 Y1 W2 Y2 U1 V3"), |
| 57 | + IOStandard("SSTL135")), |
| 58 | + Subsignal("ba", Pins("AA1 Y3 AA3"), IOStandard("SSTL135")), |
| 59 | + Subsignal("ras_n", Pins("W6"), IOStandard("SSTL135")), |
| 60 | + Subsignal("cas_n", Pins("U5"), IOStandard("SSTL135")), |
| 61 | + Subsignal("we_n", Pins("Y4"), IOStandard("SSTL135")), |
| 62 | + Subsignal("cs_n", Pins("T1"), IOStandard("SSTL135")), |
| 63 | + Subsignal("dm", Pins("D2 G2 M2 M5"), IOStandard("SSTL135")), |
| 64 | + Subsignal("dq", Pins( |
| 65 | + "C2 G1 A1 F3 B2 F1 B1 E2", |
| 66 | + "H3 G3 H2 H5 J1 J5 K1 H4", |
| 67 | + "L4 M3 L3 J6 K3 K6 J4 L5", |
| 68 | + "P1 N4 R1 N2 M6 N5 P6 P2"), |
| 69 | + IOStandard("SSTL135"), |
| 70 | + Misc("IN_TERM=UNTUNED_SPLIT_40")), |
| 71 | + Subsignal("dqs_p", Pins("E1 K2 M1 P5"), |
| 72 | + IOStandard("DIFF_SSTL135"), |
| 73 | + Misc("IN_TERM=UNTUNED_SPLIT_40")), |
| 74 | + Subsignal("dqs_n", Pins("D1 J2 L1 P4"), |
| 75 | + IOStandard("DIFF_SSTL135"), |
| 76 | + Misc("IN_TERM=UNTUNED_SPLIT_40")), |
| 77 | + Subsignal("clk_p", Pins("V4"), IOStandard("DIFF_SSTL135")), |
| 78 | + Subsignal("clk_n", Pins("W4"), IOStandard("DIFF_SSTL135")), |
| 79 | + Subsignal("cke", Pins("AB5"), IOStandard("SSTL135")), |
| 80 | + Subsignal("odt", Pins("T5"), IOStandard("SSTL135")), |
| 81 | + Subsignal("reset_n", Pins("R3"), IOStandard("SSTL135")), |
| 82 | + Misc("SLEW=FAST"), |
| 83 | + ), |
| 84 | + |
| 85 | + # RGMII Ethernet (RTL8211F) |
| 86 | + ("eth_clocks", 0, |
| 87 | + Subsignal("tx", Pins("C18")), |
| 88 | + Subsignal("rx", Pins("C19")), |
| 89 | + IOStandard("LVCMOS33") |
| 90 | + ), |
| 91 | + ("eth", 0, |
| 92 | + #SubSignal("inib"), Pins("D21")), |
| 93 | + #Subsignal("rst_n", Pins("E21")), |
| 94 | + Subsignal("mdio", Pins("G22")), |
| 95 | + Subsignal("mdc", Pins("G21")), |
| 96 | + Subsignal("rx_ctl", Pins("C22")), |
| 97 | + Subsignal("rx_data", Pins("D20 C20 A18 A19")), |
| 98 | + Subsignal("tx_ctl", Pins("B22")), |
| 99 | + Subsignal("tx_data", Pins("B20 A20 B21 A21")), |
| 100 | + IOStandard("LVCMOS33") |
| 101 | + ), |
| 102 | + |
| 103 | + # SDCard |
| 104 | + ("spisdcard", 0, |
| 105 | + Subsignal("cd", Pins("AA19")), |
| 106 | + Subsignal("clk", Pins("Y22")), |
| 107 | + Subsignal("mosi", Pins("Y21")), |
| 108 | + Subsignal("cs_n", Pins("A14")), |
| 109 | + Subsignal("miso", Pins("AB21")), |
| 110 | + Misc("SLEW=FAST"), |
| 111 | + IOStandard("LVCMOS33"), |
| 112 | + ), |
| 113 | + |
| 114 | + ("sdcard", 0, |
| 115 | + Subsignal("data", Pins("AB21 AB22 AB20 W21"),), |
| 116 | + Subsignal("cmd", Pins("Y21"),), |
| 117 | + Subsignal("clk", Pins("Y22")), |
| 118 | + Subsignal("cd", Pins("AA19")), |
| 119 | + Misc("SLEW=FAST"), |
| 120 | + IOStandard("LVCMOS33"), |
| 121 | + ), |
| 122 | +] |
| 123 | +# Connectors --------------------------------------------------------------------------------------- |
| 124 | + |
| 125 | +_connectors = [] # ToDo |
| 126 | + |
| 127 | +# Platform ----------------------------------------------------------------------------------------- |
| 128 | + |
| 129 | +class Platform(Xilinx7SeriesPlatform): |
| 130 | + default_clk_name = "clk50" |
| 131 | + default_clk_period = 1e9/50e6 |
| 132 | + |
| 133 | + def __init__(self, variant="a7-35", toolchain="vivado"): |
| 134 | + device = { |
| 135 | + "a7-35": "xc7a35tfgg484-2", |
| 136 | + "a7-100": "xc7a100tfgg484-2", |
| 137 | + "a7-200": "xc7a200tfbg484-2" |
| 138 | + }[variant] |
| 139 | + Xilinx7SeriesPlatform.__init__(self, device, _io, _connectors, toolchain=toolchain) |
| 140 | + self.toolchain.bitstream_commands = \ |
| 141 | + ["set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]"] |
| 142 | + self.toolchain.additional_commands = \ |
| 143 | + ["write_cfgmem -force -format bin -interface spix4 -size 16 " |
| 144 | + "-loadbit \"up 0x0 {build_name}.bit\" -file {build_name}.bin"] |
| 145 | + self.add_platform_command("set_property INTERNAL_VREF 0.675 [get_iobanks 34]") |
| 146 | + |
| 147 | + def create_programmer(self): |
| 148 | + return VivadoProgrammer(flash_part="mt25ql128-spi-x1_x2_x4") |
| 149 | + |
| 150 | + def do_finalize(self, fragment): |
| 151 | + Xilinx7SeriesPlatform.do_finalize(self, fragment) |
| 152 | + self.add_period_constraint(self.lookup_request("clk50", loose=True), 1e9/50e6) |
0 commit comments