2020-08-06 23:33:19 +02:00
|
|
|
import "/nmigen/cli/main"
|
|
|
|
import "/nmigen_dg/*"
|
|
|
|
|
|
|
|
Blinker = subclass Elaboratable where
|
2020-08-09 21:55:44 +02:00
|
|
|
__init__ = ncycles ~> None where
|
2020-08-06 23:33:19 +02:00
|
|
|
@ncycles = ncycles
|
|
|
|
@out = Signal!
|
|
|
|
|
|
|
|
elaborate = platform ~> m where with m = Module! =>
|
|
|
|
counter = Signal$ range (@ncycles + 1)
|
2020-08-15 02:08:36 +02:00
|
|
|
Sync$ counter :== counter - 1
|
2020-08-06 23:33:19 +02:00
|
|
|
|
2020-08-09 21:55:44 +02:00
|
|
|
When (counter == 0) $ ->
|
2020-08-15 02:08:36 +02:00
|
|
|
Sync$ @out :== ~ @out
|
|
|
|
Sync$ counter :== @ncycles
|
2020-08-06 23:33:19 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__" =>
|
|
|
|
blinker = Blinker ncycles: 10000000
|
2020-08-09 21:55:44 +02:00
|
|
|
main blinker name: "blinker" ports: [blinker.out]
|