BitFlow

Breathing LED

PWM sets brightness; changing the PWM's duty slowly makes the light breathe. Run a 6-bit PWM (64 levels) on LED 0, and step its level up one notch at a time to full, then back down to off, so a whole breath takes 2 seconds.

That is 128 steps in 2 s, one every CLK_HZ / 64 cycles, with a flag that says whether you are going up or down.

lab.v
drag to turn · scroll to zoom

Loading the board…

Press Run on the board: your Verilog is turned into gates in this browser and runs here, cycle by cycle.

Goals

  • ○LED 0 fades from off to full brightness and back
  • ○One breath takes about 2 s
Hints
  1. phase counts 0–63 every cycle; LED 0 is on while phase < level.
  2. Every CLK_HZ / 64 cycles, move level one step in its direction, and turn round at 63 and at 0.

Pin log

Run the design to see its outputs change.

Put it on a real board

  • The clock is set to the board's 27 MHz, and its active-low buttons and LEDs are flipped for you.
Waveform