aboutsummaryrefslogtreecommitdiff
path: root/amaranth_boards/fomu_pvt.py
blob: 70db867c48350c4a8e9b5319b44a13d64f25fc81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
import subprocess

from amaranth.build import *
from amaranth.vendor import LatticeICE40Platform
from .resources import *


__all__ = ["FomuPVTPlatform"]


class FomuPVTPlatform(LatticeICE40Platform):
    device      = "iCE40UP5K"
    package     = "UWG30"
    default_clk = "clk48"
    resources   = [
        Resource("clk48", 0, Pins("F4", dir="i"),
                 Clock(48e6), Attrs(GLOBAL=True, IO_STANDARD="SB_LVCMOS")),

        *LEDResources(pins="A5", invert=True, attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
        RGBLEDResource(0,
            r="B5", g="A5", b="C5", invert=True,
            attrs=Attrs(IO_STANDARD="SB_LVCMOS")
        ),


        DirectUSBResource(0, d_p="A1", d_n="A2", pullup="A4",
                attrs=Attrs(IO_STANDARD="SB_LVCMOS")),

        *SPIFlashResources(0,
            cs_n="C1", clk="D1", copi="F1", cipo="E1",
            attrs=Attrs(IO_STANDARD="SB_LVCMOS"),
        ),

        Resource("touch", 0, Pins("E4")),
        Resource("touch", 1, Pins("D5")),
        Resource("touch", 2, Pins("E5")),
        Resource("touch", 3, Pins("F5")),
    ]

    connectors = []

    def toolchain_program(self, products, name):
        dfu_util = os.environ.get("DFU_UTIL", "dfu-util")
        with products.extract("{}.bin".format(name)) as bitstream_filename:
            subprocess.check_call([dfu_util, "-D", bitstream_filename])


if __name__ == "__main__":
    from .test.blinky import *
    FomuPVTPlatform().build(Blinky(), do_program=True)