|
| 1 | +import os |
| 2 | +import subprocess |
| 3 | + |
| 4 | +from amaranth.build import * |
| 5 | +from amaranth.vendor import LatticeMachXO2Platform |
| 6 | +from .resources import * |
| 7 | + |
| 8 | + |
| 9 | +__all__ = ["MachXO2_7000HE_BreakoutPlatform", "MachXO2_1200ZE_BreakoutPlatform"] |
| 10 | + |
| 11 | + |
| 12 | +# https://www.latticesemi.com/Products/DevelopmentBoardsAndKits/MachXO2BreakoutBoard |
| 13 | +class MachXO2_7000HE_BreakoutPlatform(LatticeMachXO2Platform): |
| 14 | + device = "LCMXO2-7000HE" |
| 15 | + package = "TG144" |
| 16 | + default_clk = "OSCH" |
| 17 | + osch_frequency = 2.08 # documented default; see amaranth.vendor.lattice_machxo_2_3l for more options |
| 18 | + speed = "4" |
| 19 | + resources = [ |
| 20 | + *LEDResources(pins="97 98 99 100 104 105 106 107", invert=True), |
| 21 | + |
| 22 | + # Connectable to the FTDI UART but disconnected by default. Populate R14-R21 to connect. |
| 23 | + UARTResource(0, rx="73", tx="74", rts="75", cts="76", dtr="81", dsr="77", dcd="78", role="dte"), |
| 24 | + ] |
| 25 | + connectors = [ |
| 26 | + Connector("j", 2, # J2 |
| 27 | + "- - " |
| 28 | + "109 - " # 110: INITn |
| 29 | + "111 112 " |
| 30 | + "- - " |
| 31 | + "113 114 " |
| 32 | + "115 117 " |
| 33 | + "119 120 " |
| 34 | + "- - " |
| 35 | + "121 122 " |
| 36 | + "125 126 " |
| 37 | + "127 128 " |
| 38 | + "- - " |
| 39 | + "- - " # 130: TMS, 131: TCK |
| 40 | + "132 133 " |
| 41 | + "- - " # 136: TDI, 137: TDO |
| 42 | + "- - " |
| 43 | + "138 139 " |
| 44 | + "140 141 " |
| 45 | + "142 143 " |
| 46 | + "- - "), |
| 47 | + Connector("j", 3, # J3 |
| 48 | + "- - " |
| 49 | + "- - " |
| 50 | + "74 73 " |
| 51 | + "76 75 " |
| 52 | + "- - " |
| 53 | + "78 77 " |
| 54 | + "82 81 " |
| 55 | + "- - " |
| 56 | + "84 83 " |
| 57 | + "86 85 " |
| 58 | + "- - " |
| 59 | + "92 91 " |
| 60 | + "94 93 " |
| 61 | + "- - " |
| 62 | + "96 95 " |
| 63 | + "98 97 " |
| 64 | + "- - " |
| 65 | + "100 99 " |
| 66 | + "105 104 " |
| 67 | + "107 106 "), |
| 68 | + Connector("j", 4, # J4 |
| 69 | + "- - " |
| 70 | + "- - " |
| 71 | + "1 2 " |
| 72 | + "3 4 " |
| 73 | + "5 6 " |
| 74 | + "9 10 " |
| 75 | + "- - " |
| 76 | + "11 12 " |
| 77 | + "13 14 " |
| 78 | + "- - " |
| 79 | + "19 20 " |
| 80 | + "21 22 " |
| 81 | + "- - " |
| 82 | + "23 24 " |
| 83 | + "25 26 " |
| 84 | + "- - " |
| 85 | + "27 28 " |
| 86 | + "- - " |
| 87 | + "32 33 " |
| 88 | + "34 35 "), |
| 89 | + Connector("j", 5, # J5 |
| 90 | + "- - " |
| 91 | + "71 69 " |
| 92 | + "70 68 " |
| 93 | + "67 62 " |
| 94 | + "65 61 " |
| 95 | + "- - " |
| 96 | + "60 58 " |
| 97 | + "59 57 " |
| 98 | + "- - " |
| 99 | + "56 54 " |
| 100 | + "55 52 " |
| 101 | + "- - " |
| 102 | + "50 48 " |
| 103 | + "49 47 " |
| 104 | + "- - " |
| 105 | + "45 43 " |
| 106 | + "44 42 " |
| 107 | + "- - " |
| 108 | + "41 39 " |
| 109 | + "40 38 "), |
| 110 | + ] |
| 111 | + |
| 112 | + def toolchain_program(self, products, name): |
| 113 | + tool = os.environ.get("OPENFPGALOADER", "openFPGALoader") |
| 114 | + with products.extract("{}.bit".format(name)) as bitstream_filename: |
| 115 | + subprocess.check_call([tool, "-b", "machXO2EVN", "-m", bitstream_filename]) |
| 116 | + |
| 117 | + |
| 118 | +# This is an older version of the board, that has an FPGA with less logic |
| 119 | +# resources. It is otherwise the same. |
| 120 | +class MachXO2_1200ZE_BreakoutPlatform(MachXO2_7000HE_BreakoutPlatform): |
| 121 | + device = "LCMXO2-1200ZE" |
| 122 | + speed = "1" |
| 123 | + |
| 124 | + |
| 125 | +if __name__ == "__main__": |
| 126 | + from .test.blinky import * |
| 127 | + MachXO2_7000HE_BreakoutPlatform().build(Blinky(), do_program=True) |
0 commit comments