Skip to content

Commit db63218

Browse files
committed
Added Arrow AXE5000 target (Altera Agilex 5 A5EC008BM16AE6S)
1 parent db16a7d commit db63218

File tree

3 files changed

+297
-0
lines changed

3 files changed

+297
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Some of the suported boards, see yours? Give LiteX-Boards a try!
108108
├── antmicro_lpddr4_test_board
109109
├── antmicro_sdi_mipi_video_converter
110110
├── arduino_mkrvidor4000
111+
├── arrow_axe5000
111112
├── avalanche
112113
├── avnet_aesku40
113114
├── berkeleylab_marblemini
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
#
2+
# This file is part of LiteX-Boards.
3+
#
4+
# Copyright (c) 2025 Gwenhael Goavec-merou<[email protected]>
5+
#
6+
# SPDX-License-Identifier: BSD-2-Clause
7+
8+
from litex.build.altera import AlteraPlatform
9+
from litex.build.altera.programmer import USBBlaster
10+
from litex.build.generic_platform import Pins, IOStandard, Subsignal, Misc
11+
12+
# IOs ----------------------------------------------------------------------------------------------
13+
14+
_io = [
15+
16+
# Clk
17+
("clk25", 0, Pins("A7"), IOStandard("1.3-V LVCMOS")),
18+
("refclk", 0, Pins("AJ28"), IOStandard("3.3-V LVCMOS")),
19+
("sys_clk100", 0, Pins("BF111"), IOStandard("1.3-V LVCMOS")),
20+
21+
# Serial
22+
("serial", 0,
23+
Subsignal("rx", Pins("AG23")),
24+
Subsignal("tx", Pins("AG24")),
25+
IOStandard("3.3-V LVCMOS"),
26+
),
27+
28+
# Leds
29+
("user_led", 0, Pins("AG21"), IOStandard("3.3-V LVCMOS")),
30+
("rgb_led", 0,
31+
Subsignal("r", Pins("AH22")),
32+
Subsignal("g", Pins("AK21")),
33+
Subsignal("b", Pins("AK20")),
34+
IOStandard("3.3-V LVCMOS"),
35+
),
36+
37+
# Switches
38+
("user_sw", 0, Pins("A14"), IOStandard("1.3-V LVCMOS")),
39+
("user_sw", 1, Pins("A13"), IOStandard("1.3-V LVCMOS")),
40+
41+
# Buttons
42+
("user_btn", 0, Pins("A12"), IOStandard("1.3-V LVCMOS"), Misc("WEAK_PULL_UP_RESISTOR ON")),
43+
44+
# HyperRAM
45+
("hyperram", 0,
46+
Subsignal("dq", Pins("C3 C2 B4 B6 D3 A4 B3 C6")),
47+
Subsignal("rwds", Pins("A6")),
48+
Subsignal("cs_n", Pins("D8")),
49+
Subsignal("rst_n", Pins("F7")),
50+
Subsignal("clk", Pins("D7")),
51+
IOStandard("1.3-V LVCMOS")
52+
),
53+
54+
# VADJ selector between 1.2V(low) and 1.3V(high)
55+
("vsel_1v3", 0, Pins("AJ24"), IOStandard("3.3-V LVCMOS")),
56+
57+
# Accelerometer (LIS3DH)
58+
("accel_int", 0, Pins("AK24 AJ25"), IOStandard("3.3-V LVCMOS")),
59+
("accel_i2c", 0,
60+
Subsignal("sda", Pins("AK26")),
61+
Subsignal("scl", Pins("AH25")),
62+
IOStandard("3.3-V LVCMOS"),
63+
),
64+
]
65+
66+
# Connectors ---------------------------------------------------------------------------------------
67+
68+
_connectors = [
69+
# Arduino MKR Header (J1/J2)
70+
("arduino_io", {
71+
# J1
72+
"AREF" : "AF22", # 1
73+
"AIN0" : "AF23", # 2
74+
"AIN1" : "AF24", # 3
75+
"AIN2" : "AG26", # 4
76+
"AIN3" : "AH28", # 5
77+
"AIN4" : "AH27", # 6
78+
"AIN5" : "AF27", # 7
79+
"AIN6" : "AF26", # 8
80+
"D0" : "AE25", # 9
81+
"D1" : "AF21", # 10
82+
"D2" : "AH20", # 11
83+
"D3" : "AG19", # 12
84+
"D4" : "AF19", # 13
85+
"D5" : "AG20", # 14
86+
87+
# J2
88+
"D6" : "AK19", # 1
89+
"D7" : "AJ19", # 2
90+
"D8" : "AH21", # 3
91+
"D9" : "AH18", # 4
92+
"D10" : "AJ20", # 5
93+
"D11" : "AJ22", # 6 / Also Connected to AK25
94+
"D12" : "AK22", # 7 / Also Connected to AK27
95+
"D13" : "AH23", # 8
96+
"D14" : "AJ23", # 9
97+
"RST" : "---", # 10
98+
"GND" : "---", # 11
99+
"3_3V" : "---", # 12
100+
"VIN" : "---", # 13
101+
"5V" : "---", # 14
102+
}),
103+
104+
# CRUVI header
105+
["J3",
106+
# B2_P/B2_N (27/29) are assigned to 2 sets of pins on the FPGA
107+
# due to MIPI Hard IP pin placement:
108+
# B2_P: U5/T4
109+
# B2_N: AC6/AC5
110+
# -----------------------------------------------------------
111+
" ----", # 0
112+
# NC 3.3V 3.3V ( 1-10).
113+
" ---- N7 AH26 ---- AJ29 N6 AJ27 AF1 ---- AE10",
114+
# GND GND GND GND (11-20).
115+
" AJ28 ---- ---- N2 V6 N1 W5 ---- ---- R2",
116+
# GND GND T4 AC5 GND (21-30).
117+
" AC7 T1 AD7 ---- ---- T2 U5 U1 AC6 ----",
118+
# GND VADJ GND (31-40).
119+
" ---- V1 V3 V2 W3 ---- ---- T3 U4 R4",
120+
# GND GND GND GND GND NC (41-50).
121+
" U3 ---- ---- Y1 P5 W2 P4 ---- ---- ----",
122+
# NC NC NC GND NC NC NC NC NC 5V (51-60).
123+
" ---- ---- ---- ---- ---- ---- ---- ---- ---- ----",
124+
],
125+
]
126+
127+
# Platform -----------------------------------------------------------------------------------------
128+
129+
class Platform(AlteraPlatform):
130+
default_clk_name = "clk25"
131+
default_clk_period = 1e9/25e6
132+
133+
def __init__(self, toolchain="quartus"):
134+
AlteraPlatform.__init__(self, "A5EC008BM16AE6S", _io, _connectors, toolchain=toolchain)
135+
self.create_rbf = True
136+
self.create_svf = False # Not supported for Agilex5 family.
137+
self.add_platform_command("set_global_assignment -name ENABLE_INTERMEDIATE_SNAPSHOTS \"ON\"")
138+
139+
# Calculates clock uncertainties
140+
self.toolchain.additional_sdc_commands.append("derive_clock_uncertainty")
141+
142+
def create_programmer(self):
143+
return USBBlaster(cable_name="USB Blaster III")
144+
145+
def do_finalize(self, fragment):
146+
AlteraPlatform.do_finalize(self, fragment)
147+
self.add_period_constraint(self.lookup_request("clk25", loose=True), 1e9/25e6)
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
#!/usr/bin/env python3
2+
3+
#
4+
# This file is part of LiteX-Boards.
5+
#
6+
# Copyright (c) 2025 Gwenhael Goavec-merou<[email protected]>
7+
#
8+
# SPDX-License-Identifier: BSD-2-Clause
9+
10+
from migen import *
11+
12+
from litex.gen import *
13+
14+
from litex_boards.platforms import arrow_axe5000
15+
16+
from litex.soc.interconnect import wishbone
17+
18+
from litex.soc.integration.soc import *
19+
from litex.soc.integration.soc_core import *
20+
from litex.soc.integration.builder import *
21+
22+
from litex.soc.cores.clock import Agilex5PLL
23+
from litex.soc.cores.hyperbus import HyperRAM
24+
from litex.soc.cores.led import LedChaser
25+
26+
27+
# CRG ----------------------------------------------------------------------------------------------
28+
29+
class _CRG(LiteXModule):
30+
def __init__(self, platform, sys_clk_freq):
31+
self.rst = Signal()
32+
self.cd_sys = ClockDomain()
33+
self.cd_sys2x = ClockDomain()
34+
35+
# # #
36+
37+
# Clk / Rst
38+
clk25 = platform.request("clk25")
39+
rst_n = platform.request("user_btn", 0)
40+
41+
# Power on reset
42+
ninit_done = Signal()
43+
self.specials += Instance("altera_agilex_config_reset_release_endpoint", o_conf_reset = ninit_done)
44+
45+
# PLL
46+
self.pll = pll = Agilex5PLL(speedgrade="-6S")
47+
self.comb += pll.reset.eq(ninit_done | ~rst_n)
48+
pll.register_clkin(clk25, 25e6)
49+
pll.create_clkout(self.cd_sys, sys_clk_freq)
50+
51+
# HyperRAM
52+
pll.create_clkout(self.cd_sys2x, 2*sys_clk_freq)
53+
54+
# BaseSoC ------------------------------------------------------------------------------------------
55+
56+
class BaseSoC(SoCCore):
57+
def __init__(self, sys_clk_freq=100e6,
58+
with_l2_cache = False,
59+
with_led_chaser = True,
60+
**kwargs):
61+
platform = arrow_axe5000.Platform()
62+
63+
# Select 1.3V, for HSIO on CRUVI-HS
64+
self.comb += platform.request("vsel_1v3").eq(0b1)
65+
66+
# CRG --------------------------------------------------------------------------------------
67+
self.crg = _CRG(platform, sys_clk_freq)
68+
69+
# SoCCore ----------------------------------------------------------------------------------
70+
SoCCore.__init__(self, platform, sys_clk_freq, ident="LiteX SoC on Arrow AXE5000", **kwargs)
71+
72+
# HyperRAM ---------------------------------------------------------------------------------
73+
if not self.integrated_main_ram_size:
74+
# HyperRAM Parameters.
75+
hyperram_size = 16 * MEGABYTE
76+
hyperram_cache_size = 16 * KILOBYTE
77+
78+
# HyperRAM Bus/Slave Interface.
79+
hyperram_bus = wishbone.Interface(data_width=32, address_width=32, addressing="word")
80+
self.bus.add_slave(
81+
name = "main_ram",
82+
slave = hyperram_bus,
83+
region = SoCRegion(origin=self.mem_map["main_ram"], size=hyperram_size, mode="rwx")
84+
)
85+
86+
# HyperRAM L2 Cache.
87+
if with_l2_cache:
88+
hyperram_cache = wishbone.Cache(
89+
cachesize = hyperram_cache_size // 4,
90+
master = hyperram_bus,
91+
slave = wishbone.Interface(data_width=32, address_width=32, addressing="word")
92+
)
93+
self.hyperram_cache = FullMemoryWE()(hyperram_cache)
94+
self.add_config("L2_SIZE", hyperram_cache_size)
95+
96+
# HyperRAM Core.
97+
self.hyperram = HyperRAM(
98+
pads = platform.request("hyperram"),
99+
latency = 7,
100+
latency_mode = "variable",
101+
sys_clk_freq = sys_clk_freq,
102+
clk_ratio = "2:1", # Not working with 4:1
103+
)
104+
105+
if with_l2_cache:
106+
self.comb += self.hyperram_cache.slave.connect(self.hyperram.bus)
107+
else:
108+
self.comb += hyperram_bus.connect(self.hyperram.bus)
109+
110+
# Leds -------------------------------------------------------------------------------------
111+
if with_led_chaser:
112+
led_pads = platform.request_all("user_led")
113+
rgb_led_pads = platform.request("rgb_led", 0)
114+
self.comb += [getattr(rgb_led_pads, n).eq(1) for n in "gb"] # Disable Green/Blue Leds.
115+
self.leds = LedChaser(
116+
pads = Cat(led_pads, rgb_led_pads.r),
117+
sys_clk_freq = sys_clk_freq)
118+
119+
# Build --------------------------------------------------------------------------------------------
120+
121+
def main():
122+
from litex.build.parser import LiteXArgumentParser
123+
parser = LiteXArgumentParser(platform=arrow_axe5000.Platform, description="LiteX SoC on Arrow AXE5000.")
124+
parser.add_target_argument("--sys-clk-freq", default=100e6, type=float, help="System clock frequency.")
125+
parser.add_target_argument("--with-l2-cache", action="store_true", help="Enable Main RAM L2 cache.")
126+
127+
# Overrides defaults synth/conv tools.
128+
parser.set_defaults(synth_tool = "quartus_syn")
129+
parser.set_defaults(conv_tool = "quartus_pfg")
130+
131+
# soc.json default path
132+
args = parser.parse_args()
133+
134+
soc = BaseSoC(
135+
sys_clk_freq = args.sys_clk_freq,
136+
with_l2_cache = args.with_l2_cache,
137+
**parser.soc_argdict
138+
)
139+
140+
builder = Builder(soc, **parser.builder_argdict)
141+
if args.build:
142+
builder.build(**parser.toolchain_argdict)
143+
144+
if args.load:
145+
prog = soc.platform.create_programmer()
146+
prog.load_bitstream(builder.get_bitstream_filename(mode="sram"))
147+
148+
if __name__ == "__main__":
149+
main()

0 commit comments

Comments
 (0)