requires a lot of effort. More often than not, applying
contemporary interface standards will lead to spending more money.
Various fees have to be paid for licenses, for membership in the
standardization committee, for acquiring a vendor ID, for getting
the design certified (to ensure conformity),and more.
EXPLOITING THE ATA INTERFACE
One legacy interface boasting low latencies and high data rates can
be found on even the most contemporary motherboards-the advanced
technology attachment (ATA) interface. ATA is still a mainstream
drive interface,so long-term availability could be taken for
granted. The most compelling advantage is simplicity. The legacy
ATA interface (Parallel ATA) is essentially a modified ISA bus.
Hence, it should be easy to develop I/O adapter hardware. The
hardware/ software API is straightforward-a small register file
accessible by I/O instructions. ATA registers can be accessed
directly (under DOS or Linux) or via comparatively simple port
drivers. Serial ATA (SATA) is principally nothing more than two
wire pairs to push around register contents between the host
adapter and the attached device. Because ATA is essential for
booting the system,appropriate support is deeply embedded within
the BIOS and the operating systems.
In this article, I will concentrate on programmed I/O (PIO)
operation of the parallel ATA (PATA) interface without provisions
for supporting attachment of SATA protocol converters (see Figure
1).PATA is still supported on new motherboards in small form
factors (such as Mini-ITX or Nano-ITX), particularly because it is
still a mainstream interface for optical drives. Employing ATA as
the low-latency embedded interface enables you to apply such
motherboards instead of typical industrial platforms(like PC/104,
EBX, EPIC, or PICMG),which are considerably more expensive(see
Photo 1).


Typical ATA I/O adapters will fit into small CPLDs. Eventually, the application-specific circuitry could find its place within the same CPLD,too (see Figure 2a)。 ATA interface adapters can be provided for the attachment of widely available I/O hardware, like Opto 22-compatible racks, ISA or PCI I/O cards, and PC/104 modules (see Figure 2b).

MOTIVATION
Low-latency control problems could be solved outside of the PC by
providing the appropriate hardware. A microcontroller connected via
a serial port,USB, or Ethernet is an obvious example. On the
market, such hardware(integrated circuits, modules, starter kits,
and so on) is available in abundance. Contemporary development
software is comfortable and, more often than not, free.
But this approach has severe drawbacks too. Generally, there is the
problem of functional partitioning between software and external
hardware,as well as between two programs:one running on the PC and
one on the microcontroller. It poses some challenges.
In embedded systems design, typical application problems lead to
some kind of state machine, executing the following steps: first,
fetch input data(from sensors, operator panels, and the like);
second, perform the necessary decisions and calculations to
determine the next state and the outputs;third, emit output data
(to actuators,displays, and the like); and finally,return to the
first step.
Functional partitioning is an art rather than an exact science. It
has to be done even if you can get the microcontroller together
with its programming environment for free. Whether it is a trivial
task or not depends on the complexity of the second step. If the
decisions and calculations to be executed in this step require a
lot of computing power and memory capacity, low-cost external
hardware (i.e., PIC, AVR, or a small FPGA) will not do. In some
cases,intermediate microcontrollers (i.e.,Blackfin or ARM) would
help. But many applications have to cope with vast performance
requirements and high complexity. Many users expect the look and
feel of Windows and the availability of advanced graphics, database
and networking services,and so on. This way, comparatively humble
embedded control tasks and typical performance-hungry Windows
applications become closely intertwined. Often, a practically
viable function partitioning cannot avoid employing external
high-performance platforms (e.g., based on PowerPC or Coldfire
processors) running their own real-time OS. (In other words,all of
the decisive functions have been delegated to the external
subsystem. The Windows PC is merely used as an operating console,
file server, print server, and network hub.)
Partitioning splits the development process into independent tasks
(i.e.,PC programming, microcontroller programming, and FPGA
design).Without partitioning (all application programs reside in
the PC), program development can be done completely within one
environment (like Visual Basic, C#, or Delphi)。 From an average
Visual Basic, C#, or Delphi programmer,you can expect a PC-only
solution,not a mixture of PC programming,microcontroller
programming,and hardware design.
Therefore, many embedded systems designers resort to the
alternative approach: leave all program activities to the PC and
attach the application-specific hardware via low-latency
interfaces, especially via PCI cards, PC/104 modules, and more.
ATA I/O can be seen as a viable alternative in application areas
that are the traditional domains of the(expensive)
small-form-factor industrial PC modules.
PRINCIPLES OF OPERATION
In the beginning, ATA was a stripped-down ISA bus. The signal
lines are shown in Figure 3. Refer to Figure 1 for the principal
access cycles. Early host adapters comprised only a data bus buffer
and some address decoding circuitry. The addressing provisions were
reduced to three address lines and two pre-decoded chip selects,
supporting the selec tion of nine registers or I/O ports (see Table
1)。 So, it may seem a somewhat trivial task to design appropriate
interface adapter circuitry. Such an adapter would resemble an
old-fashioned ISA I/O card, consisting essentially of an address
decoder and attached input and output registers.


PRINCIPAL SOLUTION
The solution relies on a few simple provisions and tricks. I will
consider only register addresses, which have no side-effects in the
hardware (like command initiation) and for which the ATA standard
permits read and write accesses at random. The device/head (DH)
register will be used for device and port selection (see Figure
4).This register will be deliberately prevented from being read. A
read access to the DH register will deliver "nothing,"which results
in reading a constant value FFH. To avoid conflicts when the BIOS
tries to detect the ATA configuration,I will not use the value 0H
(in the bit positions 3......0 of the DH register) as a valid port
address. So, my adapter will be hidden completely from the
configuration software and will pass the boot and initialization
sequences without being noticed.

MORE THAN ONE ADAPTER IC
It should be possible to attach more than one I/O adapter without
resorting to the obvious principle of master/slave selection. An
application example is an industrial computer system based on a
Nano-ITX motherboard featuring one parallel and two serial ATA
ports. The parallel ATA port is used to attach one drive (DVD or
flash memory)configured as device 0 (master) and some I/O adapter
ICs (CPLDs or FPGAs), which together constitute the device 1
(slave).To support such configurations,each adapter IC has to be
assigned to a different subset of I/O port addresses. Each adapter
should write to ATA registers or drive the ATA data bus only if the
DH register contains a valid port address.
PATA CIRCUITRY
An ATA I/O adapter consists of gates and flip-flops. The principle
of operation is comparatively simple,especially if only PATA is
supported(there are no complex state machines and the like)。 Very
basic adapters fit into small CPLDs, containing 32 to 36 macro
cells. An appropriate example adapter consists of the ATA frontend
circuitry (described below) and one microcontroller-like 8-bit-port
comprising a data register and a direction register. But even the
detailed schematic of this simple circuit would occupy too much
space. Hence, I will concentrate on the basic principles.
REFERENCE DESIGNS
Based on Xilinx XC9500 CPLDs, some ATA I/O adapters have been
designed and-of course-tested intensively. Photo 2 shows one of the
test platforms. Porting to other families of programmable ICs
should pose no difficulties. The design documentation,including
complete Xilinx ISE projects, detailed schematics, and descriptions
is readily available for downloading. The four designs mentioned
below fit into Xilinx XC95108 CPLDs. Expect more to come.

In Windows, programming via simple port drivers will lead to the
usual latencies like the well-known I/O programming of the parallel
port. In this respect, ATA I/O could be seen as a substitute for
the good old parallel port, which is lacking on nearly all
contemporary commercial-grade motherboards (at least in small form
factors)。 However, if the latencies are to be avoided, the entire
I/O part of the application program must be written as a kernel
driver.
FUNCTION BLOCKS
Because you want to support the development of truly
application-specific I/O adapter hardware, it is advantageous to
distinguish between the ATA side and the application side of the
adapter circuitry (see Figure 2).Obviously, the circuitry that
connects directly to the ATA interface could be some kind of
standardized function block. This function block is called the ATA
front end. Figure 5 shows the function block together with the
application-specific inputs and outputs and the corresponding
address decoding circuitry. Output data is held in registers. Input
signals do not require particular registers because the front end
contains a common Read data register. Hence,they can be attached
via a data selector.



I highly recommend that you design the address decoders carefully.
Socalled alias addresses (caused by incomplete or sloppy address
decoding) are to be avoided. Each ATA I/O adapter should react only
on valid addresses.
DATA PATH STRUCTURE
Because CPLDs do not support tristate buses, separate read and
write data paths have to be provided. Write data are propagated
from the ATA data bus to the internal write data bus. Read data are
clocked into the synchronization register and driven onto the ATA
data bus.
THE NEXT STEP
In contemporary PCs, ATA is the last remaining low-latency
interface providing a straightforward hardware/softwar API.
Designing appropriate adapter hardware is comparatively easy. It
requires nothing more than a small CPLD-and a few gotchas to be
considered. ATA I/O adapters have been attached to all kinds of PC
motherboards. Besides the obvious application of using up legacy
hardware, it is especially compelling to apply such adapters
together with miniaturized motherboards of the commercial
high-volume market, such as Mini-ITX, Nano-ITX, and Pico-ITX.
Supporting Serial ATA (SATA) will be the next logical step.