summaryrefslogtreecommitdiff
path: root/blinky.py
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2025-08-29 19:45:19 +0200
committerYuval Adam <_@yuv.al>2025-08-29 19:45:19 +0200
commitdb54a0f41681cf5af4a98bbe9ceb0e25bc992562 (patch)
treebfe793196463abd417767e40bb1fb11554787090 /blinky.py
parent678a59565f6d7e5435c1c09c10e636ee5795c0db (diff)
Initial project files
Diffstat (limited to 'blinky.py')
-rw-r--r--blinky.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/blinky.py b/blinky.py
new file mode 100644
index 0000000..424bf5f
--- /dev/null
+++ b/blinky.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+
+from amaranth import *
+from amaranth.build import Platform
+from platform_alchitry_pt import AlchitryPtPlatform
+
+
+class Blinky(Elaboratable):
+ def elaborate(self, platform: Platform) -> Module:
+ m = Module()
+
+ # Get the LED pins
+ led = platform.request("led", 0)
+
+ # Create a counter for timing
+ counter = Signal(24)
+
+ # Increment counter every clock cycle
+ m.d.sync += counter.eq(counter + 1)
+
+ # Connect the MSB of counter to LED (blinks at ~12Hz at 100MHz)
+ m.d.comb += led.o.eq(counter[-1])
+
+ return m
+
+
+if __name__ == "__main__":
+ platform = AlchitryPtPlatform()
+ platform.build(Blinky(), do_program=True) \ No newline at end of file