From e021e7d356a67e131a90dedc70da11f159fa844e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 14 Sep 2024 16:40:14 -0700 Subject: [PATCH] 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. --- blinky/Blinky.bsv | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 blinky/Blinky.bsv 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