BitFlow

Serial echo

Receiving is sending in reverse: wait for the line to drop (the start bit), then read each bit in the middle of its time slot, CLK_HZ / BAUD cycles apart, starting with bit 0. After 8 bits comes the stop bit.

Finish uart_rx so it raises ready for one cycle with the byte in data, then wire it to the uart_tx from the last serial lesson so every byte you type comes back.

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

  • ○Every byte sent comes back
  • ○They come back right, in order (bit 0 first)
  • ○Nothing is sent when nothing arrives
Hints
  1. Wait CLK_HZ / BAUD / 2 cycles after the line drops: then you are in the middle of the start bit, and every CLK_HZ / BAUD after that is the middle of a data bit.
  2. Shift each bit in from the top: data <= {rx, data[7:1]}; puts bit 0 at the bottom after 8 shifts.
  3. Connect ready to send and data to the transmitter's data.

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