Файл: Embedded Controller Hardware Design (Ken Arnold, 2001).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 13.06.2025
Просмотров: 2652
Скачиваний: 0
115CHAPTER FOUR
Memory Technologies and Interfacing
special system software, it is possible to make the main memory appear much larger than it actually is to a program running on this type of machine. When the program attempts to access a location that is not present in the main memory, the hardware and software redirect the memory reference to a real block of memory, after the required data is loaded from disk. Thus the appli cation program is presented with a virtual memory that is significantly larger than the actual physical main memory. This has the effect of simplifying the code, since all data can be referenced by a single address, rather than selecting a file, track, or sector on a disk.
CPU Control Lines for Memory Interfacing
Some CPUs generate signals for memory timing and synchronization with devices having various access times using a technique that generates delay cycles for slow memories, referred to as wait states. The 8051 processor used in this text does not use or generate wait states for simplicity. The Dallas 80C320 series of high speed microcontrollers incorporate a software-controlled mechanism for generating wait states. These extended memory cycles allow the processor to work with slower memory and peripheral chips.
Chapter Four Problems
1.What is the largest capacity SRAM that will fit in a 32-pin package?
2.What is the largest ROM that will fit in a 32-pin package?
3.Using 4M x 4 DRAMs, how many chips will be required to implement a 16 megabyte memory organized in 32-bit words?
4.What restrictions must be considered, when writing software to program an EEPROM device?
5.What restrictions are imposed when writing to flash EPROM?
6.What would you expect to read from a blank EPROM, if its data storage element is an N-channel FET that is connected with its source grounded and the drain connected to an output pin and a pull-up resistor?
5 |
|
CHAPTER FIVE |
117 |
CPU Bus Interface
and Timing
The central processing unit (CPU) is the key part of a microcomputer, both from the functional aspect and from the design procedure facet. This is because the key control signals originate from the CPU, driving most of the timing, load, and functional characteristics of the bus interface that all other devices must be compatible with. The processor controls the data transfers on the bus on a cycle- by-cycle basis, fetching instructions, reading and writing operand data. Let’s begin by examining how the CPU reads data from and writes data to memory.
Read and Write Operations
Refer to Figure 5-1 as you read through the following steps in a memory read operation:
1)The CPU selects the memory location by driving the address on the address bus.
2)Control lines are driven by the CPU to indicate the address space to use, such as program memory, data memory, I/O, or special cycles such as interrupts.
3)Read is activated on the control bus by the CPU to indicate that the memory can drive the data bus with the contents of the selected location.
4)The memory drives the contents of the selected location on the data bus.
5) The CPU deactivates |
Memory Read Cycles |
||||||
the address and |
2 |
Instruction Fetch |
2 |
Data Fetch Cycle |
|||
control lines, |
Status |
Program Memory Cycle |
Data Memory Cycle |
||||
turning off the |
3 |
3 |
|||||
memory drivers. |
RD |
5 |
5 |
||||
Address |
1 |
1 |
|||||
Program Memory Address |
Data Memory Address |
||||||
Figure 5-1: Generic |
Bus |
||||||
CPU reading instructions |
Data |
4 |
4 |
||||
and data from memory. |
Opcode |
Operand |
|||||
Bus |
|||||||
118EMBEDDED CONTROLLER
Hardware Design
Refer to Figure 5-2 as you read through the following steps in a memory write operation:
1)The CPU selects the memory location by driving the address on the ad dress bus.
2)Control lines are driven by the CPU to indicate the address space to use.
3)The CPU drives the data to be written on the data bus.
4)Write is activated on the control bus by the CPU to indicate that the data on the data bus should be written into the selected location.
5)The CPU deactivates the address, data, and control lines.
Memory Write Cycles
2 |
Data Store Cycle |
2 |
Data Store Cycle |
||
Status |
Data Memory Cycle |
Data Memory Cycle |
|||
4 |
4 |
||||
WR |
|||||
5 |
5 |
||||
1 |
1 |
||||
Address Bus |
Data Memory Address |
Data Memory Address |
|||
Data Bus |
3 |
3 |
|||
Write Data |
Write Data |
||||
Figure 5-2: Generic CPU writing data to memory.
Address, Data, and Control Buses
During normal operation, the CPU drives the address bus with the location to be transferred to or from the CPU. Addresses generally refer to memory locations or I/O locations. The data stored in those locations is usually eight bits (a byte), 16 bits, or 32 bits depending on the processor. Most microcontrollers use byte addressing, meaning that each address is a pointer to an 8-bit piece of data. Most 8-bit and virtually all 16and 32-bit processors can also address and manipulate data in 16and 32-bit pieces. Directly accessible addresses are those that the CPU can access in a single cycle using the address bus. If a processor has N address bits, then it can directly address 2N locations, starting at location 0 and increas ing to location 2N-1. Typical processors may have 16-, 20-, 24-, or 32-bit address buses. A byte addressing, 16-bit processor can address 216 locations, or 65,536 = 64 kilobytes. Likewise, a processor with a 20-bit address bus can directly access 220 locations, or one megabyte. Some locations of memory may not be directly accessible by the CPU, meaning that the CPU must use multiple cycles to access one memory location, usually under software control. This technique, sometimes referred to as bank switching, is the so-called “expanded memory above one megabyte in the PC, which uses an 8088 CPU with 20 address bits.
119CHAPTER FIVE
CPU Bus Interface and Timing
The 80286 CPU has 24 address bits allowing direct addressing of 224 or 16 megabytes. The 80386 and higher processors have a 32-bit address space, addressing up to 232 or 4 gigabytes. Some processors use a subset of the address lines for I/O. If the processor instructions use a 16-bit address field in the I/O instructions for example, then only 216 I/O locations are accessible.
The data bus, driven by the CPU during write cycles and by other devices during read cycles, transfers instructions and data in and out of the CPU. The width of the data bus, among other things, determines the amount of data that can be transferred on the bus. This data throughput is referred to as the bus bandwidth and is usually expressed in bytes per second. If a bus supports one transfer per microsecond, an 8-bit bus has a one megabyte per second band width, a 16-bit bus has a two megabytes per second bandwidth, and a 32-bit bus has four megabytes per second bandwidth. In the case of an 8-bit bus and a period T =1 microsecond ( S), then f = 1/T = 1 MHz and, for one byte per cycle, the result is one megabyte per second or eight megabits per second.
The control bus, normally driven by the CPU, determines what type of cycle is to take place and when the data will be present on the bus. In the case of a processor with a multiplexed address and data bus, some or all of the data bus is multiplexed or shared with the address bus. An additional signal is provided on the control bus to enable an address storage latch to hold the address informa tion at the beginning of a transfer cycle. Bus cycles on a multiplexed address/data bus system, as shown in Figure 5-3, are identical to those illustrated previously except for the addition of address information on the data bus at the beginning of a cycle, and an address latch control signal as shown in Figure 5-3. The 8051 has a multiplexed bus cycle.
Multiplexed Bus Cycles
Data Fetch Cycle |
Data Store Cycle |
|||
Status |
Data Memory Cycle |
Data Memory Cycle |
||
RD |
RD Cycle |
|||
WR |
WR Cycle |
|||
ALE |
||||
Latch Output |
RD Address |
WR Address |
||
Address/Data Bus |
RDAddress |
RD Data |
Wr Addr. |
WR Data |
Figure 5-3: Multiplexed address/data bus cycles.
120EMBEDDED CONTROLLER
Hardware Design
As soon as the address latch enable (ALE) is high, the address latch allows the multiplexed address from the address/data bus through to the latch output. When the ALE signal goes low, the address remains frozen on the latch output, and the CPU can remove the address lines from the bus and begin a data transfer.
The address latch must be a transparent latch with active high enable, such as the 74xx373 device. Figure 5-4 shows a typical arrangement. It is important to recognize that a transparent latch operates differently than a clocked register. As long as the ‘373 latch enable input is high, the latch Q output follows the D input. As soon as the latch enable goes inactive, the latch Q outputs freeze. This is analogous to the way a VCR allows a continuously changing signal show on the display until the pause button is pushed. This is in contrast with edge sensitive devices, such as the ‘374, which only updates the Q outputs at the rising edge of the clock. The ‘374 is analogous to a flash still camera, which
captures the input at the instant that |
||||||||
the flash occurs. If the ALE signal was |
CPU |
Transparent |
||||||
Latch |
||||||||
inverted, the ‘374 latch would sample |
ALE |
EN (e.g. '373) |
||||||
and hold the address at the end of the |
D0..15 |
Q0..15 |
Address Bus |
|||||
ALE pulse. While this could function |
||||||||
A0..15 |
||||||||
correctly, it would delay the availa |
Data Bus |
|||||||
bility of the address to the memory |
AD0..15 |
|||||||
D0..15 |
||||||||
devices, leaving less time for them |
||||||||
to access the addressed location.
Address Spaces and Decoding
Processors, depending upon the particular architecture, may have several separate address spaces, such as the following:
•program memory address space
•data memory address space
•input/output device address space
•stack address space
Depending on the processor, these may be completely separate, overlapping, or all-in-one address space. When these are separate spaces, the processor has separate control signals to indicate which address space is to be used for data transfer. This may be done with a separate signal line that goes active when a particular space is being addressed, such as a program fetch denoting that the
121CHAPTER FIVE
CPU Bus Interface and Timing
data should be transferred from a program memory address. The address space selection may also be performed using several status lines that, when decoded, define the appropriate transfer as in the case of the Intel 80x86 family. When there are separate address spaces, as in Harvard architecture CPUs like the 8051 family, there will be more than one unique location with
the same address. The status and control lines are needed to single out the appropriate location as shown in Figure 5-5.
I/O |
Some processors, such |
|||||||||||||
Transfer |
||||||||||||||
Data |
as those in the Motorola |
|||||||||||||
Transfer |
680x0 family, have a |
|||||||||||||
Program |
Data |
Input/Output |
||||||||||||
Program |
Memory |
Memory |
Devices |
single address space for |
||||||||||
Instruction |
Enable |
Enable |
Enable |
|||||||||||
Fetch |
Address |
Address |
Address |
all purposes, including |
||||||||||
Address |
Data |
Data |
Data |
I/O. Dedicating part of |
||||||||||
Bus |
the memory address |
|||||||||||||
Address |
space to I/O is referred |
|||||||||||||
Bus |
||||||||||||||
to as memory mapped |
||||||||||||||
Figure 5-5: Separate address spaces |
||||||||||||||
for program, data, and I/O. |
I/O. Even processors |
|||||||||||||
that have separate I/O instructions and address space may have some memory mapped I/O by dedicating some of the memory address space to I/O devices.
The various address lines and control lines are decoded to provide individual chip select signals for the various memories and I/O chips. This is the purpose of the address decoder. A standard n-line to 2n-line decoder is sometimes used to decode the address lines. A typical device is the 74LS138, a 3-to-8 line decoder that drives one of eight output lines low, depending on the three bit binary number on the input. For
example, with 16 address |
7 |
Eight EPROMs |
||||||||||||||||||||||||||||||||||||||||
8031 PSEN |
EN |
6 |
each 8K x 8 |
|||||||||||||||||||||||||||||||||||||||
lines there are 64K unique |
74LS138 |
5 |
||||||||||||||||||||||||||||||||||||||||
4 |
||||||||||||||||||||||||||||||||||||||||||
3:8 Decoder |
3 |
|||||||||||||||||||||||||||||||||||||||||
locations in a memory |
2 |
Enable |
||||||||||||||||||||||||||||||||||||||||
A13 |
A |
1 |
||||||||||||||||||||||||||||||||||||||||
0 |
Enable |
|||||||||||||||||||||||||||||||||||||||||
A14 |
B |
|||||||||||||||||||||||||||||||||||||||||
address space. This would |
Enable |
|||||||||||||||||||||||||||||||||||||||||
A15 |
C |
|||||||||||||||||||||||||||||||||||||||||
Enable |
||||||||||||||||||||||||||||||||||||||||||
require eight memory ICs |
||||||||||||||||||||||||||||||||||||||||||
3 |
Enable |
|||||||||||||||||||||||||||||||||||||||||
Enable |
||||||||||||||||||||||||||||||||||||||||||
if each one contains 8K |
A13 ..15 |
|||||||||||||||||||||||||||||||||||||||||
Enable |
||||||||||||||||||||||||||||||||||||||||||
EPROM 7 |
||||||||||||||||||||||||||||||||||||||||||
locations (64K locations |
Enable |
EPROM 6 |
||||||||||||||||||||||||||||||||||||||||
Eight |
EPROM 5 |
|||||||||||||||||||||||||||||||||||||||||
divided by 8K locations |
||||||||||||||||||||||||||||||||||||||||||
Program |
EPROM 4 |
|||||||||||||||||||||||||||||||||||||||||
EPROMs |
||||||||||||||||||||||||||||||||||||||||||
EPROM 3 |
||||||||||||||||||||||||||||||||||||||||||
per chip = 8 chips). By |
A0 .. |
12 |
||||||||||||||||||||||||||||||||||||||||
EPROM 2 |
||||||||||||||||||||||||||||||||||||||||||
connecting the three |
EPROM 1 |
|||||||||||||||||||||||||||||||||||||||||
EPROM 0 |
||||||||||||||||||||||||||||||||||||||||||
decoder inputs to the |
Address |
16 |
Figure 5-6: Address |
|||||||||||||||||||||||||||||||||||||||
most significant bits of |
A0 ..15 |
A0 ..15 |
||||||||||||||||||||||||||||||||||||||||
decoding example. |
||||||||||||||||||||||||||||||||||||||||||