|
| 1 | +import os |
| 2 | +import subprocess |
| 3 | + |
| 4 | +from amaranth.build import * |
| 5 | +from amaranth.vendor.intel import * |
| 6 | +from .resources import * |
| 7 | + |
| 8 | + |
| 9 | +__all__ = ["ArrowDECAPlatform"] |
| 10 | + |
| 11 | + |
| 12 | +class ArrowDECAPlatform(IntelPlatform): |
| 13 | + device = "10M50DA" # MAX 10 |
| 14 | + package = "F484" |
| 15 | + speed = "C6" |
| 16 | + suffix = "GES" |
| 17 | + default_clk = "clk50" |
| 18 | + resources = [ |
| 19 | + Resource("clk50", 0, Pins("M8", dir="i"), |
| 20 | + Clock(50e6), Attrs(io_standard="2.5 V")), |
| 21 | + Resource("clk50", 1, Pins("P11", dir="i"), |
| 22 | + Clock(50e6), Attrs(io_standard="3.3 V")), |
| 23 | + Resource("clk50", 2, Pins("N15", dir="i"), |
| 24 | + Clock(50e6), Attrs(io_standard="1.5 V")), |
| 25 | + Resource("clk10", 0, Pins("M9", dir="i"), |
| 26 | + Clock(10e6), Attrs(io_standard="2.5 V")), |
| 27 | + |
| 28 | + *LEDResources( |
| 29 | + pins="C7 C8 A6 B7 C4 A5 B4 C5", |
| 30 | + invert=True, |
| 31 | + attrs=Attrs(io_standard="1.2 V")), |
| 32 | + *ButtonResources( |
| 33 | + pins="H21 H22", |
| 34 | + invert=True, |
| 35 | + attrs=Attrs(io_standard="1.5 V")), |
| 36 | + *SwitchResources( |
| 37 | + pins="J21 J22", |
| 38 | + attrs=Attrs(io_standard="1.5 V")), |
| 39 | + ] |
| 40 | + connectors = [ |
| 41 | + Connector("gpio", 0, |
| 42 | + "W18 Y18 Y19 AA17 AA20 AA19 AB21 AB20 AB19 Y16 V16 " |
| 43 | + "AB18 V15 W17 AB17 AA16 AB16 W16 AB15 W15 Y14 AA15 " |
| 44 | + "AB14 AA14 AB13 AA13 AB12 AA12 AB11 AA11 AB10 Y13 Y11 " |
| 45 | + "W13 W12 W11 V12 V11 V13 V14 Y17 W14 U15 R13"), |
| 46 | + Connector("gpio", 1, |
| 47 | + "Y5 Y6 W6 W7 W8 V8 AB8 V7 R11 AB7 AB6 " |
| 48 | + "AA7 AA6 Y7 V10 U7 W9 W5 R9 W4 P9 V17 " |
| 49 | + "W3"), |
| 50 | + ] |
| 51 | + |
| 52 | + def toolchain_program(self, products, name): |
| 53 | + quartus_pgm = os.environ.get("QUARTUS_PGM", "quartus_pgm") |
| 54 | + with products.extract("{}.sof".format(name)) as bitstream_filename: |
| 55 | + subprocess.check_call([quartus_pgm, "--haltcc", "--mode", "JTAG", |
| 56 | + "--operation", "P;" + bitstream_filename]) |
| 57 | + |
| 58 | + @property |
| 59 | + def file_templates(self): |
| 60 | + # Configure the voltages of the I/O banks by appending the global |
| 61 | + # assignments to the template. However, we create our own copy of the |
| 62 | + # file templates before modifying them to avoid modifying the original. |
| 63 | + return { |
| 64 | + **super().file_templates, |
| 65 | + "{{name}}.qsf": |
| 66 | + super().file_templates.get("{{name}}.qsf") + |
| 67 | + r""" |
| 68 | + set_global_assignment -name IOBANK_VCCIO 2.5V -section_id 1A |
| 69 | + set_global_assignment -name IOBANK_VCCIO 2.5V -section_id 1B |
| 70 | + set_global_assignment -name IOBANK_VCCIO 2.5V -section_id 2 |
| 71 | + set_global_assignment -name IOBANK_VCCIO 3.3V -section_id 3 |
| 72 | + set_global_assignment -name IOBANK_VCCIO 3.3V -section_id 4 |
| 73 | + set_global_assignment -name IOBANK_VCCIO 1.5V -section_id 5 |
| 74 | + set_global_assignment -name IOBANK_VCCIO 1.5V -section_id 6 |
| 75 | + set_global_assignment -name IOBANK_VCCIO 1.8V -section_id 7 |
| 76 | + set_global_assignment -name IOBANK_VCCIO 1.2V -section_id 8 |
| 77 | +
|
| 78 | + set_global_assignment -name FORCE_CONFIGURATION_VCCIO ON |
| 79 | + set_global_assignment -name AUTO_RESTART_CONFIGURATION OFF |
| 80 | + set_global_assignment -name ENABLE_CONFIGURATION_PINS OFF |
| 81 | + set_global_assignment -name ENABLE_BOOT_SEL_PIN OFF |
| 82 | + """ |
| 83 | + } |
| 84 | + |
| 85 | + |
| 86 | +if __name__ == "__main__": |
| 87 | + from .test.blinky import Blinky |
| 88 | + ArrowDECAPlatform().build(Blinky(), do_program=True) |
0 commit comments