Chapter One Interfacing 1111111
Chapter One Interfacing 1111111
1. Introduction
In this chapter microcomputer organization, different part of microcomputer and
operation, Microprocessor, Evolution of microprocessor, Microprocessors
Architecture and operation, ALU, Register Array, Instruction execution, Memory
array design and memory interfacing are discussed.
After completing this chapter, the students will be able to:
Differentiate Microprocessor and microcontroller
Explain memory array design
Differentiate Static and Dynamic RAM
Develop knowledge about microcomputer, microprocessor and memory
interfacing.
1.2. Microcomputer
Microcomputers &interfacing 1
these techniques required complex hardware consisting of Medium scale
integration devices making the design highly complex and time consuming.
Input Unit and Output Unit: Input and Output units are the means by which the
MPU communicates with the outside world. Input unit: keyboard, mouse, scanner
etc. Output unit: Monitor, printer etc. Bi-directional ports: Modem, Network etc.
I/O is responsible for interfacing between CPU and operators or external devices.
I/O includes any device that converts binary data in the computer into another form
of data that are used by human. Examples of I/O devices include monitors,
keyboards, printers, modems, hard disks, floppy disks, etc. Each computer system
may have many I/O ports. Each input port has a unique address and each output
port has a unique address. Some microprocessors assign the memory and I/O with
separate address space (e.g., Intel x86 processors). In this case, one may use
memory address X and also I/O address X the same time. Some microprocessors
make the memory and I/O use the same address space (e.g., Motorola 68HC12). In
this case, if memory uses address X, I/O cannot use address X.
Microcomputers &interfacing 2
1.3. Microprocessor Unit/ Central Processing Unit:
Microcomputers &interfacing 3
Memory is responsible for storing programs and the data that are needed by the
program. To make the concept clear, we divide the computer memory to processor
memory, main memory (or primary memory) and secondary memory.
Processor Memory refers to a set of CPU registers. These registers are useful to
hold temporary results when a computation is in progress. Also, there is no speed
disparity between the registers and the microprocessor because they are fabricated
using the same technology. The main disadvantage is the cost involved which
forces the architect to include very few registers (usually 8 to 16 only) in the
microprocessor.
The main memory is the memory that the CPU can access directly. Examples of
main memory include RAM, ROM, etc.
The secondary memory cannot be addressed directly (cannot access specified
memory location) by the CPU. Examples of secondary include floppy disk, hard
disk, CD, etc. The information in the secondary memory must be copied to the
main memory so that CPU can access it. Secondary memory is much cheaper than
primary memory.
Microcomputers &interfacing 4
amount of RAM, ROM and other peripherals all embedded on a single chip. At
times it is also termed as a mini computer or a computer on a single chip.
Microprocessor:
1. Do not have inbuilt RAM or ROM and timer.
2. Input and output ports are not available, requires extra device like 8255
3. Do not have inbuilt serial port, requires 8250 device.
4. Program and data are stored in same memory.
5. Less multifunction pins on IC.
6. Boolean operation is not possible directly
7. It takes many instructions to read and write data from external memory
Microcomputers &interfacing 5
3. Clock speed: Given in megahertz (MHz), the clock speed determines how many
instructions per second the processor can execute or we can say based on
Performance. Performance (in terms of speed, power consumption...)
In modern μPs(microprocessor), the best features from the different types is taken
to achieve the maximum performance.
4. Finally we can classify/differentiate based on Application type .In all cases, the
higher the value, the more powerful the CPU.
Microcomputers &interfacing 6
They were fabricated using PMOS technology which provided low cost, slow
speed and low output currents. It contained 2300 PMOS transistor.
Microcomputers &interfacing 7
Fifth Generation (1995 – till date)
This age the emphasis is on introducing chips that carry on-chip functionalities and
improvements in the speed of memory and I/O devices along with introduction of
64-bit microprocessors. Intel leads the show here with Pentium, Celeron and very
recently dual and quad core processors working with up to 3.5GHz speed.
1.8. Microprocessor Architecture
Its architecture consists of a central processing unit, memory modules, a system
bus, and an input/output unit. The system bus connects the various units to
facilitate the exchange of information. It further consists of data, address, and
control buses to perform data exchanging properly.
As there are a great many variations in architecture between the different kinds of
CPU/MPU, we shall begin my looking at a simplified model of the structure. The
simplified model consists of five parts, which are:
The part of the central processing unit that deals with operations such as addition,
subtraction and multiplication of integers and Boolean operations. It receives
control signals from the control unit telling it to carry out these operations. It works
Microcomputers &interfacing 8
in conjunction with the register array for many of these, in particular, the
accumulator and flag registers. The accumulator holds the results of operations,
while the flag register contains a number of individual bits that are used to store
information about the last operation carried out by the ALU.
Addition and subtraction: These two tasks are performed by constructs of logic
gates, such as half adders and full adders. While they may be termed 'adders', with
the aid of they can also perform subtraction via use of inverters and 'two's
complement' arithmetic.
Multiplication and division: In most modern processors, the multiplication and
division of integer values is handled by specific floating-point hardware within the
CPU. Earlier processors used either additional chips known as maths co-
processors, or used a completely different method to perform the task.
Logical tests: Further logic gates are used within the ALU to perform a number of
different logical tests, including seeing if an operation produces a result of zero.
Most of these logical tests are used to then change the values stored in the flag
register, so that they may be checked later by separate operations or instructions.
Others produce a result which is then stored, and used later in further processing.
Comparison: Comparison operations compare values in order to determine such
things as whether one number is greater than, less than or equal to another. These
operations can be performed by subtraction of one of the numbers from the other,
and as such can be handled by the aforementioned logic gates. However, it is not
strictly necessary for the result of the calculation to be stored in this instance; the
amount by which the values differ is not required. Instead, the appropriate status
Microcomputers &interfacing 9
flags in the flag register are set and checked to determine the result of the
operation.
Bit shifting: Shifting operations move bits left or right within a word, with
different operations filling the gaps created in different ways. This is accomplished
via the use of a shift register, which uses pulses from the clock within the control
unit to 10 trigger a chain reaction of movement across the bits that make up the
word. Again, this is a quite complicated logical procedure, and further reading may
aid your understanding.
This controls the movement of instructions in and out of the processor, and also
controls the operation of the ALU. It consists of a decoder, control logic circuits,
and a clock to ensure everything happens at the correct time. It is also responsible
for performing the instruction execution cycle. The three main elements of the
control unit are as follows:
Decoder: This is used to decode the instructions that make up a program when
they are being processed, and to determine in what actions must be taken in order
to process them. These decisions are normally taken by looking at the opcode of
the instruction, together with the addressing mode used.
Timer or clock: The timer or clock ensures that all processes and instructions are
carried out and completed at the right time. Pulses are sent to the other areas of the
CPU at regular intervals (related to the processor clock speed), and actions only
occur when a pulse is detected. This ensures that the actions themselves also occur
at these same regular intervals, meaning that the operations of the CPU are
synchronized.
Microcomputers &interfacing 10
Control logic circuits: The control logic circuits are used to create the control
signals themselves, which are then sent around the processor. These signals inform
the arithmetic and logic unit and the register array what they actions and steps they
should be performing, what data they should be using to perform said actions, and
what should be done with the results.
Program Counter (PC): This register is used to hold the memory address of the
next instruction that has to execute in a program. This is to ensure the CPU knows
at all times where it has reached, that is able to resume following an execution at
the correct point, and that the program is executed correctly.
Instruction Register (IR): This is used to hold the current instruction in the
processor while it is being decoded and executed, in order for the speed of the
whole execution process to be reduced. This is because the time needed to access
the instruction register is much less than continual checking of the memory
location itself.
Accumulator (A, or ACC): The accumulator is used to hold the result of
operations performed by the arithmetic and logic unit.
Memory Address Register (MAR): Used for storage of memory addresses,
usually the addresses involved in the instructions held in the instruction register.
The control unit then checks this register when needs to know which memory
address to check or obtain data from.
Microcomputers &interfacing 11
Memory Buffer Register (MBR): When an instruction or data is obtained from
the memory or elsewhere, it is first placed in the memory buffer register. The next
action to take is then determined and carried out, and the data is moved on to the
desired location.
Flag register / status flags: The flag register is specially designed to contain all
the appropriate 1-bit status flags, which are changed as a result of operations
involving the arithmetic and logic unit.
Other general purpose registers: These registers have no specific purpose, but
are generally used for the quick storage of pieces of data that are required later in
the program execution. In the model used here these are assigned the names A and
B, 12 with suffixes of L and U indicating the lower and upper sections of the
register respectively.
Control Bus: The control bus contains lines that select the memory or I/O and
cause them to perform a read or write operation. In most computer system, there
are four control bus connections: (Memory read control), (Memory Write control)
(I/O read control) ,(I/O write control) .
Data Bus: This is used for the exchange of data between the processor, memory
and peripherals, and is bi-directional so that it allows data flow in both directions
along the wires. Data bus may be 8 bits, 16 bits, 32 bits or 64 bits.
Microcomputers &interfacing 12
Address Bus: Address bus – carries memory addresses from the processor to other
components such as primary storage and input/output devices. .
Note: The 8086 has a combined address and data bus commonly referred as a time
multiplexed address and data bus. The main reason behind multiplexing address
and data over the same pins is the maximum utilization of processor pins and it
facilitates the use of 40 pin standard DIP package
1.8.5. Memory
The memory is not an actual part of the CPU itself, and is instead housed
elsewhere on the motherboard. However, it is here that the program being executed
is stored, and as such is a crucial part of the overall structure involved in program
execution.To execute an instruction–the processor must:
Instruction Fetch: Control unit collect the instructions from main memory and put
them in CPU register. This is called instruction fetch.
Instruction Decode: When instruction reaches in processor register, CU decodes
or interprets the instruction and sends necessary signals and data to ALU.
Instruction Execute: ALU process the data with arithmetic and logic operations
and gives a result according to instructions.
Microcomputers &interfacing 13
Store Result: Finally CU stores result in Accumulator or main memory. These
four steps to execute an instruction are called machine cycle.
Apple and SUN use RISC architecture Intel and AMD develop CISC
processors ,8086 microprocessor has
RISC architecture
Table 1.1: CISC and RISC architecture
Microcomputers &interfacing 14
Typically, CISC chips have a large amount of different and complex instructions.
The philosophy behind it is that hardware is always faster than software, therefore
one should make a powerful instruction set, which provides programmers with
assembly instructions to do a lot with short programs.
There is still considerable controversy among experts about which architecture is
better. Some say that RISC is cheaper and faster and therefor the architecture of the
future. Others note that by making the hardware simpler, RISC puts a greater
burden on the software. Software needs to become more complex. Software
developers need to write more lines for the same tasks. Therefore they argue that
RISC is not the architecture of the future, since conventional CISC chips are
becoming faster and cheaper anyway.
2. Interfacing
Interface is the path for communication between two components. Interfacing is of
two types, memory interfacing and I/O interfacing.
Microcomputers &interfacing 15
Figure 1. 4 : block diagram of memory and I/O interfacing
Microcomputers &interfacing 16
Non-volatile memory (ROM - read only memory EPROM, EEPROM,
FLASH)
(c) Secondary memory (Hard disks, CD, floppy disks, tape)
Processor Memory refers to a set of CPU registers. These registers are useful to
hold temporary results when a computation is in progress. Also, there is no speed
disparity between the registers and the microprocessor because they are fabricated
using the same technology. The main disadvantage is the cost involved which
forces the architect to include very few registers (usually 8 to 16 only) in the
microprocessor.
The primary memory or, main memory is the memory that the CPU can access
directly. Examples of main memory include RAM, ROM, etc.
Nonvolatile memory keeps the data in the memory even it is not powered up.
Nonvolatile memory includes read only memory (ROM).
Read Only Memory (ROM) is used to permanently save the program being
executed. The size of program that can be written depends on the size of this
memory. There are several types of ROM.
Microcomputers &interfacing 17
(i) Masked ROM (MROM) is a kind of ROM the content of which is programmed
by the manufacturer. The term ‘masked’ comes from the manufacturing process,
where regions of the chip are masked off before the process of photolithography.
In case of a large-scale production, the price is very low.
(ii) One time programmable ROM (OTP ROM) enables you to download a
program into it, but, as its name states, one time only. If an error is detected after
downloading, the only thing you can do is to download the correct program to
another chip.
(iii) UV Erasable Programmable ROM (UV EPROM) Both the manufacturing
process and characteristics of this memory are completely identical to OTP ROM.
It enables data to be erased under strong ultraviolet light. After a few minutes it is
possible to download a new program into it.
(iv) Flash Memory This type of memory was invented in the 80s in the laboratories
of INTEL and was represented as the successor to the UV EPROM. The content of
this memory can be written and cleared practically an unlimited number of times.
Flash memory can only be erased block (many bytes) by block.
(v) Electrically Erasable programmable ROM (EPROM) the contents of EEPROM
may be changed during operation (similar to RAM), but remains permanently
saved even after the loss of power (similar to ROM). EEPROM can be
programmed and erased byte by byte.
Random Access Memory (RAM): Information stored in random access memories
will be lost if the power is turned off. This property is known as volatility and
hence, RAMs are usually called volatile memories. RAM can be made of magnetic
core or by semiconductor. Semiconductor RAM’s are two types: Static RAM and
Dynamic RAM.
Microcomputers &interfacing 18
Static RAM: In a semiconductor memory constructed using bipolar transistors; the
information is stored in the form of voltage levels in flip-flops. These voltage
levels do not usually get drifted away. Such memories are called static RAMs
because stored information remains constant for some period of time. Since the
static RAM maintains information in active circuits, power is required even when
the chip is inactive or standby mode. Hence, static RAMs require large power
supplies. Also each static RAM cell is about four times larger in area than an
equivalent dynamic cell. Dynamic RAM: On the other hand, semiconductor
memories designed using MOS transistors, the information is held in the form of
electrical charges in capacitors. Here the stored charge has the tendency of get
leaked away. These memories are referred to as dynamic RAMs. In order to
prevent any information loss, dynamic RAMS have to be refreshed at regular
intervals. Refreshing means boosting the 18 signal level and writing it back. This
activity is performed using hardware unit termed as refresh logic.
Differences between static and dynamic RAMs:
Microcomputers &interfacing 19
2.4. Main Memory Array Design:
Microcomputers &interfacing 20
(0000 0000 0000 0000 0000 to 1111 1111 1111 1111 1111 B (Binary))
Note: 8086 has 20-bit address bus. So, it can addresses 1 MB memory.
Microcomputers &interfacing 21
(1) Partial or Linear Decoding.
(2) Absolute or Fully Decoding.
To realize the interconnecting technique first we should know about a small
memory block. Let us consider the block diagram of a typical RAM IC.
The capacity of this chip is 1Kbytes. They are organized in the form of 1024
words with 8 bits/word.
Each word has a unique address and is specified on 10-bit address lines A9 –
A0.
The inputs and outputs are routed through the 8-bit bidirectional data bus (D7–
D0). The operation of this chip is governed by two control inputs: (Write
Enable) and (Chip Select).
The following truth table describes the operation of this chip:
Microcomputers &interfacing 22
When CS is high, chip is not selected at all, hence D7 to D0 are driven to high
impedance state. When CS = 0 and WE = 0, data on lines D7 – D0 are written
into the word addressed by A0 through A9.
When CS = 0 and WE = 1, the contents of memory word whose address is on
A9 – A0 will appear on lines D7 – D0.
Now let us discuss linear decoding and fully decoding:
Microcomputers &interfacing 23
Figure1. 6 : Linear decoding
Microcomputers &interfacing 24
microprocessor used as common input to address lines of all memory chips. The
data lines of microprocessor are connected to data lines of all memory chips. The
remaining address lines (A10-A15) are used to select one of the chips ( ) at a
time. For example, 000001 selects chip1, 100000 selects chip 6 etc. from
microprocessor is connected to of all RAM Chips. This line select whether data
is writing to memory or reading from memory.
Advantage:- Linear decoding does not need any decoding circuit (Hardware).
Disadvantages:-
a) Although there is an address bus of 16-bits wide, we could connect only 6Kb of
RAM. This idea clearly wasted address space.
b) Address map is not contiguous. It is sparsely distributed.
c) Conflicts occur if two of the select lines (suppose A11 and A10) become active
at the same time.
d) If all unused address lines are not used as chip selectors, then these unused lines
become don’t cares. This results in fold back, meaning a memory location will
have its image in memory map. For example, if A15 is don’t care, then address
0000H is same as address 8000H. It wastes memory space.
Microcomputers &interfacing 25
First we have to write memory map to identify the address lines to be given to
decoderlogic. There are many advantages in absolute address decoding.
1. Each memory location has only one address; there is no duplication in the
address.
2. Memory can be placed contiguously in the address space of the microprocessor.
3. Future expansion can be made easily without disturb ing the existing circuitry
Table 1. 2 : memory map for address lines memory map for address lines
If we observe A10 and A11, 2-to-4 decoder would be an obvious choice for CS
signals. We can write the truth table as follows:
Microcomputers &interfacing 26
Figure 1.7: Fully Decoding
Microcomputers &interfacing 27