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
|
import os
import subprocess
from amaranth import *
from amaranth.build import *
from amaranth.vendor import LatticeICE40Platform
from .resources import *
class AlchitryCuV2Platform(LatticeICE40Platform):
device = "iCE40HX8K"
package = "CB132"
speed = "1"
default_clk = "clk100"
resources = [
Resource(
"clk100", 0, Pins("P7", dir="i"), Clock(100e6), Attrs(GLOBAL=True,
IO_STANDARD="SB_LVCMOS")
),
Resource("usb", 0,
Subsignal("usb_tx", Pins("P14", dir="o")),
Subsignal("usb_rx", Pins("M9", dir="i")),
Attrs(IO_STANDARD="LVCMOS")
),
*SPIFlashResources(0,
cs_n="P13", clk="P12", copi="M11", cipo="P11",
attrs=Attrs(IO_STANDARD="SB_LVCMOS")
),
*LEDResources(
pins="J11 K11 G12 H12 K14 J12 L14 K12", attrs=Attrs(IO_STANDARD="SB_LVCMOS")
),
*ButtonResources(pins="P8"),
]
connectors = [
# TODO(mciantyre) define these.
]
def toolchain_program(self, products, name):
iceprog = os.environ.get("ICEPROG", "iceprog")
with products.extract("{}.bin".format(name)) as bitstream_filename:
subprocess.check_call([iceprog, "-u", "-b", bitstream_filename])
if __name__ == "__main__":
from .test.blinky import Blinky
AlchitryCuV2Platform().build(Blinky(), do_program=True)
|