Skip to content

Commit 3ab966b

Browse files
Tom KeddieTomKeddie
Tom Keddie
authored andcommitted
butterstick: add board defn for r1.0
1 parent bd7fdd3 commit 3ab966b

File tree

1 file changed

+155
-0
lines changed

1 file changed

+155
-0
lines changed

nmigen_boards/butterstick.py

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
import os
2+
import subprocess
3+
import shutil
4+
5+
from nmigen.build import *
6+
from nmigen.vendor.lattice_ecp5 import *
7+
from .resources import *
8+
9+
10+
__all__ = ["ButterStickPlatform"]
11+
12+
13+
class ButterStickPlatform(LatticeECP5Platform):
14+
device = "LFE5U-85F"
15+
package = "BG381"
16+
speed = "8"
17+
default_clk = "clk30"
18+
resources = [
19+
Resource("clk30", 0, Pins("B12", dir="i"),
20+
Clock(30e6), Attrs(IO_TYPE="LVCMOS33")),
21+
22+
# LED Anodes
23+
*LEDResources(pins="C13 D12 U2 T3 D13 E13 C16", attrs=Attrs(IO_STANDARD="LVCMOS33")),
24+
25+
# LED Cathodes. Use invert to default as on to allow LEDs to be used in white with single bit IO
26+
RGBLEDResource(0, r="T1", g="R1", b="U1", invert=True, attrs=Attrs(IO_TYPE="LVCMOS33")),
27+
28+
*ButtonResources(
29+
pins={0: "U16", 1: "T17" }, invert=True,
30+
attrs=Attrs(IO_TYPE="SSTL135_I")),
31+
32+
*SPIFlashResources(0,
33+
cs_n="R2", clk="U3", cipo="V2", copi="W2", wp_n="Y2", hold_n="W1",
34+
attrs=Attrs(IO_TYPE="LVCMOS33", SLEWRATE="FAST"),
35+
),
36+
37+
*SDCardResources("sdcard", 0,
38+
clk="B13", cmd="A13", dat0="C12", dat1="A12", dat2="D14", dat3="A14",
39+
attrs=Attrs(IO_TYPE="LVCMOS33", SLEWRATE="FAST"),
40+
),
41+
42+
Resource("ddr3", 0,
43+
Subsignal("rst", PinsN("E17", dir="o")),
44+
Subsignal("clk", DiffPairs("C20", "J19", dir="o"), Attrs(IO_TYPE="SSTL135D_I")),
45+
Subsignal("clk_en", Pins("F18 J18", dir="o")),
46+
Subsignal("cs", PinsN("J20 J16", dir="o")),
47+
Subsignal("we", PinsN("G19", dir="o")),
48+
Subsignal("ras", PinsN("K18", dir="o")),
49+
Subsignal("cas", PinsN("J17", dir="o")),
50+
Subsignal("a", Pins("G16 E19 E20 F16 F19 E16 F17 L20 M20 E18 G18 D18 H18 C18 D17 G20", dir="o")),
51+
Subsignal("ba", Pins("H16 F20 H20", dir="o")),
52+
Subsignal("dqs", DiffPairs("T19 N16", "R18 M17", dir="io"),
53+
Attrs(IO_TYPE="SSTL135D_I", TERMINATION="OFF",
54+
DIFFRESISTOR="100")),
55+
Subsignal("dq", Pins("U19 T18 U18 R20 P18 P19 P20 N20 L19 L17 L16 R16 N18 R17 N17 P17",
56+
dir="io"), Attrs(TERMINATION="75")),
57+
Subsignal("dm", Pins("U20 L18", dir="o")),
58+
Subsignal("odt", Pins("K20 H17", dir="o")),
59+
Attrs(IO_TYPE="SSTL135_I", SLEWRATE="FAST")
60+
),
61+
62+
Resource("eth_rgmii", 0,
63+
Subsignal("rst", PinsN("B20", dir="o")),
64+
Subsignal("mdc", Pins("A19", dir="o")),
65+
Subsignal("mdio", Pins("D16", dir="io")),
66+
Subsignal("tx_clk", Pins("E15", dir="o")),
67+
Subsignal("tx_ctl", Pins("D15", dir="o")),
68+
Subsignal("tx_data", Pins("C15 B16 A18 B19", dir="o")),
69+
Subsignal("rx_clk", Pins("D11", dir="i")),
70+
Subsignal("rx_ctl", Pins("B18", dir="i")),
71+
Subsignal("rx_data", Pins("A16 C17 B17 A17", dir="i")),
72+
Attrs(IO_TYPE="LVCMOS33", SLEWRATE="FAST")
73+
),
74+
75+
ULPIResource(0, data="B9 C6 A7 E9 A8 D9 C10 C7",
76+
rst="C9", clk="B6", dir="A6", stp="C8", nxt="B8",
77+
clk_dir="i", rst_invert=True, attrs=Attrs(IOSTANDARD="LVCMOS18")),
78+
79+
I2CResource(0, scl="E14", sda="C14",
80+
attrs=Attrs(IOSTANDARD="LVCMOS33")),
81+
82+
# SYGYZY VIO level control pwm pins (use with care)
83+
Resource("pdm", 0, Pins("V1", dir="o"), Attrs(IO_TYPE="LVCMOS33")),
84+
Resource("pdm", 1, Pins("E11", dir="o"), Attrs(IO_TYPE="LVCMOS33")),
85+
Resource("pdm", 2, Pins("T2", dir="o"), Attrs(IO_TYPE="LVCMOS33")),
86+
87+
# Used to reload FPGA configuration (drives program_n)
88+
Resource("program", 0, PinsN("R3", dir="o"), Attrs(IO_TYPE="LVCMOS33")),
89+
]
90+
connectors = [
91+
Connector("syzygy", 0, {
92+
# single ended
93+
"S0":"G2", "S1":"J3",
94+
"S2":"F1", "S3":"K3",
95+
"S4":"J4", "S5":"K2",
96+
"S6":"J5", "S7":"J1",
97+
"S8":"N2", "S9":"L3",
98+
"S10":"M1", "S11":"L2",
99+
"S12":"N3", "S13":"N4",
100+
"S14":"M3", "S15":"P5",
101+
"S16":"H1", "S17":"K5",
102+
"S18":"K4", "S19":"K1",
103+
"S20":"L4", "S21":"L1",
104+
"S22":"L5", "S23":"M4",
105+
"S24":"N1", "S25":"N5",
106+
"S26":"P3", "S27":"P4",
107+
"S28":"H2", "S29":"P1",
108+
"S30":"G1", "S31":"P2",
109+
# diff pairs
110+
111+
}),
112+
Connector("syzygy", 1, {
113+
# single ended
114+
115+
# diff pairs
116+
"D0P":"E4", "D0N":"D5",
117+
"D1P":"A4", "D1N":"A5",
118+
"D2P":"C4", "D2N":"B4",
119+
"D3P":"B2", "D3N":"C2",
120+
"D4P":"A2", "D4N":"B1",
121+
"D5P":"C1", "D5N":"D1",
122+
"D6P":"F4", "D6N":"E3",
123+
"D7P":"D2", "D7N":"E1",
124+
}),
125+
]
126+
127+
@property
128+
def required_tools(self):
129+
return super().required_tools + [
130+
"dfu-suffix"
131+
]
132+
133+
@property
134+
def command_templates(self):
135+
return super().command_templates + [
136+
r"""
137+
{{invoke_tool("dfu-suffix")}}
138+
-v 1209 -p 5af0 -a {{name}}.bit
139+
"""
140+
]
141+
142+
def toolchain_prepare(self, fragment, name, **kwargs):
143+
overrides = dict(ecppack_opts="--compress --freq 38.8")
144+
overrides.update(kwargs)
145+
return super().toolchain_prepare(fragment, name, **overrides)
146+
147+
def toolchain_program(self, products, name):
148+
dfu_util = os.environ.get("DFU_UTIL", "dfu-util")
149+
with products.extract("{}.bit".format(name)) as bitstream_filename:
150+
subprocess.check_call([dfu_util, "-D", bitstream_filename])
151+
152+
153+
if __name__ == "__main__":
154+
from .test.blinky import *
155+
ButterStickPlatform().build(Blinky(), do_program=True)

0 commit comments

Comments
 (0)