split blinker into blinker and pulser
This commit is contained in:
parent
269d05bfe2
commit
c68ec0f876
|
@ -1,7 +1,7 @@
|
||||||
import "/nmigen_boards.icebreaker/ICEBreakerPlatform"
|
import "/nmigen_boards.icebreaker/ICEBreakerPlatform"
|
||||||
import "/nmigen_dg/*"
|
import "/nmigen_dg/*"
|
||||||
import "modules/blinker/Blinker"
|
import "modules/blinker/Blinker"
|
||||||
import "modules/blinker/Pulser"
|
import "modules/pulser/Pulser"
|
||||||
import "resources/pmod"
|
import "resources/pmod"
|
||||||
|
|
||||||
Top = subclass Elaboratable where
|
Top = subclass Elaboratable where
|
||||||
|
|
|
@ -2,28 +2,18 @@ import "/nmigen/cli/main"
|
||||||
import "/nmigen_dg/*"
|
import "/nmigen_dg/*"
|
||||||
|
|
||||||
Blinker = subclass Elaboratable where
|
Blinker = subclass Elaboratable where
|
||||||
__init__ = ncycles pulse: False ~> None where
|
__init__ = ncycles ~> None where
|
||||||
@ncycles = ncycles
|
@ncycles = ncycles
|
||||||
@pulse = pulse
|
|
||||||
@out = Signal!
|
@out = Signal!
|
||||||
|
|
||||||
elaborate = platform ~> m where with m = Module! =>
|
elaborate = platform ~> m where with m = Module! =>
|
||||||
counter = Signal$ range (@ncycles + 1)
|
counter = Signal$ range (@ncycles + 1)
|
||||||
|
Sync$ Drive counter (counter - 1)
|
||||||
|
|
||||||
if @pulse =>
|
When (counter == 0) $ ->
|
||||||
sync$ drive @out LOW
|
Sync$ Drive @out (~ @out)
|
||||||
|
Sync$ Drive counter @ncycles
|
||||||
when
|
|
||||||
counter == 0 ,->
|
|
||||||
sync$ drive @out (~ @out)
|
|
||||||
sync$ drive counter @ncycles
|
|
||||||
otherwise ,->
|
|
||||||
sync$ drive counter (counter - 1)
|
|
||||||
|
|
||||||
|
|
||||||
Pulser = bind Blinker pulse: True
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__" =>
|
if __name__ == "__main__" =>
|
||||||
blinker = Blinker ncycles: 10000000
|
blinker = Blinker ncycles: 10000000
|
||||||
main blinker ports: [blinker.out]
|
main blinker name: "blinker" ports: [blinker.out]
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
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]
|
Loading…
Reference in New Issue