2020-08-06 23:33:19 +02:00
|
|
|
import "/nmigen_boards.icebreaker/ICEBreakerPlatform"
|
|
|
|
import "/nmigen_dg/*"
|
2020-08-08 02:26:03 +02:00
|
|
|
import "modules/blinker/Blinker"
|
2020-08-09 21:55:44 +02:00
|
|
|
import "modules/pulser/Pulser"
|
2020-08-09 22:54:51 +02:00
|
|
|
import "modules/segment7/Segment7x2"
|
2020-08-07 00:22:39 +02:00
|
|
|
import "resources/pmod"
|
2020-08-06 23:33:19 +02:00
|
|
|
|
|
|
|
Top = subclass Elaboratable where
|
|
|
|
elaborate = platform ~> m where with m = Module! =>
|
|
|
|
freq = int platform.default_clk_frequency
|
|
|
|
|
|
|
|
@ledr = platform.request "led_r"
|
|
|
|
@ledg = platform.request "led_g"
|
2020-08-07 00:22:39 +02:00
|
|
|
@seg7 = platform.request "seven_seg"
|
2020-08-06 23:33:19 +02:00
|
|
|
|
2020-08-09 21:57:26 +02:00
|
|
|
blinker = (Submodule$ Blinker$ freq // 3 ).out
|
|
|
|
pulser = (Submodule$ Pulser$ freq // 10).out
|
2020-08-09 22:54:51 +02:00
|
|
|
seg7 = Submodule$ Segment7x2 decimal: True
|
2020-08-06 23:33:19 +02:00
|
|
|
|
2020-08-09 21:57:26 +02:00
|
|
|
Comb$ Drive @ledr blinker
|
|
|
|
|
|
|
|
ff = Signal 1 reset: 1
|
|
|
|
When pulser $ ->
|
|
|
|
Sync$ Drive ff ~ff
|
|
|
|
|
|
|
|
Comb$ Drive @ledg ff
|
|
|
|
|
|
|
|
counter = Signal 8
|
|
|
|
When pulser $ ->
|
|
|
|
Sync$ Drive counter (counter + 1)
|
2020-08-06 23:33:19 +02:00
|
|
|
|
2020-08-09 22:54:51 +02:00
|
|
|
Comb$ Drive seg7.number counter
|
|
|
|
Comb$ Drive @seg7 (Cat seg7.segs seg7.select)
|
2020-08-06 23:33:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__" =>
|
|
|
|
plat = ICEBreakerPlatform!
|
2020-08-08 02:27:31 +02:00
|
|
|
plat.add_resources$ pmod.seven_seg pmod: 0 # pmod 1a
|
|
|
|
plat.add_resources$ pmod.dip_switch8 pmod: 1 # pmod 1b
|
2020-08-06 23:33:19 +02:00
|
|
|
plat.build Top! do_program: True
|