22 lines
577 B
Plaintext
22 lines
577 B
Plaintext
|
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]
|