|
| 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 = CModS7_Platform(toolchain="Symbiflow") |
| 11 | + platform.build(Top(), do_program=True) |
| 12 | +
|
| 13 | +Supported programmer: |
| 14 | + openocd |
| 15 | +""" |
| 16 | + |
| 17 | +__all__ = ["CmodS7_Platform"] |
| 18 | + |
| 19 | + |
| 20 | +class CmodS7_Platform(XilinxPlatform): |
| 21 | + device = "xc7s25" |
| 22 | + package = "csga225" |
| 23 | + speed = "1" |
| 24 | + default_clk = "clk12" |
| 25 | + resources = [ |
| 26 | + Resource("clk12", 0, Pins("M9", dir="i"), |
| 27 | + Clock(12e6), Attrs(IOSTANDARD="LVCMOS33")), |
| 28 | + |
| 29 | + *LEDResources(pins="E2 K1 J1 E1", attrs=Attrs(IOSTANDARD="LVCMOS33")), |
| 30 | + |
| 31 | + RGBLEDResource(0, r="F2", g="D3", b="F1", invert=True, |
| 32 | + attrs=Attrs(IOSTANDARD="LVCMOS33")), |
| 33 | + |
| 34 | + *ButtonResources(pins="D2 D1", attrs=Attrs(IOSTANDARD="LVCMOS33")), |
| 35 | + |
| 36 | + UARTResource(0, |
| 37 | + rx="L12", tx="K15", |
| 38 | + attrs=Attrs(IOSTANDARD="LVCMOS33") |
| 39 | + ), |
| 40 | + |
| 41 | + # Clock only via STARTUPE2 primitive |
| 42 | + *SPIFlashResources(0, |
| 43 | + cs_n="L11", clk="F5", copi="H14", cipo="H15", wp_n="J12", |
| 44 | + hold_n="K13", |
| 45 | + attrs=Attrs(IOSTANDARD="LVCMOS33") |
| 46 | + ), |
| 47 | + |
| 48 | + # One-wire interface to crypto authentication device |
| 49 | + # May not be populated on the board |
| 50 | + Resource("atsha204a", 0, Pins("D17", dir="io"), |
| 51 | + Attrs(IOSTANDARD="LVCMOS33")) |
| 52 | + ] |
| 53 | + connectors = [ |
| 54 | + Connector("pmod", 0, "J2 H2 H4 F3 - - H3 H1 G1 F4 - -"), # JA |
| 55 | + |
| 56 | + # Pin 24/25 are VCC and GND |
| 57 | + # Pin 32/33 are analog (XADC) |
| 58 | + # Pin 9-15 and 34-39 do not exist |
| 59 | + Connector("gpio", 0, |
| 60 | + """ |
| 61 | + L1 M4 M3 N2 M2 P3 N3 P1 N1 - - - |
| 62 | + - - - P14 P15 N13 N15 N14 M15 M14 L15 - |
| 63 | + - L14 K14 J15 L13 M13 J11 - - - - - |
| 64 | + - - - C5 A2 B2 B1 C1 B3 B4 A3 A4 |
| 65 | + """), |
| 66 | + |
| 67 | + Connector("xadc", 0, { |
| 68 | + "vaux5_n": "A13", |
| 69 | + "vaux5_p": "A14", |
| 70 | + "vaux12_n": "A11", |
| 71 | + "vaux12_p": "A12" |
| 72 | + }) |
| 73 | + ] |
| 74 | + |
| 75 | + def toolchain_program(self, products, name): |
| 76 | + openocd = os.environ.get("OPENOCD", "openocd") |
| 77 | + with products.extract("{}.bit".format(name)) as bitstream_filename: |
| 78 | + subprocess.check_call([openocd, |
| 79 | + # Use for debug output |
| 80 | + #"-d", |
| 81 | + "-c", |
| 82 | + "source [find board/digilent_cmod_s7.cfg]; init; pld load 0 {}; exit" |
| 83 | + .format(bitstream_filename) |
| 84 | + ]) |
| 85 | + |
| 86 | + |
| 87 | +if __name__ == "__main__": |
| 88 | + from .test.blinky import * |
| 89 | + CmodS7_Platform().build(Blinky(), do_program=True) |
0 commit comments