nmigen-learning/fpga/modules/blinker.dg

20 lines
550 B
Plaintext
Raw Permalink 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-17 00:34:12 +02:00
Sync$ counter ::= counter - 1
2020-08-09 21:55:44 +02:00
When (counter == 0) $ ->
2020-08-17 00:34:12 +02:00
Sync$ @out ::= ~ @out
Sync$ counter ::= @ncycles
if __name__ == "__main__" =>
blinker = Blinker ncycles: 10000000
2020-08-09 21:55:44 +02:00
main blinker name: "blinker" ports: [blinker.out]