Implement a simple blinker

Reimplemented the icebreaker top in nmigen_dg
This commit is contained in:
2020-08-06 23:33:19 +02:00
parent 0d4b733da6
commit 3dacf1eb90
4 changed files with 59 additions and 28 deletions

2
fpga/modules/__init__.py Normal file
View File

@@ -0,0 +1,2 @@
from .blinker import Blinker
from .blinker import Pulser

29
fpga/modules/blinker.dg Normal file
View File

@@ -0,0 +1,29 @@
import "/nmigen/cli/main"
import "/nmigen_dg/*"
Blinker = subclass Elaboratable where
__init__ = ncycles pulse: False ~> None where
@ncycles = ncycles
@pulse = pulse
@out = Signal!
elaborate = platform ~> m where with m = Module! =>
counter = Signal$ range (@ncycles + 1)
if @pulse =>
sync$ drive @out LOW
when
counter == 0 ,->
sync$ drive @out (~ @out)
sync$ drive counter @ncycles
otherwise ,->
sync$ drive counter (counter - 1)
Pulser = bind Blinker pulse: True
if __name__ == "__main__" =>
blinker = Blinker ncycles: 10000000
main blinker ports: [blinker.out]