Processor Architecture and Basics
Processor Architecture and Basics
CHAPTER
OBJECTIVES
Processor Basics
5.1 INTRODUCTION
We have already discussed in Chapter 1that processor or
the heart of any computer. This had been valid starting from microprocessor or central processing unit (CPU)=
the time of ISA machine by Von Neumann (S
tion 1.2.2). Modern processors are mostly single-chip devices
tasks assigned to them. However, depending upon the capable of overseeing and executing all relak
in their details. In this chapter, we shall manufacturer and the model. there is a wide variati
take a closer look at these processors in
about three popular and vintage processors (8085, general, and then diseu
advanced processors (80386 and Pentium 4). We are 8086 and 8051). Finally, we shall also consider two
are the products from Intel. restricting our discussions within those processosu
Details of afew more advanced
processors are presented in the appendices.
5.2
PROCESSOR
Externally, any processor is a ARCHITECTURE AND ORGANIZATIO
pins attached with this ceramic or plastic package several meeta
receive power supply
(integrated
package. These pins are provided to circuit or IC) with Signalsat
of these pins,
their requirements for the processor. communicate different types of ofen
well as time-wise signal names and Manufacturer' s the details
data sheets givecharacteristies)
(known as AC characteristics, both electrical (known as DC
characteristics).
Processor Basics 95
62.1 InternalArchitecture
sgeneral internal
architecture of any proccssor is
logic unit (ALU), which performs all arithmetic and shown Figure 5.1. Apart from the arithmetic
in
general purpose registers for various storage and logical operations, cvery processor offers a set of
different arithmetic and logical operations, which opcrations, Its status register accommodates the status
program counter holds the address of next
might be necessary for conditional
branching Its
otack pointer indicates the address of the instruction word to be fetched from external rnernory. The
stack-top, which we shall discuss a little latet.
General purpose
registers Data bus
Control
ALU
unit Control bus bus
System
and
Oscillator
Timings
Status register
Stack pointer
ProcesSor
Figure 5.1 General internal architecture of a
processor
Two more architectural features of any processor are indicated in Figure 5.1. They are
and, oscillator and timing module. The control control unit
unit is responsible for generating all control signals
general working of the processor. This is achieved by the and
which is maintained by the oscillator unit. instructions with the help of internal clock,
DC + V power in
Vcc
0R
Clock Address Address signals to memory and /Odevices
S
Reset S Data Data signals from/to memory and /Odevices
CE
Memory Device
Data
Data
processor
lines Data
from Data
select
signals Data
Location Data
n to 2
Address Data
Decoder
gn Data
Data
-
n Data
Data
Data
Data
(8-bits) and at the input and output of each flip-lop. tri-state buffers are provided, whose contro
are connected in parallel. The location-select signal from the decoder within the memorye ( in
The clock signal acts
Figure 5,4) along with memory read or memory write signal cnablc thesC buffers.
in conjunction with memory write and selectsignals for the storage operation.
DO
DO D O
FIF
D1
D1
F/F
D2
D2 DO
F/F
D3
D3 D
F/F
D4
DQ
D4
F/F
D5
D5 D Q
F/F
Clock
Memory read
In Figure 5.5, the reader should note that although separate lines indicate input-to and output-from
the tri-state buffers, the designation for any pair of buffers is the same, i.e., either both are D0 or both
are DI.Externally, these data line pairs are connected together to form abus of 8data lines, i.e, D0-D.
5.2.6 Control Bus
Number and functions of control signals, constituting the control bus varies widely with the processoris
However, two of its important signals are READ and WRTE. Condition of these control signals inae
whether the present operation, intended by the processor is expecting the data in (READ) or sendingth
data out (WRITE). As the processor is to interact with two types of devices, memory and VO, in generd
th
four read/write signals are offered, as shown in Figure 5.3. Afew status signals are also available from
name
processor, apart from power input signals. Two more input signals are essential for all processors,
processos
clock and reset. Apart from these, afew external interrupt input all
The purpose of all these signals is to execute any signals are also pprovided in ofindivid1s
program. The programs are composed during
instructions. shall now discuss how this program execution is
We processor
its operational stage. implemented bythe
Processor Basics 99
itr
6.3 PROCESSOR OPERATION
os mentioned in the Section 5.2, the job of the processor is to execute programs, which are
composed of multiple instructions. At this point, we should remember that instructions cxecutable by
eprocessor, are always in the machine code. Programs devcloped with high level Welanguage
instructions are first changed to this machine code, understandable by thc processor.
(HLL)
shall elaborate
his point further in Chapter l1, where we would discuss about operating system. At present, we should
knowthat, in general, these machine code instructions are extremely primitive and simple, cg.
nCopya data byte from external memory to internal register or vice versa.
n Add two numbers available within the processor registers.
nIfthe result of subtraction is zero, then skip next three (or three thousand three hundred thirty
three)instructions.
These instructions must be present in binary form within the memory of the system.
5.3.1 Instruction Cycle
To execute any type of instruction including those that are cited above, the processor should perform
the following steps
DFetch
ODecode
DExecute.
Combination of these three steps is known as an instruction cycle. A flowchart of simplified form of
instruction cycle for a generic processor is shown in Figure 5.6.
Instruction
fetch
Instruction
decode
No
Instruction
execute
Store
result
It may be observed from the flowchart that after fetching the instruction in the forrm of its opcode and
decoding it, the processor checksfor any eventual operand fetch, which might be nccessary for some (not tor
all) instructions. If found necessary, then the operand is fetched from memory and then the instruction 1s exe
cuted. Finally, the result of the instruction is stored and the whole cycle is repeated. At this point, the reader
may ask aquestion why this is designated as asimplified instruction cycle? The answer is, we are avoding
many other details related with the instruction cycle, e.g.,checking for any interrupt signal or looking tor any
direct memory access (DMA) request and so on. At a later stage, we shall consider all these details of the
instruction cycle.We shall now discuSS about the details of these three stages and some more related aspects,.
5.3.2 Instruction Fetch
The first step, as indicated before,is to fetch the instruction byte(s) from external memory. lhis external
memory is avast area containing many bytes of instructions. Therefore, the processor must pin-poitE
the correct location of this large memory area to extract the target byte.
It was already indicated that every memory location (byte in majority of cases) has a unique binary
address (refer Figure 5.4). After receiving this address, the duty of the memory device is to decode the
address to locate the target byte and place it on the data bus, so that the content of that address is avai.
able for the processor (Figure 5.5).
Address from prOcessor
(multiple bits) Content of address bus
X
Memory READ signal from processor
(active low)
Data from memory device to processor
(multiple bits) Content of daa bus
Processor reads from data bus at this instant of time
Figure 5.7 Timing diagram for instruction fetch
Therefore, for the purpose of instruction fetch, the processor places an
binary information, on the address bus. address, composed of multiplebis
its control bus. When these signals reach Simultaneously, processor also sends a memory read signal thu
the
the memory device, the data are sent to the
bythe memory device.
Schematically, this transaction is depicted in Figure 5.7, processor automatacs
gram. Observe from Figure 5.7 that data must be which is
to high. Address signals, valid (stable) when the memory read known as timingt
generated by the signal goes fron
One question may arise here that processor, are stable at this stage to ensure a valid data trans
control bus,the correct device would pay how, out of so many devices
attention to the
interfaced with address, dat
would
<000,remain silent? The answer is, every device has a processor's demand and that the other
chip select input
(generally, designaleu as
KHOU
Generally, for active
low signals, the
to high. In the
case of active high transactions are carried out when it switches fromlow
signals, the process occurs at the time when the signal
switches from high to low. The reader
may verify these from
different timing diagrams.
Processor Basics 101
Cand if this input is not activated, the device does not react with the system bus
communications.
Using a part of the address lines and a suitable decoder (we have studied this in Chapter 3), the proces-
ofivates only one device during any communication and that solves the problem. This technique is
nas address decoding and deviceselection. A processor is assisted with a memory decoder andan
Odecoder to target the correct device, which is of current interest.
5.3.3 Instruction Decode
Afer receiving the instruction code bytewithin itself, the processor becomes busy in understanding it
(what to do?). This part is known as instruction decode, carried out within the processor itself. After
the completion of instruction decoding, the processor knows whether to fetch operands from external
memory or to increment a register by one or tostore aregister content in external memory location.
This instruction decoding may be implemented through hardware, in somewhat a similar way as we
have implemented it in Solved Example 3.3 of Chapter 3 (ALUdesign problem). Instruction decoding
may also be implemented through software, known as micro-programming. This demands a miniature
processor within the processor itself, completely devoted for instruction decoding and its execution. We
shall discuss more about this aspect in Chapters 9 and 10.
5.3.4 Instruction Execute
This is the last and final phase of an instruction's execution. Depending upon the instruction, one or
several operations are implemented by the processor. Once this part is complete, the processor looks
forward for the next instruction fetch-decode-execute, and the process continues.
5.3.5 Machine Cycle and T-states
An instruction cycle has one or more machine cycles and every machine cycle is composed of several
T-states. These points need some elaboration.
A machine cycle is the step or time-slice during which l1-byte (or one word) of data are transacted
between the processor and some external device. Generally, this external device is the memory device.
However, in exceptional cases it might be an I/O device also. To transact 1-byte of information, one
machine cycle must be executed by the processor. In Figure 5.7, we have illustrated such a machine
cycle. Note, that instead of reading, it might be a writing operation also.
Each machine cycle is composed of several T-states. One complete oscillation of the processor clock is
designated as one T-state. Depending upon the processor, the number of T-states necessary tocomplete one
machine cycle must be known. For example, Intel 8085 processor needs four to six T-states to complete
one machine cycle. The correlation ofT-states, machine cycle and instruction cycle is shown in Figure 5.8.
For the sake of example, execution of an instruction increment a memory location by one is illustrated
through Figure 5.8.It is assumed that it is a 1-byte instruction, which is fetched by the first machine cycle.
As the data, to be incremented by one, are available in external memory location, the next machine cycle
eads this operand from memory (brings the data byte within the processor). The data are then incremented
Oy one by the processor and are stored back in the same memory location in the third machine cycle.
Two questions may arise after this explanation of Figure S.8, as follows
) When the instruction was decoded?
(1) When the data were incremented by one?
aswer the first question, it must be pointed out that the instruction must be decoded before the beginning of
G Second machine cycle, as the processor must know by that timne what to do. As a
rule, instruction deoaing
102 Computer Architecture and Organization
System clock
One
T-state
accessi1ble (programmer)
registers varies from processor accessible
to processor.
and a few thatat
processors
Those
Processor Basics 103
Instruction
fetch
Instruction
decode
Operand Yes
fetch Fetch
needed operand
No
Instruction
execute
Store
result
Any Yes
interrupt Load PC by
ISR address
No
Figure 5.9 Modified flowchart for simplified
instruction cycle
memory oriented (e.g., Motorola 6800) offers lesser number of internal
operands would mainly be stored and manipulated within the read/writeregisters as it expects the data or
On the other hand, some processors are register oriented (e.g., memory (RAM) of the system.
of internal registers for the user. It may be noted that the
Zilog Z80), which offers a larger number
be less if the data are available within itself rather than program execution time for a processor would
looking outside for them. However, more inter
nal registers means more complexity in instruction decoding as
each register would demand aseparate
instruction to be provided by the instruction set of the processor.
So far, we have been discussing about the general purpose
are also available within the processors. They are registers. However, other types of registers
accumulator or result register, status register, stack
pointer, program counter, interrupt register and so on. Most of these registers, in most
be user accessible.Apart from these, there aresome processors, would
registers that are purely for processor's own use, e.g.,
temporary registers. We shall now have a brief discussion about someof these special purpose
registers.
5.4.1 Status Register
EVery processor performs some arithmetic or logical operations generating some results.
upon whether the result is zero or negative or produced a carry or odd/even parity, some Depending
additional
dcions might have to be taken by the programmer. Status register solves this problem by offering the
esult status of the last performed arithmetic or logical operation through its pre-assigned bits. Gener
YCach bit of this status register is assigned for one particular indication, e.g.,carry, parity, zero,
Ovetiow and so on. These bits act as flags and their conditions (true or false) help the program to delde
urther course of actions and dictate the conditional program branching.
104 Computer Architecture and Organization
5.4.2 Accumulator
availahle ofnty in the
macke
In carlicr proccssots, fcsult of all atithmetic ot logical petatints weteregrstets 4v1lable wifhit fhe
accumulatot. In morc tecent rgister tn-rgister atchitecture, all relev ant
proccssor may contain thc result of similar opcrations
5.4.3 Program Counter responsible for hold1tg the
within any processot as it is proceNsor
This is onc of the most important registerS fetched hy the Afer
word to be
address of the memory location for next instruction byte to pont to the nEt byte The
by one
fetching every instruction byte, this is automatically incremented is in the case of program bratch1ng
counter
only exception for this auto-increment of the program initialized during systemreset so that the firs
when it is reloaded by a new value. This counter is always
location of the memory.
executable instruction byte is fetched from a pre-defined
5.4.4 Stack Pointer mtor
is earmarked by the programmer to accommodate inportant
System stack is a RAM area, which Stack pointer
mation, e.g., return address or register values, in last-in-first-out(LIFO) sequence. Section
in
alwzs
S.5.
about the system stack
points to the top of the stack area. We shall discuss more
FFFOH
FFF1H FFFOH
FFF1H
FFF2H Free FFF2H
FFF3H
FFF4H FFF3H
Stack
area FFF4H
FFF5H FFF5H Stack
area
FFF6H
FFF6H
FFF7H
FFF7H
FFF8H
Stack-top FFF9H Stack-top FFF8H
FFFAH
kOccupied Data saved here FFF9H
+Occupied
FFFAH
FFFBH FFFBH
FFF9 FFFCH FFFCH
FFFDH FFF8
Stack pointer (SP) FFFDH
FFFEH Stack pointer (SP) FFFEH
FFFFH
(updated) FFFFH
(a) (b)
Eigure 5.10 Stack and its operation
from the stack-top. These data might be originally available within a general purpose register or some
other data. It is already mentioned that the register within the processor, which holds the curTent stack
top address, is designated as stack pointer (SP). Whenever any data are placed on the stack-top or taken
out from it, SP is also automatically changed by the processor itself. Here, we use the term 'changed
as, for some processorS, a PUSH operation increments the SP while for other processors the SP is dec
remented for aPUSH instruction.