gary/blinky/Blinky.bsv

27 lines
573 B
Plaintext
Raw Normal View History

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