Skip to content

Commit 4c493bb

Browse files
committed
Initial commit
0 parents  commit 4c493bb

File tree

6 files changed

+317
-0
lines changed

6 files changed

+317
-0
lines changed

.env.toolchain

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
AMARANTH_USE_YOSYS=builtin
2+
YOSYS=yowasp-yosys
3+
NEXTPNR_ICE40=yowasp-nextpnr-ice40
4+
ICEPACK=yowasp-icepack
5+
NEXTPNR_ECP5=yowasp-nextpnr-ecp5
6+
ECPPACK=yowasp-ecppack

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Python
2+
__pycache__/
3+
*.egg-info
4+
/dist
5+
6+
# pdm
7+
/.pdm-plugins
8+
/.pdm-python
9+
/.venv
10+
11+
# Amaranth
12+
/build*

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# amaranth-template-fpga
2+
3+
TODO: write this section
4+
5+
```shell
6+
$ pipx install pdm
7+
$ pdm install
8+
$ pdm run build_ice40
9+
$ pdm run build_ecp5
10+
```

pdm.lock

+243
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[project]
2+
name = "amaranth-template-fpga"
3+
version = "0.0.0"
4+
description = "Template for a generic FPGA project using Amaranth"
5+
6+
requires-python = "~=3.8"
7+
dependencies = [
8+
"amaranth @ git+https://github.com/amaranth-lang/amaranth",
9+
"amaranth-yosys",
10+
"amaranth-boards @ git+https://github.com/amaranth-lang/amaranth-boards",
11+
"yowasp-yosys",
12+
"yowasp-nextpnr-ice40",
13+
"yowasp-nextpnr-ecp5",
14+
]
15+
16+
[tool.pdm.scripts]
17+
_.env_file = ".env.toolchain"
18+
build_ice40 = {call = "amaranth_template_fpga:build_ice40()"}
19+
build_ecp5 = {call = "amaranth_template_fpga:build_ecp5()"}

src/amaranth_template_fpga.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from amaranth import *
2+
from amaranth_boards.icestick import ICEStickPlatform
3+
from amaranth_boards.versa_ecp5 import VersaECP5Platform
4+
5+
6+
class Blinky(Elaboratable):
7+
def elaborate(self, platform):
8+
m = Module()
9+
10+
led = platform.request("led", 0).o
11+
timer = Signal(range(int(platform.default_clk_frequency//2)),
12+
reset=int(platform.default_clk_frequency//2) - 1)
13+
with m.If(timer == 0):
14+
m.d.sync += led.eq(~led)
15+
m.d.sync += timer.eq(timer.reset)
16+
with m.Else():
17+
m.d.sync += timer.eq(timer - 1)
18+
19+
return m
20+
21+
22+
def build_ice40():
23+
ICEStickPlatform().build(Blinky())
24+
25+
26+
def build_ecp5():
27+
VersaECP5Platform().build(Blinky())

0 commit comments

Comments
 (0)