-
Notifications
You must be signed in to change notification settings - Fork 4
/
top.py
29 lines (21 loc) · 724 Bytes
/
top.py
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
from amaranth import *
from amaranth.lib import wiring
from amaranth.lib.wiring import In, Out
class Blinky(wiring.Component):
led: Out(1)
def __init__(self, frequency):
self.frequency = frequency
super().__init__()
def elaborate(self, platform):
m = Module()
count = Signal(range(self.frequency // 2))
with m.If(count == self.frequency // 2 - 1):
m.d.sync += self.led.eq(~self.led)
m.d.sync += count.eq(0)
with m.Else():
m.d.sync += count.eq(count + 1)
return m
if __name__ == '__main__':
from amaranth.back import rtlil
with open('top.il', 'w') as f:
f.write(rtlil.convert(Blinky(25_000_000)))