200 MHZ Uart With Internal 16-Byte Buffer: 7 CLB 8 CLB
200 MHZ Uart With Internal 16-Byte Buffer: 7 CLB 8 CLB
Summary
This application note describes highly optimized Universal Asynchronous Receiver Transmitter
(UART) transmitter and receiver macros for Virtex, Virtex-E, and Spartan-II devices. The
UART_TX and UART_RX macros not only communicate with each other, but they are also fully
compatible with the standard UART communication protocols used for connecting to devices,
such as PCs or microcontrollers.
General
Description
The UART_TX and UART_RX macros provide the functionality of a simple UART transmitter
and receiver, each with the following fixed characteristics:
1 start bit
8 serially transmitted data bits, received least significant bit (LSB) first
1 stop bit
Each macro also contains an embedded 16-byte first-in first-out (FIFO) buffer, using a total of
only 15 Configurable Logic Blocks (CLBs). See Figure 1.
The macros are implemented using SMART_IP for absolute predictability over shape and size
and for providing very high levels of performance. Indeed, the eight speed grades for Virtex-E
devices ensure operation at clock rates exceeding 200 MHz. This high-level performance
combined with the internal data buffers results in asynchronous data transfers in excess of
1 Mbyte per second (Mb/s) with these macros.
UART_TX
UART_RX
8-bit
16 Byte
FIFO Buffer
Serial
TX
7 CLB
8-bit
Serial
RX
16 Byte
FIFO Buffer
8 CLB
X223_01_103000
2001-2008 Xilinx, Inc. All rights reserved. XILINX, the Xilinx logo, Virtex, Spartan, ISE and other designated brands included herein are trademarks of Xilinx in the United States
and other countries. All other trademarks are the property of their respective owners.
www.xilinx.com
Detailed
Description
UART_TX Macro
The UART transmitter is provided as a single EDIF netlist, which can be instantiated into a
design, as shown in Figure 2.
TX_INST_NAME
DIN[7:0]
BUFFER_FULL
WRITE
SERIAL_OUT
EN_16_X_BAUD
RESET_BUFFER
CLK
UART_TX
X223_02_103000
:
:
:
:
:
:
:
UART_RX Macro
The UART receiver is provided as a single EDIF netlist, which can be instantiated into a design,
as shown in Figure 3.
RX_INST_NAME
SERIAL_IN
EN_16_X_BAUD
READ
DOUT[7:0]
BUFFER_FULL
DATA_PRESENT
RESET_BUFFER
CLK
UART_RX
X223_03_103000
www.xilinx.com
:
:
:
:
:
:
:
:
in
in
in
in
in
out
out
out
STD_LOGIC;
STD_LOGIC;
STD_LOGIC;
STD_LOGIC;
STD_LOGIC;
STD_LOGIC_VECTOR (7 downto 0);
STD_LOGIC;
STD_LOGIC);
Common Signals
The signals shown in Table 1 are provided on both the transmitter and receiver macros.
Table 1: Signals Common to Both Transmitter and Receiver
Signal
Direction
Description
CLK
Input
EN_16_X_BAUD
Input
RESET_BUFFER
Input
BUFFER_FULL
Output
www.xilinx.com
Direction
Description
DIN[7:0]
Input
WRITE
Input
SERIAL_OUT
Output
Direction
Description
DOUT[7:0]
Output
DATA_PRESENT
Output
READ
Input
www.xilinx.com
UART Operation
Input
Although an asynchronous receiver and transmitter are not synchronized, the UART_TX and
UART_RX both use a timing reference that is of adequate tolerance to allow the serial transfer
of each byte of data.
The data is transmitted serially LSB first at a given bit rate (baud rate) known by the transmitter
and receiver. Since the transmitter can start sending this data at any time, the receiver needs
a method of identifying when the first (LSB) is being sent. This is achieved by the transmitter
sending an active Low start signal for the duration of one bit. See Figure 4.
Start
d0
d1
d2
d3
d4
d5
d6
d7
Stop
Start
X223_04_103000
d0
16
d1
16
X223_05_103000
Break Condition
The normal status of the serial line is active High. In this way, a new start bit is identified by its
falling edge.
www.xilinx.com
d0
d1
d2
d3
d4
d5
d6
d7
Stop
X223_06_103000
Start
d0
d1
d2
d3
X223_07_011701
Buffer Operation
The buffer in each macro performs a FIFO operation on the byte data to a depth of 16 bytes.
RESET_BUFFER can be used to discard the current contents of the buffer and, therefore, it
must be used with caution, so that data is not lost. In most cases, this signal is not used.
The UART_TX buffer is used to accept byte data for transmission when written to the macro.
The buffer is automatically read by the transmission circuit to pass the data to the serial line.
When the WRITE signal is active, data is written to the buffer on the rising edge of clock. Data
can be written in isolation, or in a burst of several bytes. See Figure 8.
CLK
DIN[7:0]
WRITE
Single write
www.xilinx.com
CLK
DIN[7:0}
No writes possible
WRITE
BUFFER_FULL
SERIAL_OUT
D7
Stop Bit
X223_09_103000
Invalid data
DATA_PRESENT
X233_10_103000
D7
Stop Bit
D5
D6
BUFFER_FULL
READ
DOUT[7:0]
X233_11_103000
Standard UART
Applications
The UART_TX and UART_RX macros can be used to enable a Xilinx device to communicate
with other devices conforming to standard UART protocols, such as PCs and microcontrollers.
If full RS232 signaling is employed, then an external device such as the MAXIM MAX220 (multichannel RS232 drivers/receivers) should be used. In cases where a Xilinx device is performing
microcontroller communication on the same printed circuit board (PCB), then a direct low
voltage transistor-transistor logic (LVTTL) should be more than adequate. However, in this
case, it is required that the external device must conform to the fixed protocol of the macros
(1 start bit, 8 data bits, no parity, and 1 stop bit). See Figure 12.
www.xilinx.com
Baud
Rate
Timing
clk
MAXIM
MAX220
UART_TX
PC
RS232
X223_12_041708
PCB
Virtex or Spartan-II FPGA
Baud
Rate
Timing
clk
UART_RX
LVTTL
Microcontroller
UART_TX
X223_13_041708
CLK
EN_16_X_BAUD
X223_14_103000
www.xilinx.com
Pulse Generator
clk/260
CLK
40 MHz
EN_16_X_BAUD
153.6 KHz
clk
X223_15_041608
reset
clk/260
clk
9-Bit
AND
X223_16_103000
CLK
VCC
Divide by 26
SRL16E
D
DIV26_INT
Q
CE
CLK
CLK
A0
A1
A2
A3
INIT=0000
LUT2
SRL16E
D
CE
Q
CLK
A0
A1
A2
A3
FD
EN_1538461Hz
VCC
CLK
Divide by 10
INIT=8
PULSE_1538461Hz (2 input AND gate)
EN_16_X_BAUD
Q
SRL16E
D
CE
Q
CLK
A0
A1
A2
A3
INIT=0001
GND
I1
I0
CLK
INIT=0001
GND
X223_17_052101
www.xilinx.com
Embedded Microcontroller
The ability to implement efficient serial communications inside a Virtex or Spartan-II device is
useful. However, communications carried out on such serial links are often made using higher
level protocols, consisting of the ASCII character set with control characters, such as LF and
CR. The particular application can also use special character sequences to identify where data
packets are contained. Although hardware state machines could be created to deal with these
cases, it is likely to be a difficult design task that would result in large silicon requirements.
A small 8-bit microcontroller called Constant Coded Programmable State Machine (KCPSM)
has been developed and is ideal for performing such tasks. See Figure 18. The internal buffers
of the UART macros enable the processor to work efficiently on the data without servicing
interrupts all the time (interrupts can be left to look for BUFFER_FULL conditions). At 35 CLBs,
this processor is very small; hence, the whole serial communications controller solution is
possible in the smallest Spartan-II device or virtually free in Virtex devices.
More details on the 8-bit microcontroller, KCPSM, can be found in the Xilinx Application Note
XAPP213, PicoBlaze 8-Bit Microcontroller for Virtex-E and Spartan-II/IIE Devices.
UART RX
Serial
RX
7 CLB
KCPSM
16 Byte
FIFO Buffer
INPUT[7:0]
35 CLB
UART TX
16 Byte
FIFO Buffer
OUTPUT[7:0]
INTERRUPT
8 CLB
Serial
TX
PORT_ID[7:0]
READ_STROBE
1 Block Memory
(Program)
CLK
INSTRUCTION[15:0]
I[15:0]
WRITE_STROBE
KCPSM available
on request
ADDR[7:0]
ADDRESS[7:0]
CLK
X223_18_103000
UART FastLINK
The UART_TX and UART_RX macros can operate at clock rates in excess of 200 MHz. This
performance can be exploited to provide fast asynchronous serial communications between
Xilinx devices. Since there is no reason to conform to any of the standard baud rates, the
EN_16_X_BAUD can be connected permanently High, so that the baud rate is the clock/16.
See Figure 19. For example, a 160-MHz clock results in a 10-Mb/s serial transfer; hence, a data
rate of 1 MB/s (10-bit periods per 8-bit data transfer).
PCB
UART_TX
UART_RX
LVTTL
UART_TX
UART_RX
clk
X223_19_103000
www.xilinx.com
PCB
PCB
UART_TX
UART_RX
LVDS
UART_RX
UART_TX
clk
X223_20_103000
Size and
Performance
The macros are provided as Relationally Placed Macros (RPM) of the shape shown in
Figure 21.
CLB
UART_TX
R0C0
CLB
CLB
CLB
CLB
CLB
CLB
UART_RX
R0C0
CLB
CLB
CLB
CLB
CLB
CLB
CLB
CLB
X223_21_103000
www.xilinx.com
11
Downloading
the Macros
There are two options for downloading the UART_TX and UART_RX macros (Option 2 is
recommended):
1. Download XAPP223.zip.
The macros are in the form of EDIF (.edn) files, which can be used within any early Virtex,
Virtex-E, or Spartan-II FPGA design. The macros should be treated as a black box in the
design. Other information about the macros is given in the readme.txt file.
2. Download the file bundle from the PicoBlaze processor website at
http://www.xilinx.com/picoblaze (preferred).
The UART macros are included in the file bundle in source VHDL and Verilog. These files
target all Xilinx FPGAs from early to current architectures. The implementations contain
improvements over the files from Option 1; for example, the FIFO buffer now has a half-full
flag.
Revision
History
12
The following table shows the revision history for this document.
Date
Version
Revision
01/31/01
1.0
07/10/01
1.1
Figure 17 updated.
04/24/08
1.2
www.xilinx.com