Skip to content

Commit a7d4422

Browse files
committed
Add support for S7 Mini (TE0890).
1 parent 15ad3ab commit a7d4422

File tree

2 files changed

+178
-0
lines changed

2 files changed

+178
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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)
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env python3
2+
3+
#
4+
# This file is part of LiteX-Boards.
5+
#
6+
# Copyright (c) 2024 Philip Kirkpatrick <[email protected]>
7+
# SPDX-License-Identifier: BSD-2-Clause
8+
9+
from migen import *
10+
11+
from litex.gen import *
12+
13+
from litex_boards.platforms import trenz_te0890
14+
15+
from litex.soc.cores.clock import *
16+
from litex.soc.integration.soc import SoCRegion
17+
from litex.soc.integration.soc_core import *
18+
from litex.soc.integration.builder import *
19+
from litex.soc.cores.led import LedChaser
20+
21+
from litex.soc.cores.hyperbus import HyperRAM
22+
23+
# CRG ----------------------------------------------------------------------------------------------
24+
25+
class _CRG(LiteXModule):
26+
def __init__(self, platform, sys_clk_freq):
27+
self.rst = Signal()
28+
self.cd_sys = ClockDomain()
29+
30+
self.pll = pll = S7PLL(speedgrade=-1)
31+
self.comb += pll.reset.eq(~platform.request("cpu_reset") | self.rst)
32+
pll.register_clkin(platform.request("clk100"), 100e6)
33+
pll.create_clkout(self.cd_sys, sys_clk_freq)
34+
35+
# BaseSoC ------------------------------------------------------------------------------------------
36+
37+
class BaseSoC(SoCCore):
38+
def __init__(self, sys_clk_freq=100e6, with_led_chaser=True, **kwargs):
39+
platform = trenz_te0890.Platform()
40+
41+
# CRG --------------------------------------------------------------------------------------
42+
self.crg = _CRG(platform, sys_clk_freq)
43+
44+
# SoCCore ----------------------------------------------------------------------------------
45+
SoCCore.__init__(self, platform, sys_clk_freq, ident="LiteX SoC on Trenz TE0890 Board", **kwargs)
46+
47+
# Use HyperRAM generic PHY as SRAM ---------------------------------------------------------
48+
size = int((64*1024*1024) / 8)
49+
hr_pads = platform.request("hyperram", 0)
50+
self.hyperram = HyperRAM(hr_pads, sys_clk_freq=sys_clk_freq)
51+
self.bus.add_slave("hyperram", slave=self.hyperram.bus, region=SoCRegion(origin=0x20000000, size=size))
52+
53+
# Leds -------------------------------------------------------------------------------------
54+
if with_led_chaser:
55+
self.leds = LedChaser(
56+
pads = platform.request_all("user_led"),
57+
sys_clk_freq = sys_clk_freq)
58+
59+
# Build --------------------------------------------------------------------------------------------
60+
61+
def main():
62+
from litex.build.parser import LiteXArgumentParser
63+
parser = LiteXArgumentParser(platform=trenz_te0890.Platform, description="LiteX SoC on Trenz TE0890.")
64+
parser.add_target_argument("--flash", action="store_true", help="Flash bitstream.")
65+
parser.add_target_argument("--sys-clk-freq", default=100e6, type=float, help="System clock frequency.")
66+
67+
args = parser.parse_args()
68+
69+
soc = BaseSoC(
70+
sys_clk_freq = args.sys_clk_freq,
71+
**parser.soc_argdict
72+
)
73+
74+
builder = Builder(soc, **parser.builder_argdict)
75+
if args.build:
76+
builder.build(**parser.toolchain_argdict)
77+
78+
if args.load:
79+
prog = soc.platform.create_programmer()
80+
prog.load_bitstream(builder.get_bitstream_filename(mode="sram"))
81+
82+
if args.flash:
83+
prog = soc.platform.create_programmer()
84+
prog.flash(0x000, builder.get_bitstream_filename(mode="flash"), external=True)
85+
86+
if __name__ == "__main__":
87+
main()
88+

0 commit comments

Comments
 (0)