diff --git a/blinky/Blinky.bsv b/blinky/Blinky.bsv new file mode 100644 index 0000000..f3d3615 --- /dev/null +++ b/blinky/Blinky.bsv @@ -0,0 +1,26 @@ +package Blinky; + +import Strobe::*; + +(* always_ready *) +interface Blinky; + method Bool led_on(); +endinterface + +// mkBlinky returns a module that toggles its output approximately +// once a second. It's intended to be wired to an LED as a basic "are +// you alive" indicator. +module mkBlinky(Integer clock_frequency, Blinky ifc); + let strobe <- mkStrobe(clock_frequency, 1); + + Reg#(Bool) out <- mkReg(False); + + (* no_implicit_conditions,fire_when_enabled *) + rule increment (strobe); + out <= !out; + endrule + + method led_on = out._read; +endmodule + +endpackage