2.1 Data Encoding
The algorithm that encodes the data according to the
Hamming code (Peterson, 1992) is simple:
- all bit positions that are powers of two (positions:
1, 2, 4, 8 and so on) are used as parity bits (P1, P2,
P3, P4 and so on);
- all other bit positions (positions 3, 5, 6 and so on)
are reserved for the data itself (D0, D1, D2 and so
on)
Thus the data stream will be:
- P1, P2, D0, P3, D1, D2, D3, P4, D4, D5, D6, D7
for an 8 bits data;
- P1, P2, D0, P3, D1, D2, D3, P4, D4 … D10, P5,
D11 … D15 for a 16 bits data;
- P1, P2, D0, P3, D1, D2, D3, P4, D4 … D10, P5,
D11 … D25, P6, D26 … D31 for a 32 bits data.
Adding a start bit (‘0’) and a stop bit (‘1’), a total
of 14 bits are necessary to transmit/receive a byte,
23 bits to transmit/receive a word, and 40 bits to
transmit/receive a double word.
To transmit/receive the 8 bits data, a “classical”
UART (working with only one stop bit) uses 3
supplementary bits (a 37.5% overhead).
In the proposed UART, the total number of
supplementary bits will be 6 for an 8 bits data (a
75% overhead), 7 for a 16 bits data (44%), but only
8 for a 32 bits data (only a 25% overhead).
Thus, to transmit a byte, the classical UART
must transmit only 11 bits and the proposed UART
must transmit 14 bits, decreasing the communication
throughput. But, to transmit a double word, the
classical UART must transmit 44 bits, whereas the
proposed UART transmits only 40 bits, and
therefore increasing the communication speed.
This joins another feature of the new UART
which ups communication speed, which is its error
self-correction ability (which saves the need for
resending data).
2.2 Error Detection and Correction
When a transmission error occurs, the traditional
UART can only detect it. Correction must be made
at a superior level of communication, and involves
resending the data, a lengthy process.
It is to be noted that this is typical also to other
communication protocols, such as the very popular
USB communication standard, which uses a CRC
method to detect the transmission error – a Not
Acknowledge (NAK) response of the receiver if an
error will appear, will also require to repeat the
transmission.
In contradiction, the new UART’s multiple
parity bits mechanism, as laid in the Hamming
Code, allows it to correct, by itself, every single
error. In this manner, no superior level of
communication is required. Moreover, using a
pipeline procedure, the receiver can correct the error
in parallel with a new data receiving process, thus
the communication throughput is not affected by the
eventual transmission errors (Thirer, 2006).
It is also notable that Hamming code also allows
detecting double errors, but can only correct a single
error. Meaning, the method of error correction is not
best suited for errors that come in bursts, but to
situations in which errors are randomly occurring
(and those are the most common in UART).
2.3 Baud Rate
To provide a large range of baud rates, a
programmable 16 bits counter is included in the
UART.
Thus the UART is able to work with various
baud rates, from the transmission clock value
TXCLK to TXCLK / 65536 without additional
circuits.
3 AN FPGA IMPLEMENTATION
This UART was successfully implemented and
tested in an ALTERA CYCLONE EP1C6Q240C8
FPGA chip
The UART controller includes a transmitter unit,
a receiver unit and an internal counter.
The user can select the data path width (8, 16 or
32 bits), the error control method (parity bit or
Hamming code) and also the baud rate (by the value
of the counter acting as a clock divider ).
Fig. 2 presents the state machine to generate and
transmit the serial data stream by using the parity
control bit or by using the Hamming control bits.
For generate the parity bits, a XOR based
scheme was implemented in the transmitter unit.
Evidently, the use of separate schemes for every
parity bit will increase the speed, by a parallel
computation, but a cheaper UART implementation
can use a single parity generator scheme for a serial
computation of the P1, P2, …P6 bits.
Fig. 3 presents the state machine for the receiver
unit, including the parity check and the Hamming
error check and fix.
Fig. 4 presents the block scheme of the receiver
unit.
In the receiver unit, the parity check and fix
section includes a parity generator (like the parity
circuit of the transmitter unit) a six bit comparator
(to check the received parity bits) and an adder
A NEW UART CONTROLLER
355