4.5 DESIGNING WITH MICROPROCESSORS
In this sectionwe concentrate on howto create an initialworking embedded system
and how to ensure that the system works properly. Section 4.5.1 considers possible
architectures for embedded computing systems. Section 4.5.2 studies techniques for
designing the hardware components of embedded systems. Section 4.5.3 describes
the use of the PC as an embedded computing platform.
4.5.1 System Architecture
We know that an architecture is a set of elements and the relationships between
them that together form a single unit.The architecture of an embedded computing
systemis the blueprint for implementing that system—it tells youwhat components
you need and how you put them together.
The architecture of an embedded computing systemincludes both hardware and
software elements. Let’s consider each in turn.
The hardware architecture of an embedded computing system is the more obvi-
ous manifestation of the architecture since you can touch it and feel it. It includes
several elements, some of which may be less obvious than others.
■ CPU An embedded computing system clearly contains a microprocessor.
But which one? There are many different architectures, and even within an
architecture we can select between models that vary in clock speed,bus data
width, integrated peripherals, and so on. The choice of the CPU is one of the
most important,but it cannot be made without considering the software that
will execute on the machine.
■ Bus The choice of a bus is closely tied to that of a CPU, since the bus is an
integral part of the microprocessor. But in applications that make intensive
use of the bus due to I/O or other data traffic,the busmay bemore of a limiting
factor than the CPU. Attention must be paid to the required data bandwidths
to be sure that the bus can handle the traffic.
■ Memory Once again,the question is notwhether the systemwill havemem-
ory but the characteristics of that memory.The most obvious characteristic is
total size,which depends on both the required data volume and the size of the
program instructions.The ratio of ROM to RAM and selection of DRAM versus
SRAM can have a significant influence on the cost of the system.The speed of
the memory will play a large part in determining system performance.
■ Input and output devices The user’s view of the input and output mech-
anisms may not correspond to the devices connected to the microprocessor.
For example,a set of switches and knobs on a front panelmay all be controlled
by a single microcontroller,which is in turn connected to the main CPU. For
a given function, there may be several different devices of varying sophistica-
tion and cost that can do the job. The difficulty of using a particular device,
such as the amount of glue logic required to interface it,may also play a role
in final device selection.
You may not think of programs as having architectures, but well-designed
programs do have structure that represents an architecture. A fundamental task
in software architecture design is partitioning—breaking the functionality into
pieces in a way that makes it easy to implement, test, and modify.
Most embedded systems will do more than one thing—for example,processing
streams of data and handling the user interface. Mixing together different types
of functionality into a single code module leads to spaghetti code, which has
poorly structured control flow,excessive use of global data,and generally unreliable
programs.
Breaking the system’s functionality into pieces that roughly correspond to the
major modes of operation and functions of the device is often a good choice. First,
different types of functionality often require different programming styles, so that
theywill naturally fall into different procedures in the code. Second,the functionality
boundaries often correspond to performance requirements. Since at least some of
the software components will almost certainly have to finish executing within a
given deadline, it is important to be able to identify the code that must satisfy the
deadline and to measure the performance of that code.
It is also important to remember that some of the functionality may in fact be
implemented in the I/O devices. You may have a choice between using a simple,
inexpensive device that requiresmore software support or amore sophisticated and
expensive device that can perform more functions automatically. (An example in
the digital audio domain is [1]-law scaling,which can be done automatically by some
analog/digital converters.) Using DMA to move data rather than a programmed
loop is another example of using hardware to substitute for software. Most of the
functionality will be in the software, but careful consideration of the hardware
architecture can help simplify the software and make it easier for the software to
meet its performance requirements.
4.5.2 Hardware Design
The design complexity of the hardware platform can vary greatly, from a totally
off-the-shelf solution to a highly customized design.
At the board level,the first step is to consider evaluation boards supplied by the
microprocessor manufacturer or another company working in collaboration with
themanufacturer. Evaluation boards are sold formanymicroprocessor systems;they
typically include the CPU, some memory, a serial link for downloading programs,
and some minimal number of I/O devices. Figure 4.24 shows an ARM evaluation
board manufactured by Sharp. The evaluation board may be a complete solution
or provide what you need with only slight modifications. If the evaluation board is
supplied by the microprocessor vendor, its design (netlist, board layout, etc.) may
be available from the vendor; companies provide such information to make it easy
for customers to use their microprocessors. If the evaluation board comes from a
third party, it may be possible to contract them to design a new board with your
required modifications, or you can start from scratch on a new board design.
The other major task is the choice of memory and peripheral components.
In the case of I/O devices, there are two alternatives for each device: selecting a
component from a catalog or designing one yourself.When shopping for devices
from a catalog, it is important to read data sheets carefully—it may not be trivial to
figure out whether the device does what you need it to do. You should also con-
sider the amount of glue logic required to connect the device to your bus. Simple
peripheral logic can be implemented in programmable logic devices (PLDs),
while more complex units can be built from field-programmable gate arrays
(FPGAs).
4.5.3 The PC as a Platform
Personal computers are often used as platforms for embedded computing. A PC
offers several important advantages—it is a predesigned hardware platform with
a great many features, a wide variety of I/O devices can be purchased for it, and it
provides a rich programming environment. Because a PC-based systemdoes not use
custom hardware, it also carries the resulting disadvantages. It is larger,more power-
hungry, and more expensive than a custom hardware platform would be. However,
for low-volume applications and environments such as factories and offices where
size and power are not critical,using a PC to build an embedded systemoftenmakes a
lot of sense.The termpersonal computer has come to apply to a variety ofmachines,
including IBM-compatibles,Macs, and others. In this section,we describe a generic
PC architecture with some discussion of features relevant to different types of PCs.
A detailed discussion of any of these platforms is beyond the scope of this book.
As shown in Figure 4.25, a typical PC includes several major hardware com-
ponents:
■ The CPU provides basic computational facilities.
■ RAM is used for program storage.
■ ROM holds the boot program.
■ A DMA controller provides DMA capabilities.
■ Timers are used by the operating system for a variety of purposes.
■ A high-speed bus, connected to the CPU bus through a bridge, allows fast
devices to communicate efficiently with the rest of the system.
■ A low-speed bus provides an inexpensive way to connect simpler devices and
may be necessary for backward compatibility as well.
PCI (Peripheral Component Interconnect) is the dominant high-perfor-
mance system bus today. PCI uses high-speed data transmission techniques and
efficient protocols to achieve high throughput. The original PCI standard allowed
operation up to 33 MHz; at that rate, it could achieve a maximum transfer rate of
264 MB/s using 64-bit transfers. The revised PCI standard allows the bus to run up
to 66 MHz, giving a maximum transfer rate of 524 MB/s with 64-bit wide transfers.
PCI useswide buseswithmany data and address bits alongwithmultiple control
bits.Thewidth of the bus both increases the cost of an interface to the bus andmakes
the physical connection to the bus more complicated.As a result,PC manufacturers
have introduced serial buses to provide high-speed transfers while keeping the cost
of connecting to the bus relatively low.USB (Universal Serial Bus) and IEEE 1394
are the two major high-speed serial buses. Both of these buses offer high transfer
rates using simple connectors. They also allow devices to be chained together so
that users don’t have to worry about the order of devices on the bus or other details
of connection.
A PC also provides a standard software platform that provides interfaces to the
underlying hardware as well as more advanced services. At the bottom of the soft-
ware platform structure in most PCs is a minimal set of software in ROM. This
software is designed to load the complete operating system from some other device
(disk, network, etc.), and it may also provide low-level hardware interfaces. In the
IBM-compatible PC, the low-level software is known as the basic input/output
system (BIOS). The BIOS provides low-level hardware drivers as well as booting
facilities.The operating systemprovides high-level drivers,control of executing pro-
cesses, user interfaces, and so on. Because the PC software environment is so rich,
developing embedded code for a PC target is much easier than when a host must be
connected to a CPU in a development target. However, if the software is delivered
directly on a standard version of the operating system, the resulting software pack-
age will require significant amounts of RAM as well as occupy a large disk image.
Developers often create pared down versions of the operating system for delivering
embedded code on PC platforms.
Both the IBM-compatible PC and the Mac provide a combination of hardware
and software that allows devices to provide their own configuration information.
On the IBM-compatible PC, this is known as the Plug-and-Play standard developed
by Microsoft.These standards make it possible to plug in a device and have it work
directly,without hardware or software intervention from the user.
It is now possible to put all the components (except for memory) for a standard
PC on a single chip. A single-chip PC makes the development of certain types of
embedded systems much easier, providing the rich software development of a PC
with the low cost of a single-chip hardware platform.
The ability to integrate a CPU and devices on a single chip has allowed manufac-
turers to provide single-chip systems that do not conform to board-level standards.
Application Example 4.1 describes one such single-chip system,the Intel StrongARM
SA-1100.
Bạn đang đọc truyện trên: truyentop.pro