nmigen-learning/fpga/modules/blinker.dg

20 lines
550 B
Plaintext

import "/nmigen/cli/main"
import "/nmigen_dg/*"
Blinker = subclass Elaboratable where
__init__ = ncycles ~> None where
@ncycles = ncycles
@out = Signal!
elaborate = platform ~> m where with m = Module! =>
counter = Signal$ range (@ncycles + 1)
Sync$ counter :== counter - 1
When (counter == 0) $ ->
Sync$ @out :== ~ @out
Sync$ counter :== @ncycles
if __name__ == "__main__" =>
blinker = Blinker ncycles: 10000000
main blinker name: "blinker" ports: [blinker.out]