|
| 1 | +# |
| 2 | +# This file is part of LiteX-Boards. |
| 3 | +# FPGA Board Info : https://shop.trenz-electronic.de/de/TE0890-01-P1C-5-A-S7-Mini-Fully-Open-Source-Modul-mit-AMD-Spartan-7-7S25-64-Mbit-HyperRAM?c=525 |
| 4 | +# |
| 5 | +# Copyright (c) 2024 Philip Kirkpatrick <[email protected]> |
| 6 | +# SPDX-License-Identifier: BSD-2-Clause |
| 7 | + |
| 8 | +from litex.build.generic_platform import * |
| 9 | +from litex.build.xilinx import Xilinx7SeriesPlatform |
| 10 | +from litex.build.openfpgaloader import OpenFPGALoader |
| 11 | + |
| 12 | +# IOs ---------------------------------------------------------------------------------------------- |
| 13 | + |
| 14 | +_io = [ |
| 15 | + # Clk / Rst |
| 16 | + ("clk100", 0, Pins("L5"), IOStandard("LVCMOS33")), |
| 17 | + ("cpu_reset", 0, Pins("B10"), IOStandard("LVCMOS33")), |
| 18 | + |
| 19 | + # Leds |
| 20 | + ("user_led", 0, Pins("D14"), IOStandard("LVCMOS33")), |
| 21 | + |
| 22 | + # Serial |
| 23 | + ("serial", 0, |
| 24 | + Subsignal("tx", Pins("A5")), |
| 25 | + Subsignal("rx", Pins("A12")), |
| 26 | + IOStandard("LVCMOS33") |
| 27 | + ), |
| 28 | + |
| 29 | + # SPIFlash |
| 30 | + ("spiflash", 0, |
| 31 | + Subsignal("cs_n", Pins("C11")), |
| 32 | + Subsignal("clk", Pins("A8")), |
| 33 | + Subsignal("mosi", Pins("B11")), |
| 34 | + Subsignal("miso", Pins("B12")), |
| 35 | + IOStandard("LVCMOS33"), |
| 36 | + ), |
| 37 | + |
| 38 | + # HyperRAM |
| 39 | + ("hyperram", 0, |
| 40 | + Subsignal("dq", Pins("P11 P12 N4 P10 P5 N10 N11 P13"), IOStandard("LVCMOS33")), |
| 41 | + Subsignal("rwds", Pins("P4"), IOStandard("LVCMOS33")), |
| 42 | + Subsignal("cs_n", Pins("P2"), IOStandard("LVCMOS33")), |
| 43 | + Subsignal("rst_n", Pins("P3"), IOStandard("LVCMOS33")), |
| 44 | + Subsignal("clk", Pins("N1"), IOStandard("LVCMOS33")), |
| 45 | + Misc("SLEW=FAST"), |
| 46 | + ), |
| 47 | +] |
| 48 | + |
| 49 | +# Connectors --------------------------------------------------------------------------------------- |
| 50 | + |
| 51 | +_connectors = [ |
| 52 | + ("j1", " A2 C4 D4 A3 B3 C5 E4 C3", |
| 53 | + " B2 C1 D2 F1 B1 D1 E2 G1", |
| 54 | + " F3 F4 H3 J3 F2 G4 H4 J4", |
| 55 | + " K3 L2 M2 M4 K4 L3 M3 M5"), |
| 56 | + ("j2", "J12 M14 K12 M12 J11 N14 K11 M11", |
| 57 | + "H13 J13 L12 L14 H14 J14 L13 M13", |
| 58 | + "F14 E12 F11 H12 G14 F12 G11 H11", |
| 59 | + "E11 C10 D12 E13 C12 D10 D13 F13"), |
| 60 | +] |
| 61 | + |
| 62 | +# Platform ----------------------------------------------------------------------------------------- |
| 63 | + |
| 64 | +class Platform(Xilinx7SeriesPlatform): |
| 65 | + default_clk_name = "clk100" |
| 66 | + default_clk_period = 1e9/100e6 |
| 67 | + |
| 68 | + def __init__(self, toolchain="vivado"): |
| 69 | + Xilinx7SeriesPlatform.__init__(self, "xc7s25ftgb196-1", _io, _connectors, toolchain=toolchain) |
| 70 | + self.toolchain.bitstream_commands = \ |
| 71 | + ["set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 1 [current_design]"] |
| 72 | + self.toolchain.additional_commands = \ |
| 73 | + ["write_cfgmem -force -format bin -interface spix1 -size 8" |
| 74 | + " -loadbit \"up 0x0 {build_name}.bit\" -file {build_name}.bin"] |
| 75 | + self.add_platform_command("set_property CFGBVS VCCO [current_design]") |
| 76 | + self.add_platform_command("set_property CONFIG_VOLTAGE 3.3 [current_design]") |
| 77 | + # For some reason this board places the clock on a non clock dedicated pin. |
| 78 | + # Tell Vivado to ignore this and just deal with it. |
| 79 | + self.add_platform_command("set_property CLOCK_DEDICATED_ROUTE FALSE [get_nets clk100_IBUF]") |
| 80 | + |
| 81 | + def create_programmer(self): |
| 82 | + # OpenFPGALoader doesn't have a spiOverJtag bit for the ftgb196 package, but does have one |
| 83 | + # for the csga225. Based on a hint from bscan_spi_bitstreams, it seems the package doesn't |
| 84 | + # matter, so lie here to make it work. |
| 85 | + # (https://github.com/quartiq/bscan_spi_bitstreams/blob/master/xilinx_bscan_spi.py#L358) |
| 86 | + return OpenFPGALoader(cable="ft2232", fpga_part=f"xc7s25csga225") |
| 87 | + |
| 88 | + def do_finalize(self, fragment): |
| 89 | + Xilinx7SeriesPlatform.do_finalize(self, fragment) |
| 90 | + self.add_period_constraint(self.lookup_request("clk100", loose=True), 1e9/100e6) |
0 commit comments