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:
David Anderson 2024-09-14 16:40:14 -07:00
parent 227526c2b1
commit e021e7d356
1 changed files with 26 additions and 0 deletions

26
blinky/Blinky.bsv Normal file
View File

@ -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