Compact UART transmitter/receiver RTL with parity support, loopback simulation, and FPGA project scaffolding for Vivado/Quartus flows.
This project implements a reusable UART (Universal Asynchronous Receiver/Transmitter) communication core in Verilog, including both transmit (TX) and receive (RX) paths. It converts parallel bytes to serial UART frames and reconstructs received serial frames back into bytes, with optional parity checking and framing/parity error reporting.
It is useful for:
- Learning digital communication protocol design in RTL
- Integrating serial debug/command interfaces in FPGA projects
- Serving as a clean reference design for UART timing, framing, and verification flow
Core functions provided:
- UART byte transmission with configurable baud and oversampling
- UART byte reception with start-bit validation and error flags
- Loopback testbench and script-based simulation workflow for quick validation
- Configurable
CLK_FREQ_HZ,BAUD_RATE, andOVERSAMPLE(default16) - TX frame:
start(0)+8 data bits (LSB first)+optional parity+stop(1) - RX start-bit validation and mid-bit sampling using oversample ticks
- RX status outputs:
rx_valid,parity_error,framing_error - Ready-to-run simulation flow for Windows PowerShell and Linux/macOS shell
UART-Tx/
├── src/ # RTL: uart_tx, uart_rx, uart_top
├── test/ # Testbenches
├── sim/ # Icarus + GTKWave scripts/Makefile
├── constraints/ # Basys3 / Arty A7 XDC templates
├── fpga/ # Placeholder project directories
├── docs/ # Diagrams and report assets
├── .gitignore
├── LICENSE
└── readme.md
- Icarus Verilog (
iverilog,vvp) - GTKWave (optional, for waveform viewing)
- Python 3.6+ and
cocotb(for Python-based testbenches)
choco install iverilog gtkwave -y
pip install cocotb pytestIf iverilog is still not found after install:
- Open PowerShell as Administrator.
- Clear possible Chocolatey lock files:
Remove-Item "C:\ProgramData\chocolatey\lib\*.lock" -Force -ErrorAction SilentlyContinue- Re-run install:
choco install iverilog -y- Open a new terminal and verify:
iverilog -V
vvp -VIf local install remains blocked, push the repo and use GitHub Actions CI (included in this project) to validate simulation in the cloud.
Set-Location sim
.\run_sim.ps1 -Target mainRun RX-only test:
Set-Location sim
.\run_sim.ps1 -Target rxRun with waveform viewer:
Set-Location sim
.\run_sim.ps1 -Target main -Wavecd sim
make runOpen waveform:
cd sim
make waveThis project includes Python-based testing using Cocotb for randomized testing and edge-case generation.
cd test
makeThis will run the test_uart.py testbench using Icarus Verilog and output the results to the console.
OVERSAMPLE=16means one UART bit spans 16 oversample ticks.- TX advances to the next bit every 16 ticks.
- RX validates start at
OVERSAMPLE/2, then samples each bit every 16 ticks.
- Update the placeholders in
constraints/basys3.xdcorconstraints/arty_a7.xdc. - Match
clkconstraint period to your board clock source. - Keep top-level UART I/O names aligned with
uart_top.vor your board wrapper.
- RTL and testbenches are written in Verilog-2001 style and compile with
iverilog -g2012. - Generated simulation artifacts (
*.vvp,*.vcd) are ignored by Git. - See
CONTRIBUTING.mdfor recommended contribution workflow.
This project is licensed under the MIT License. See LICENSE.