blinky/Blinky: a module that blinks a LED every second
Handy as a basic liveness test when you push stuff to an FPGA and nothing happens.
This commit is contained in:
parent
227526c2b1
commit
e021e7d356
|
@ -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
|
Loading…
Reference in New Issue