|
| 1 | +import os |
| 2 | +import subprocess |
| 3 | + |
| 4 | +from amaranth.build import * |
| 5 | +from amaranth.vendor.xilinx import * |
| 6 | +from .resources import * |
| 7 | + |
| 8 | +""" |
| 9 | +Example Usage: |
| 10 | + platform = CModA7_35Platform(toolchain="Symbiflow") |
| 11 | + platform.build(Top(), do_program=True) |
| 12 | +
|
| 13 | +Supported programmer: |
| 14 | + openocd |
| 15 | +""" |
| 16 | + |
| 17 | +__all__ = ["CmodA7_15Platform", "CmodA7_35Platform"] |
| 18 | + |
| 19 | + |
| 20 | +class _CmodA7Platform(XilinxPlatform): |
| 21 | + package = "cpg236" |
| 22 | + speed = "1" |
| 23 | + default_clk = "clk12" |
| 24 | + resources = [ |
| 25 | + Resource("clk12", 0, Pins("L17", dir="i"), |
| 26 | + Clock(12e6), Attrs(IOSTANDARD="LVCMOS33")), |
| 27 | + |
| 28 | + *LEDResources(pins="A17 C16", attrs=Attrs(IOSTANDARD="LVCMOS33")), |
| 29 | + |
| 30 | + RGBLEDResource(0, r="C17", g="B16", b="B17", invert=True, |
| 31 | + attrs=Attrs(IOSTANDARD="LVCMOS33")), |
| 32 | + |
| 33 | + *ButtonResources(pins="A18 B18", attrs=Attrs(IOSTANDARD="LVCMOS33")), |
| 34 | + |
| 35 | + UARTResource(0, |
| 36 | + rx="J18", tx="J17", |
| 37 | + attrs=Attrs(IOSTANDARD="LVCMOS33") |
| 38 | + ), |
| 39 | + |
| 40 | + *SPIFlashResources(0, |
| 41 | + cs_n="K19", clk="E19", copi="D19", cipo="D18", wp_n="G18", |
| 42 | + hold_n="F18", |
| 43 | + attrs=Attrs(IOSTANDARD="LVCMOS33") |
| 44 | + ), |
| 45 | + |
| 46 | + SRAMResource(0, |
| 47 | + cs_n="N19", oe_n="P19", we_n="R19", |
| 48 | + a="M18 M19 K17 N17 P17 P18 R18 W19 U19 V19 W18 T17 T18 U17 U18 V16 W16 W17 V15", |
| 49 | + d="W15 W13 W14 U15 U16 V13 V14 U14"), |
| 50 | + |
| 51 | + # One-wire interface to crypto authentication device |
| 52 | + # May not be populated on the board |
| 53 | + Resource("atsha204a", 0, Pins("D17", dir="io"), |
| 54 | + Attrs(IOSTANDARD="LVCMOS33")) |
| 55 | + ] |
| 56 | + connectors = [ |
| 57 | + Connector("pmod", 0, "G17 G19 N18 L18 - - H17 H19 J19 K18 - -"), # JA |
| 58 | + |
| 59 | + # Pin 24/25 are VCC and GND |
| 60 | + # Pin 15/16 are analog (XADC) |
| 61 | + Connector("gpio", 0, |
| 62 | + """ |
| 63 | + M3 L3 A16 K3 C15 H1 A15 B15 A14 J3 J1 K2 |
| 64 | + L1 L2 - - M1 M3 P3 M2 N1 N2 P1 - |
| 65 | + - R3 T3 R2 T1 T2 U1 W2 V2 W3 V3 W5 |
| 66 | + V4 U4 V5 W4 U5 U2 W6 U3 U7 W7 U8 V8 |
| 67 | + """), |
| 68 | + |
| 69 | + Connector("xadc", 0, { |
| 70 | + "vaux4_n": "G2", |
| 71 | + "vaux4_p": "G3", |
| 72 | + "vaux12_n": "J2", |
| 73 | + "vaux12_p": "H2" |
| 74 | + }) |
| 75 | + ] |
| 76 | + |
| 77 | + def toolchain_program(self, products, name): |
| 78 | + with products.extract("{}.bit".format(name)) as bitstream_filename: |
| 79 | + subprocess.check_call(["openFPGALoader", |
| 80 | + "-c", "digilent", |
| 81 | + "--fpga-part", "xc7a35", |
| 82 | + "{}".format(bitstream_filename) |
| 83 | + ]) |
| 84 | + |
| 85 | + |
| 86 | +class CmodA7_15Platform(_CmodA7Platform): |
| 87 | + device = "xc7a15t" |
| 88 | + |
| 89 | +class CmodA7_35Platform(_CmodA7Platform): |
| 90 | + device = "xc7a35t" |
| 91 | + |
| 92 | +if __name__ == "__main__": |
| 93 | + from .test.blinky import * |
| 94 | + CmodA7_35Platform().build(Blinky(), do_program=True) |
0 commit comments