A fully-featured, Verilator-compatible UART (Universal Asynchronous Receiver/Transmitter) implementation in SystemVerilog with a comprehensive C++ testbench.
- 10-bit shift register (start + 8 data + stop)
- Busy flag prevents overwriting during transmission
- Least significant bit ("LSB")-first transmission
- Automatic frame generation
- Four-state FSM: IDLE → START → DATA → STOP
- Start bit validation to prevent false triggers
- Stop bit checking for frame error detection
- Ready pulse signals completed byte reception
- LSB-first reception with proper bit alignment
- Verilator (version 4.0 or later)
- C++ compiler (g++, clang++)
- Make
- Homebrew
sh setup.sh
make
The included testbench (sim_main.cpp).
- Reset Test: Verifies proper initialization
- Single Byte Transmission: Tests TX path with 0x55
- Single Byte Reception: Tests RX path with 0xAA
- Loopback Test: Multiple bytes (0x00, 0xFF, 0x42, 0xA5, 0x5A)
MIT