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-09 21:55:44 +02:00
|
|
|
Sync$ Drive counter (counter - 1)
|
2020-08-06 23:33:19 +02:00
|
|
|
|
2020-08-09 21:55:44 +02:00
|
|
|
When (counter == 0) $ ->
|
|
|
|
Sync$ Drive @out (~ @out)
|
|
|
|
Sync$ Drive 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]
|