|
| 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) |
0 commit comments