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! =>
|
2020-08-15 02:08:36 +02:00
|
|
|
Sync$ @out :== 0
|
2020-08-09 21:55:44 +02:00
|
|
|
|
|
|
|
counter = Signal$ range (@ncycles + 1)
|
2020-08-15 02:08:36 +02:00
|
|
|
Sync$ counter :== counter - 1
|
2020-08-09 21:55:44 +02:00
|
|
|
|
|
|
|
When (counter == 0) $ ->
|
2020-08-15 02:08:36 +02:00
|
|
|
Sync$ @out :== HIGH
|
|
|
|
Sync$ counter :== @ncycles
|
2020-08-09 21:55:44 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__" =>
|
|
|
|
pulser = Pulser ncycles: 10000000
|
|
|
|
main pulser name: "pulser" ports: [pulser.out]
|