nmigen-learning/fpga/modules/blinker.dg

20 lines
557 B
Plaintext
Raw Normal View History

import "/nmigen/cli/main"
import "/nmigen_dg/*"
Blinker = subclass Elaboratable where
2020-08-09 21:55:44 +02:00
__init__ = ncycles ~> None where
@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-09 21:55:44 +02:00
When (counter == 0) $ ->
Sync$ Drive @out (~ @out)
Sync$ Drive counter @ncycles
if __name__ == "__main__" =>
blinker = Blinker ncycles: 10000000
2020-08-09 21:55:44 +02:00
main blinker name: "blinker" ports: [blinker.out]