summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--platform_alchitry_pt.py135
-rw-r--r--pyproject.toml2
-rw-r--r--uv.lock57
4 files changed, 125 insertions, 74 deletions
diff --git a/.gitignore b/.gitignore
index 0cafc1c..ae4e658 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
-.venv/ \ No newline at end of file
+.venv/
+build/
+
+__pycache__ \ No newline at end of file
diff --git a/platform_alchitry_pt.py b/platform_alchitry_pt.py
index 9964ecc..8a2c895 100644
--- a/platform_alchitry_pt.py
+++ b/platform_alchitry_pt.py
@@ -12,86 +12,71 @@ class AlchitryPtPlatform(XilinxPlatform):
default_clk = "clk100"
resources = [
- Resource("clk100", 0, Pins("N14", dir="i"),
+ # 100MHz clock - using official pin from Alchitry Labs
+ Resource("clk100", 0, Pins("W19", dir="i"),
Clock(100e6), Attrs(IOSTANDARD="LVCMOS33")),
- # LEDs
- Resource("led", 0, Pins("K13", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("led", 1, Pins("K16", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("led", 2, Pins("L15", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("led", 3, Pins("L14", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("led", 4, Pins("M16", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("led", 5, Pins("M14", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("led", 6, Pins("M12", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("led", 7, Pins("N16", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
+ # LEDs - official pins from Alchitry Labs
+ Resource("led", 0, Pins("P19", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
+ Resource("led", 1, Pins("P20", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
+ Resource("led", 2, Pins("T21", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
+ Resource("led", 3, Pins("R19", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
+ Resource("led", 4, Pins("V22", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
+ Resource("led", 5, Pins("U21", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
+ Resource("led", 6, Pins("T20", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
+ Resource("led", 7, Pins("W20", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
- # Reset button
- Resource("rst_n", 0, Pins("P6", dir="i"), Attrs(IOSTANDARD="LVCMOS33")),
+ # Reset button - official pin from Alchitry Labs
+ Resource("rst_n", 0, Pins("N15", dir="i"), Attrs(IOSTANDARD="LVCMOS33")),
- # IO pins
- Resource("io", 0, Pins("A1", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 1, Pins("A2", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 2, Pins("A3", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 3, Pins("A4", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 4, Pins("A5", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 5, Pins("A7", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 6, Pins("A8", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 7, Pins("A9", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 8, Pins("A10", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 9, Pins("A11", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 10, Pins("A13", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 11, Pins("A14", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 12, Pins("A15", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 13, Pins("A16", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 14, Pins("A17", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 15, Pins("A18", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 16, Pins("B1", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 17, Pins("B2", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 18, Pins("B4", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 19, Pins("B5", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 20, Pins("B6", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 21, Pins("B7", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 22, Pins("B8", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 23, Pins("B10", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 24, Pins("B11", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 25, Pins("B12", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 26, Pins("B14", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 27, Pins("B15", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 28, Pins("B16", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 29, Pins("B17", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 30, Pins("B18", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 31, Pins("C1", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 32, Pins("C2", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 33, Pins("C4", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 34, Pins("C5", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 35, Pins("C6", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 36, Pins("C7", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 37, Pins("C8", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 38, Pins("C9", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 39, Pins("C10", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 40, Pins("C11", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 41, Pins("C13", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 42, Pins("C14", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 43, Pins("C16", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 44, Pins("C17", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 45, Pins("C18", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 46, Pins("D3", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
- Resource("io", 47, Pins("D4", dir="io"), Attrs(IOSTANDARD="LVCMOS33")),
+ # A-Bank IO pins - official pins from Alchitry Labs (subset for convenience)
+ Resource("io", 0, Pins("AB22", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A3
+ Resource("io", 1, Pins("AB21", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A5
+ Resource("io", 2, Pins("E3", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A9
+ Resource("io", 3, Pins("F3", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A11
+ Resource("io", 4, Pins("M2", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A15
+ Resource("io", 5, Pins("M3", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A17
+ Resource("io", 6, Pins("J6", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A21
+ Resource("io", 7, Pins("K6", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A23
+ Resource("io", 8, Pins("AB18", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A4
+ Resource("io", 9, Pins("AA18", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A6
+ Resource("io", 10, Pins("N2", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A10
+ Resource("io", 11, Pins("P2", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A12
+ Resource("io", 12, Pins("L1", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A16
+ Resource("io", 13, Pins("M1", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A18
+ Resource("io", 14, Pins("D2", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A22
+ Resource("io", 15, Pins("E2", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # A24
+
+ # B-Bank IO pins - official pins from Alchitry Labs (subset)
+ Resource("io", 16, Pins("AB13", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # B3
+ Resource("io", 17, Pins("AA13", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # B5
+ Resource("io", 18, Pins("AB12", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # B9
+ Resource("io", 19, Pins("AB11", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # B11
+ Resource("io", 20, Pins("AA11", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # B4
+ Resource("io", 21, Pins("AA10", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # B6
+ Resource("io", 22, Pins("Y14", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # B10
+ Resource("io", 23, Pins("W14", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # B12
+
+ # C-Bank IO pins - official pins from Alchitry Labs
+ Resource("io", 24, Pins("U18", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # C29
+ Resource("io", 25, Pins("U17", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # C31
+ Resource("io", 26, Pins("V2", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # C33
+ Resource("io", 27, Pins("U2", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # C35
+ Resource("io", 28, Pins("Y1", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # C30
+ Resource("io", 29, Pins("W1", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # C32
+ Resource("io", 30, Pins("R14", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # C34
+ Resource("io", 31, Pins("P14", dir="io"), Attrs(IOSTANDARD="LVCMOS33")), # C36
]
connectors = []
def toolchain_program(self, products, name, **kwargs):
- vivado = self.toolchain.sh_command("vivado")
+ import subprocess
+ import os
+
with products.extract("{}.bit".format(name)) as bitstream_filename:
- self.toolchain.run([
- vivado, "-mode", "batch", "-source", self._create_tcl_script(bitstream_filename)
- ], root="build")
-
- def _create_tcl_script(self, bitstream_filename):
- tcl_script = "program_fpga.tcl"
- with open(tcl_script, "w") as f:
- f.write(f"""
+ # Create TCL script for programming
+ tcl_content = f"""
open_hw_manager
connect_hw_server
open_hw_target
@@ -102,5 +87,11 @@ current_hw_device [get_hw_devices xc7a100t_0]
program_hw_devices [get_hw_devices xc7a100t_0]
close_hw_manager
exit
-""")
- return tcl_script \ No newline at end of file
+"""
+ tcl_script = os.path.join("build", "program_fpga.tcl")
+ with open(tcl_script, "w") as f:
+ f.write(tcl_content)
+
+ # Run vivado to program the FPGA
+ subprocess.run(["vivado", "-mode", "batch", "-source", tcl_script],
+ cwd="build", check=True) \ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index 474a726..2044136 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -6,4 +6,6 @@ readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"amaranth>=0.5.7",
+ "amaranth-boards>=0",
+ "amaranth-yosys>=0.50.0.0.post115",
]
diff --git a/uv.lock b/uv.lock
index 8446418..88f8a34 100644
--- a/uv.lock
+++ b/uv.lock
@@ -17,15 +17,49 @@ wheels = [
]
[[package]]
+name = "amaranth-boards"
+version = "0"
+source = { registry = "https://pypi.org/simple" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/fb/51/876b5888928300504cb7112d7aa113346b62966506caa6126cdf6dae2893/amaranth_boards-0-py3-none-any.whl", hash = "sha256:0cc6af682122197b532eef7c2d378a59905ac5e63ec5c69b9147b1e05bf2c600", size = 1073, upload-time = "2021-12-10T05:08:27.275Z" },
+]
+
+[[package]]
+name = "amaranth-yosys"
+version = "0.50.0.0.post115"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "wasmtime" },
+]
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/1e/58/ac549b1d8d25205a21d008886fe04cd8d475426b120b8660b25f996d65c7/amaranth_yosys-0.50.0.0.post115-py3-none-any.whl", hash = "sha256:a37253df4c1b782dc981430e38f796165b58de13e158e21160ae043105d38ba0", size = 11064311, upload-time = "2025-08-21T01:59:25.142Z" },
+]
+
+[[package]]
name = "hello-alchitry-pt-v2"
version = "0.1.0"
source = { virtual = "." }
dependencies = [
{ name = "amaranth" },
+ { name = "amaranth-boards" },
+ { name = "amaranth-yosys" },
]
[package.metadata]
-requires-dist = [{ name = "amaranth", specifier = ">=0.5.7" }]
+requires-dist = [
+ { name = "amaranth", specifier = ">=0.5.7" },
+ { name = "amaranth-boards", specifier = ">=0" },
+ { name = "amaranth-yosys", specifier = ">=0.50.0.0.post115" },
+]
+
+[[package]]
+name = "importlib-resources"
+version = "6.5.2"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/cf/8c/f834fbf984f691b4f7ff60f50b514cc3de5cc08abfc3295564dd89c5e2e7/importlib_resources-6.5.2.tar.gz", hash = "sha256:185f87adef5bcc288449d98fb4fba07cea78bc036455dd44c5fc4a2fe78fed2c", size = 44693, upload-time = "2025-01-03T18:51:56.698Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/a4/ed/1f1afb2e9e7f38a545d628f864d562a5ae64fe6f7a10e28ffb9b185b4e89/importlib_resources-6.5.2-py3-none-any.whl", hash = "sha256:789cfdc3ed28c78b67a06acb8126751ced69a3d5f79c095a98298cd8a760ccec", size = 37461, upload-time = "2025-01-03T18:51:54.306Z" },
+]
[[package]]
name = "jinja2"
@@ -96,3 +130,24 @@ sdist = { url = "https://files.pythonhosted.org/packages/85/40/1520d68bfa07ab5a6
wheels = [
{ url = "https://files.pythonhosted.org/packages/ff/9a/9afaade874b2fa6c752c36f1548f718b5b83af81ed9b76628329dab81c1b/rfc3986-2.0.0-py2.py3-none-any.whl", hash = "sha256:50b1502b60e289cb37883f3dfd34532b8873c7de9f49bb546641ce9cbd256ebd", size = 31326, upload-time = "2022-01-10T00:52:29.594Z" },
]
+
+[[package]]
+name = "wasmtime"
+version = "36.0.0"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "importlib-resources" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/6b/68/231035f96ba0798c0088b1ab0aa59403f5ec6b2fde2cbd5930d95acad7ff/wasmtime-36.0.0.tar.gz", hash = "sha256:e0523be4b2ebb1344a387fb4ce054a62acbcbc19671a7e7eeb166355d2f3004c", size = 147386, upload-time = "2025-08-20T17:33:11.103Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/7a/3b/33fccbb066bcc84f195d0f6c6b4e038f4df8bf9596d24478fa143a7e4f27/wasmtime-36.0.0-py3-none-android_26_arm64_v8a.whl", hash = "sha256:eab97e2a54fcfd074dcbddf38d7397a0411914802e072f4fd30ed41c2a5604fe", size = 8649185, upload-time = "2025-08-20T17:32:51.925Z" },
+ { url = "https://files.pythonhosted.org/packages/12/a9/60bdd9fe50daba4562b4d11e8cd156e7774ccc69fc87f1cd47ec3bd5aca3/wasmtime-36.0.0-py3-none-android_26_x86_64.whl", hash = "sha256:72c2186c11b255ea8c6874320973712eceb384f5d68594de4348e2a169437af0", size = 9366812, upload-time = "2025-08-20T17:32:53.903Z" },
+ { url = "https://files.pythonhosted.org/packages/a4/85/5654a332a7f51108a672898414c2009cf362b268b514bae02b3f106c02b2/wasmtime-36.0.0-py3-none-any.whl", hash = "sha256:d1e41c3f832752982aced040168b4cea1144c39a5ed43882791b2e2975145ee3", size = 7588263, upload-time = "2025-08-20T17:32:55.935Z" },
+ { url = "https://files.pythonhosted.org/packages/9f/65/abf6a435bba624b005d5d6ea3fb9285be662aa3ac7a80f97aeb29b1e1d60/wasmtime-36.0.0-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:a8ff3bf20f84f3f092ef7bf216afa2706e496ef3e190fb90b88b13b9529ed035", size = 9006605, upload-time = "2025-08-20T17:32:57.658Z" },
+ { url = "https://files.pythonhosted.org/packages/b4/52/297b9982b135e43ef060f899227aa5e0b3798198f17ee1e0f806bd247fcc/wasmtime-36.0.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:6396ca0178ceffb17464e3cf2b4beae0e0b1da5c95aa5d27ff094f2a7f41106e", size = 7881396, upload-time = "2025-08-20T17:32:59.857Z" },
+ { url = "https://files.pythonhosted.org/packages/b1/63/cc69b41d6db6522adfc79627e7b9ad83d44797d525aae2a53f62d47d6e3e/wasmtime-36.0.0-py3-none-manylinux1_x86_64.whl", hash = "sha256:bca67a384a64a5d9164ebc48c106862881a6d2af67d0740ed29cc50847cbe6f5", size = 9691244, upload-time = "2025-08-20T17:33:01.364Z" },
+ { url = "https://files.pythonhosted.org/packages/9b/fa/d8a27f073757bd2261455017c9c28f1d7343468931048f35c3f23a4f1b83/wasmtime-36.0.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:cd6f69bb744096b9bcca17863c463a96d08af86db1ccc0d74206a33892fac887", size = 8666149, upload-time = "2025-08-20T17:33:03.553Z" },
+ { url = "https://files.pythonhosted.org/packages/9d/49/70f70d13dedc783b5894ab1f11bd696f0f1c0e8faabc6ae422ce5eb91a67/wasmtime-36.0.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:5ea87199a35616848e20060f3cc00c22d4b2a919fd72bdea4c62b6503ac2bccc", size = 9689298, upload-time = "2025-08-20T17:33:05.642Z" },
+ { url = "https://files.pythonhosted.org/packages/ba/7d/0b45d172feba7488e67bf85f8f4254dd8c1dc99d6c1a3b9aa410f7a2d907/wasmtime-36.0.0-py3-none-win_amd64.whl", hash = "sha256:1e826960c02cbcf74cb91de41b63ff55ad6c9260e684fd4c315736b607642934", size = 7588270, upload-time = "2025-08-20T17:33:07.858Z" },
+ { url = "https://files.pythonhosted.org/packages/cf/d5/6b59a7f194940e6cdece2516e46f919c006e639a85854dd548799e3d884f/wasmtime-36.0.0-py3-none-win_arm64.whl", hash = "sha256:de932f23d257917652358093226315aeed21a262fdc124fff3486d5dfa62b40b", size = 6604726, upload-time = "2025-08-20T17:33:09.642Z" },
+]