This is an old revision of the document!
Verilog UART Readme
Introduction
This is a basic UART to AXI Stream IP core, written in Verilog with MyHDL testbenches.
Documentation
Source Files
rtl/uart.v
- Wrapper for complete UARTrtl/uart_rx.v
- UART receiver implementationrtl/uart_tx.v
- UART transmitter implementation
uart module
parameter DATA_WIDTH = 8
- define width of data bus and transferred words in bitsinput wire clk
- clock inputinput wire rst
- reset inputinput wire [DATA_WIDTH-1:0] input_axis_tdata
- data inputinput wire input_axis_tvalid
- data valid inputoutput wire input_axis_tready
- ready for data outputoutput wire [DATA_WIDTH-1:0] output_axis_tdata
- data outputoutput wire output_axis_tvalid
- data valid outputinput wire output_axis_tready
- ready for data inputinput wire rxd
- UART RXD inputoutput wire txd
- UART TXD outputoutput wire tx_busy
- operation in progress signaloutput wire rx_busy
- operation in progress signaloutput wire rx_overrun_error
- overrun error signaloutput wire rx_frame_error
- frame error signalinput wire [15:0] prescale
- BAUD rate prescale value
uart_rx module
parameter DATA_WIDTH = 8
- define width of data bus and transferred words in bitsinput wire clk
- clock inputinput wire rst
- reset inputoutput wire [DATA_WIDTH-1:0] output_axis_tdata
- data outputoutput wire output_axis_tvalid
- data valid outputinput wire output_axis_tready
- ready for data inputinput wire rxd
- UART RXD inputoutput wire busy
- operation in progress signaloutput wire overrun_error
- overrun error signaloutput wire frame_error
- frame error signalinput wire [15:0] prescale
- BAUD rate prescale value
uart_tx module
parameter DATA_WIDTH = 8
- define width of data bus and transferred words in bitsinput wire clk
- clock inputinput wire rst
- reset inputinput wire [DATA_WIDTH-1:0] input_axis_tdata
- data inputinput wire input_axis_tvalid
- data valid inputoutput wire input_axis_tready
- ready for data outputoutput wire txd
- UART TXD outputoutput wire busy
- operation in progress signalinput wire [15:0] prescale
- BAUD rate prescale value
AXI interface
The main interface to the user design is an AXI4-Stream interface that consists of the tdata, tvalid, and tready signals. tready flows in the opposite direction. tdata is considered valid when tvalid is high. The destination will accept data only when tready is high. Data is transferred from the source to the destination only when both tvalid and tready are high, otherwise the bus is stalled.
AXI Stream Interface Example
two byte transfer with sink pause after each byte
__ __ __ __ __ __ __ __ __ clk __/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__ _____ _________________ tdata XXXXXXXXX_D0__X_D1______________XXXXXXXXXXXXXXXXXXXXXXXX _______________________ tvalid ________/ \_______________________ ______________ _____ ___________ tready \___________/ \___________/
Testing
Running the included testbenches requires MyHDL and Icarus Verilog. Make sure that myhdl.vpi is installed properly for cosimulation to work correctly. The testbenches can be run with a Python test runner like nose or py.test, or the individual test scripts can be run with python directly.
Testbench Files
- tb/axis_ep.py - MyHDL AXI Stream endpoints
- tb/test_uart_rx.py - MyHDL testbench for uart_rx module
- tb/test_uart_rx.v - Verilog toplevel file for uart_rx cosimulation
- tb/test_uart_tx.py - MyHDL testbench for uart_tx module
- tb/test_uart_tx.v - Verilog toplevel file for uart_tx cosimulation
- tb/uart_ep.py - MyHDL UART endpoints
Example Design
The included example design is targeted to a Digilent Atlys board. To build it, cd into example/ATLYS/fpga, make sure the Xilinx settings file has been sourced correctly, and run make.