BitFlow

Serial-controlled LEDs

Now the board takes orders. A byte is just a number: the character '3' arrives as 51, so subtract "0" (48) to get the digit.

Each time a digit 0–5 arrives, flip that LED. Ignore anything else, so a newline or a letter does nothing. The receiver is done for you.

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

  • ○A digit 0–5 switches its LED
  • ○The same digit again switches it back
  • ○Other characters are ignored
Hints
  1. if (got && byte_in >= "0" && byte_in <= "5") leds[byte_in - "0"] <= ~leds[byte_in - "0"];
  2. Keep the LEDs in a reg [5:0] and assign it to led.

Pin log

Run the design to see its outputs change.

Serial terminal (type to send on rx)

 

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.

Check on my board

Flash this lesson, then connect at 115200 baud. Your browser asks which port: on a Tang Nano, try the higher-numbered one if nothing comes back.

Waveform