Home / Learn Verilog / Project 5: UART Echo and Hello Printer

Project 5: UART Echo and Hello Printer

Send text to a PC terminal and echo what you type.

The short versionSend text to a PC terminal and echo what you type.

Theory in plain words

UART echoPC terminalUSB-serialFPGA RXecho registerFPGA TXPC
UART echo

Definition

The FPGA receives characters from a terminal program, sends them back (echo) and prints "Hello" on a button press.

Why you need this

Projects turn knowledge into skill: you design, simulate, debug and finally see real hardware react.

How it works

Simulate in the browser, then build for your board following the steps.

Where you'll see this

  • Portfolio
  • Interviews
  • Learning by doing

What you will build

The FPGA receives characters from a terminal program, sends them back (echo) and prints "Hello" on a button press.

LevelTimeWorks in simulation only?
Intermediate4 hoursNo: simulate first, then run on the board

What you need (equipment and tools)

Read this table once and you will know exactly what to buy or prepare. You can do the simulation part with only a computer and the free tools.

ItemWhat it is (in simple words)Why you need itApprox. cost
Computer (Windows, Linux or macOS)Your normal laptop or desktop. You write Verilog here and run the free tools.Simulator, synthesis and programmer all run on it.you have it
Free software: Icarus Verilog + GTKWave (simulation), Yosys + nextpnr or the vendor IDE (build), openFPGALoader (program)The programs that compile and simulate your design.Everything in this course can be simulated with only these free tools.free
FPGA development board (e.g. Tang Nano 9K, Basys 3, iCEBreaker, Arty A7)A small circuit board with an FPGA chip, an oscillator (clock), LEDs, buttons and a USB port. The FPGA is the "blank hardware" that your Verilog turns into a real circuit.This is where your design actually runs. Without it you can only simulate.about $15 (Tang Nano 9K) to $150 (Arty A7)
USB cable (data type, not charge-only)Cable between the board and the computer. Some cheap cables carry only power and no data.Programs the FPGA and powers it. If the board is not found, try another cable first.$2
USB-to-serial adapter (CP2102, CH340 or FT232, 3.3 V level)A small dongle that turns USB into TX/RX pins that a UART design can talk to.Lets the PC send/receive bytes with your design in a terminal program.$3
Breadboard + jumper wiresA plastic board with holes connected in rows; wires plug in without soldering.Connect the FPGA pins to buttons, LEDs and modules quickly and safely.$5
Logic analyzer (8-channel USB, e.g. Saleae-clone) - optional but very usefulA tool that records digital signals over time and shows them as waveforms on the PC, like the simulator but for the real board.Lets you check what the pins really do (UART bits, SPI clock, VGA sync).$10 for a clone, use with PulseView (free)
Terminal program (PuTTY, minicom, screen, or the Arduino serial monitor)A program on the PC that shows received characters and sends typed ones.The "other end" of your UART.free

Connections

SignalDirectionGoes toNote
rxinputTX pin of the USB-serial adaptercross-over: adapter TX to FPGA RX
txoutputRX pin of the adapteradapter RX from FPGA TX
GND-adapter GNDmust be shared

Step 1: simulate the design

UART receive + transmit in simulationVerilog: edit and run

The receiver gets H and i and the transmitter starts sending them back.

Step by step

  1. Set your terminal to the same baud rate as the design (115200 8N1).
  2. DIV = clock frequency / baud rate: 27 MHz / 115200 = 234.
  3. Check tx with a logic analyzer: idle high, start bit low.
  4. Echo: connect the receiver output to the transmitter input through a one-byte register.
  5. Add a button that sends "Hello\r\n" using a small ROM and counter.

Step 2: top-level for the board

Top-level wrapper and pin constraints (adapt pin names to your board)
module top(input clk, rx, output tx);
  // instantiate uart_rx and uart_tx with DIV = 234 and connect them as an echo
endmodule

If it does not work

SymptomLikely causeFix
Board not detected by the PCCharge-only USB cable or missing driverTry another data cable; install the vendor/FTDI driver; check dmesg or Device Manager
Nothing happens after programmingWrong clock pin or wrong pin constraintsCompare every pin with the board schematic; first test with a blinking LED
Garbage charactersBaud rate mismatchCompute DIV again and set the terminal to 115200
Nothing receivedTX and RX swapped or no common groundCross TX/RX and connect GND
Works at first then errorsClock toleranceSample in the middle of each bit
Tip:Keep your first board test tiny: if the LED blinks, the toolchain, cable and clock are fine. Then add your project piece by piece.

Test what you just read

1. Baud divider for 27 MHz and 115200 baud?