Simple 8-bit UART implementation in Verilog HDL.
This is a fork of verilog-uart (which doesn't work). It fixes several issues with the transmit and receive code, adds majority voting for bit sampling, and uses valid/ready signals for control. It was synthesized using Yosys and successfully tested on an FPGA (up to 115200 baud driven by a 48 MHz clock, both transmit and receive.)
It assumes 8 data bits, 1 start bit, 1 stop bit, and no parity. The receiver uses 16x oversampling and majority voting over 3 samples.
CLOCK_RATE
- clock rateBAUD_RATE
- target baud rate
clk
- [input] clock signal
rx
- [input] RX linerxEn
- [input] enable/disable receiverout[7..0]
- [output] received datarxValid
- [output] end of transaction (1 posedge clk)rxReady
- [output] low when RX is in progressrxErr
- [output] transaction error: invalid start/stop bit (1 posedge clk)
txEn
- [input] enable/disable transmittertxValid
- [input] start of transaction (1 posedge clk)in[7..0]
- [input] data to transmit (stored inside while transaction is in progress)tx
- [output] TX linetxReady
- [output] low when TX is in progress