nmigen-learning/fpga/modules/pulser.dg

22 lines
577 B
Plaintext
Raw Normal View History

2020-08-09 21:55:44 +02:00
import "/nmigen/cli/main"
import "/nmigen_dg/*"
Pulser = subclass Elaboratable where
__init__ = ncycles ~> None where
@ncycles = ncycles
@out = Signal!
elaborate = platform ~> m where with m = Module! =>
Sync$ Drive @out LOW
counter = Signal$ range (@ncycles + 1)
Sync$ Drive counter (counter - 1)
When (counter == 0) $ ->
Sync$ Drive @out HIGH
Sync$ Drive counter @ncycles
if __name__ == "__main__" =>
pulser = Pulser ncycles: 10000000
main pulser name: "pulser" ports: [pulser.out]