Computer Organisation and Architecture.
Computer Organisation and Architecture.
Course Outcome
1
Topics Covered
3
FUNCTIONAL UNITS OF COMPUTER
• Input Unit
• Output Unit
• Central Processing Unit (ALU and Control Units)
• Memory
• Bus Structure
4
5
Functions
• ALL computer functions are:
– Data PROCESSING
– Data STORAGE Data = Information
– Data MOVEMENT
Coordinates How
– CONTROL
Information is Used
6
Functions of a computer
The operations performed by a computer using the functional
units can be summarized as follows:
• It accepts information (program and data) through input unit
and transfers it to the memory.
• Information stored in the memory is fetched, under program
control, into an arithmetic and logic unit for processing.
• Processed information leaves the computer through an
output unit.
• The control unit controls all activities taking place inside a
computer.
7
8
INPUT UNIT:
OUTPUT UNIT:
R2
11
Example
Add R1, R2
T1 Enable R1
T2 Enable R2
T3
Enable ALU for addition operation
T4
Enable out put of ALU to store result of the
operation
12
MEMORY UNIT
•Two types are RAM or R/W memory and ROM read only memory
•ROM is used to store data and program which is not going to change.
13
Basic Operational Concepts
14
Review
• Activity in a computer is governed by instructions.
• To perform a task, an appropriate program consisting of a
list of instructions is stored in the memory.
• Individual instructions are brought from the memory into
the processor, which executes the specified operations.
• Data to be used as operands are also stored in the
memory.
15
A Typical Instruction
Add R0, LOCA
• Add the operand at memory location LOCA to the
operand in a register R0 in the processor.
• Place the sum into register R0.
• The original contents of LOCA are preserved.
• The original contents of R0 is overwritten.
• Instruction is fetched from the memory into the
processor – the operand at LOCA is fetched and added to
the contents of R0 – the resulting sum is stored in
register R0.
16
17
Registers
Registers are fast stand-alone storage locations that hold
data temporarily. Multiple registers are needed to facilitate
the operation of the CPU. Some of these registers are
Two registers-MAR (Memory Address Register) and MDR (Memory
Data Register) : To handle the data transfer between main memory
and processor. MAR-Holds addresses, MDR-Holds data
Instruction register (IR) : Hold the Instructions that is currently
being executed
Program counter (PC) : Points to the next instructions that is to be
fetched from memory
General-purpose Registers: are used for holding data, intermediate
results of operations. They are also known as scratch-pad registers.18
19
INSTRUCTION FETCH – STEPS INVOLVED
• Program gets into the memory through an input
device.
• Execution of a program starts by setting the PC to
point to the first instruction of the program.
• The contents of PC are transferred to the MAR and a
Read control signal is sent to the memory.
• The addressed word (here it is the first instruction of
the program) is read out of memory and loaded into
the MDR.
• The contents of MDR are transferred to the IR for
instruction decoding 20
INSTRUCTION EXECUTION – STEPS IVOLVED
• The operation field of the instruction in IR is examined to
determine the type of operation to be performed by the
ALU.
• The specified operation is performed by obtaining the
operand(s) from the memory locations or from GP
registers.
1) Fetching the operands from the memory requires
sending the memory location address to the MAR and
initiating a Read cycle.
2) The operand is read from the memory into the MDR
and then from MDR to the ALU.
21
INSTRUCTION EXECUTION – STEPS IVOLVED
(Contd..)
3) The ALU performs the desired operation on one or
more operands 13 fetched in this manner and sends the
result either to memory location or to a GP register.
4) The result is sent to MDR and the address of the
location where the result is to be stored is sent to MAR
and Write cycle is initiated.
Thus, the execute cycle ends for the current instruction
and the PC is incremented to point to the next
instruction for a new fetch cycle.
22
Interrupt
• An interrupt is a request from I/O device for
service by processor
• Processor provides requested service by
executing interrupt service routine (ISR)
• Contents of PC, general registers, and some
control information are stored in memory .
• When ISR completed, processor restored, so
that interrupted program may continue
23
BUS STRUCTURE
Connecting CPU and memory
26
TWO BUS STRUCTURE:
•In two – bus structure : One bus can be used to fetch
instruction other can be used to fetch data, required for
execution. The bus is said to perform two distinct functions
The main advantage of this structure is good operating speed
but on account of more cost.
27
MULTI BUS STRUCTURE
To improve performance multi bus structure can be used.
CONTROL BUS A2 A1 A0 Selected
location
0 0 0 0th Location
0 0 1 1st Location
0 1 0
W/R 0 1 1
CS RD
A0 PROCESSOR
1 0 0
A1 1 0 1
A2
1 1 0
ADDRESS BUS
1 1 1
D7 D0
D0 D7
DATA BUS
28
•23 = 8 i.e. 3 address line is required to select 8 location
29
Figure below shows address, data and control bus and their connection with
peripheral and microprocessor
30
Memory Locations and
Addresses
31
Memory Location and Addresses
nbits
• Memory consists of many first word
millions of storage cells, second word
each of which can store 1
bit.
•
• Data is usually accessed in n- •
•
bit groups. n is called word ith word
length.
• The memory of a computer •
can be schematically •
•
represented as a collection last word
of words as shown in Figure Figure 1 Main Memory words.
1. 32
MEMORY LOCATIONS AND ADDRESSES
•Main memory is the second major subsystem in a computer. It
consists of a collection of storage locations, each with a unique
identifier, called an address.
34
Address space
35
Memory addresses are defined using unsigned
binary integers.
36
Example 1
Example 2
A computer has 128 MB of memory. Each word in this computer is
eight bytes. How many bits are needed to address any single word in
memory?
Solution
The memory address space is 128 MB, which means 227. However,
each word is eight (23) bytes, which means that we have 224 words. This
means that we need log2 224, or 24 bits, to address each word. 37
MEMORY OPERATIONS
• Today, general-purpose computers use a set of instructions called a
program to process data.
• 8000 54
• 8001 96
• 8002
78
• 8003
• 8004 46
| 41
Big Endian
• Big Endian (e.g., in IBM, Motorolla, Sun, HP)
» high order byte stored at lowest address
» byte3 byte2 byte1 byte0
0 0 1 2 3 0 3 2 1 0
4 4 5 6 7 4 7 6 5 4
• •
• •
• •
k k k k k k k k k k
2 -4 2 -4 2 -3 2- 2 2 - 1 2 - 4 2- 1 2 - 2 2 -3 2 -4
45
Introduction
46
Types of Instructions
• Most computer instructions are classified into
3 categories
– Data transfer Instructions
To Transfer data from one location to another
– Data Manipulation Instructions
To perform the operations by the ALU
– Program control Instructions
To control the system
47
Data transfer Instructions
48
Data Manipulation Instructions
• Three categories:
– Arithmetic Instructions
– Logical and bit manipulation instructions
– Shift instructions
49
Arithmetic Instructions
Used to perform arithmetic operations
Some instruction in 8086
INC Increment the data by 1
DEC Decreases data by 1
ADD perform sum of data
ADC Add with carry bit.
MUL perform multiplication
50
Logical and bit manipulation instructions
54
Zero Address Instructions
55
Example: Evaluate (A+B) (C+D)
57
Two Address Instruction
This is common in commercial computers.
Here two address can be specified in the instruction.
61
3. Read the Effective Address
If the instruction has an indirect address, the effective address
is read from the memory. Otherwise operands are directly read
in case of immediate operand instruction.
62
start
Load address to PC
Load content of PC to IR
Execute Instruction
63
Interrupts Service Interrupt
Addressing Modes
65
Direct Addressing
• Address field contains address of operand
• Effective address (EA) = address field (A)
• e.g. ADD A
– Add contents of cell A to accumulator
– Look in memory at address A for operand
• Single memory reference to access data
• No additional calculations to work out effective address
• Limited address space
66
67
Indirect Addressing (1)
• Memory cell pointed to by address field contains
the address of (pointer to) the operand
Two references to memory are required to fetch
the operand.
• Effective Address = [A]
– Look in A, find address (A) and look there for operand
• e.g. ADD (A)
– Add contents of cell pointed to by contents of A to
the accumulator
68
69
Register Direct Addressing
In this addressing mode,
• The operand is contained in a register set.
• The address field of the instruction refers to a CPU register that
contains the operand.
• No memory access
• Very fast execution
• Very limited address space
• Limited number of registers
• Very small address field needed
– Shorter instructions
– Faster instruction fetch
70
Eg:
ADD R will increment the value stored in the
accumulator by the content of register R.
AC ← AC + [R]
• This addressing mode is similar to direct
addressing mode.
• The only difference is address field of the
instruction refers to a CPU register instead of
main memory.
71
72
Register Indirect Addressing
• The address field of the instruction refers to a
CPU register that contains the effective address
of the operand.
• Only one reference to memory is required to
fetch the operand
Eg:
ADD R will increment the value stored in the
accumulator by the content of memory location
specified in register R.
AC ← AC + [[R]] 73
74
Indexed Addressing
Effective Address
= Content of Index Register +
Address part of the instruction
75
76
Relative Addressing
84
85
Internal structure and basic operation of microprocessor
Address bus
ALU Register
Section
Data bus
87
Microprocessor types
• Microprocessors can be characterized based on
– the word size
• 8 bit, 16 bit, 32 bit, etc. processors
– Instruction set structure
• RISC (Reduced Instruction Set Computer), CISC (Complex
Instruction Set Computer)
– Functions
• General purpose, special purpose such image processing,
floating point calculations
– And more …
88
Evolution of Microprocessors
• The first microprocessor was introduced in 1971 by Intel Corp.
• It was named Intel 4004 as it was a 4 bit processor.
89
Second Generation (8 - bit Microprocessor)
• The second generation microprocessors were
introduced in 1973 again by Intel.
• the first 8 - bit microprocessor which could perform
arithmetic and logic operations on 8-bit words.
Third Generation (16 - bit Microprocessor)
• introduced in 1978
• represented by Intel's 8086, Zilog Z800 and 80286,
• 16 - bit processors with a performance like
minicomputers.
90
Fourth Generation (32 - bit Microprocessors)
• Several different companies introduced the 32-bit microprocessors
• the most popular one is the Intel 80386
91
Typical microprocessors
• Most commonly used
– 68K
• Motorola
– x86
• Intel
– IA-64
• Intel
– MIPS
• Microprocessor without interlocked pipeline stages
– ARM
• Advanced RISC Machine
– PowerPC
• Apple-IBM-Motorola alliance
– Atmel AVR
• A brief summary will be given later
92
8086 Microprocessor
• designed by Intel in 1976
• 16-bit Microprocessor having
• 20 address lines
• 16 data lines
• provides up to 1MB storage
• consists of powerful instruction set, which provides operations like
multiplication and division easily.
supports two modes of operation
Maximum mode :
suitable for system having multiple processors
Minimum mode :
suitable for system having a single processor.
93
Features of 8086
• Has an instruction queue, which is capable of
storing six instruction bytes
• First 16-bit processor having
– 16-bit ALU
– 16-bit registers
– internal data bus
– 16-bit external data bus
94
uses two stages of pipelining
1. Fetch Stage and
2. Execute Stage
which improves performance.
Fetch stage : can pre-fetch up to 6 bytes of
instructions and stores them in the queue.
Execute stage : executes these instructions.
95
Architecture of 8086
96
Segments in 8086
memory is divided into various sections called
segments
97
General purpose registers
used to store temporary data within the microprocessor
AX – Accumulator
16 bit register
divided into two 8-bit registers AH and AL to
perform 8-bit instructions also
generally used for arithmetical and logical
instructions
BX – Base register
16 bit register
divided into two 8-bit registers BH and BL to
perform 8-bit instructions also
Used to store the value of the offset.
98
CX – Counter register
16 bit register
divided into two 8-bit registers CH and CL to
perform 8-bit instructions also
Used in looping and rotation
DX – Data register
16 bit register
divided into two 8-bit registers DH and DL to
perform 8-bit instructions also
Used in multiplication an input/output port addressing
99
Pointers and Index Registers
SP – Stack pointer
16 bit register
points to the topmost item of the stack
If the stack is empty the stack pointer will be (FFFE)H
It’s offset address relative to stack segment
BP –Base pointer
16 bit register
used in accessing parameters passed by the stack
It’s offset address relative to stack segment
100
SI – Source index register
16 bit register
used in the pointer addressing of data and
as a source in some string related operations
It’s offset is relative to data segment
DI – Destination index register
16 bit register
used in the pointer addressing of data and
as a destination in string related operations
It’s offset is relative to extra segment.
101
IP - Instruction Pointer
16 bit register
stores the address of the next instruction
to be executed
also acts as an offset for CS register.
102
Segment Registers
CS - Code Segment Register:
user cannot modify the content of these registers
Only the microprocessor's compiler can do this
DS - Data Segment Register:
The user can modify the content of the data segment.
SS - Stack Segment Registers:
used to store the information about the memory segment.
operations of the SS are mainly Push and Pop.
ES - Extra Segment Register:
By default, the control of the compiler remains in the DS where the
user can add and modify the instructions
If there is less space in that segment, then ES is used
Also used for copying purpose.
103
Flag or Status Register
• 16-bit register
• contains 9 flags
• remaining 7 bits are idle in this register
• These flags tell about the status of the
processor after any arithmetic or logical
operation
• IF the flag value is 1, the flag is set, and if it is
0, it is said to be reset.
104
Microcomputer
Block Diagram
• A digital computer with one
microprocessor which acts as a
CPU
• A complete computer on a
small scale, designed for use by
one person at a time
• called a personal computer
(PC)
• a device based on a single-chip
microprocessor
• includes laptops and desktops
105
Introduction to 8086 Assembly
Language
106
Program Statements
• Program consist of statement, one per line.
107
Program Statements
• An example of an instruction is
START: MOV CX,5 ; initialize counter
name operation operand(s) comment
The name field consists of the label START:
The operation is MOV, the operands are CX and 5
And the comment is ; initialize counter
111
Program Statements
112
Program Data and Storage
• Pseudo-ops to define • These directives require
data or reserve storage one or more operands
– DB - byte(s) – define memory contents
– DW - word(s) – specify amount of
– DD - doubleword(s) storage to reserve for
– DQ - quadword(s) run-time data
– DT - tenbyte(s)
113
Defining Data
• Numeric data values • A list of values may be
– 100 - decimal used - the following
– 100B - binary creates 4 consecutive
– 100H - hexadecimal words
– '100' - ASCII DW 40CH,10B,-13,0
– "100" - ASCII • A ? represents an
• Use the appropriate uninitialized storage
DEFINE directive (byte, location
word, etc.) DB 255,?,-128,'X'
114
Naming Storage Locations
• Names can be • ANum refers to a byte
associated with storage storage location,
locations initialized to FCh
ANum DB -4 • The next word has no
DW 17 associated name
ONE
UNO DW 1
• ONE and UNO refer to
X DD ? the same word
• These names are called • X is an unitialized
variables doubleword
115
• Multiple definitions can be abbreviated
Example:
message DB ’B’
DB ’y’
DB ’e’
DB 0DH
DB 0AH
can be written as
message DB ’B’,’y’,’e’,0DH,0AH
• More compactly as
message DB ’Bye’,0DH,0AH
116
Arrays
• Any consecutive storage locations of the same
size can be called an array
X DW 40CH,10B,-13,0
Y DB 'This is an array'
Z DD -109236, FFFFFFFFH, -1, 100B
• Components of X are at X, X+2, X+4, X+6
• Components of Y are at Y, Y+1, …, Y+15
• Components of Z are at Z, Z+4, Z+8, Z+12
117
DUP
120
Word Storage
121
Named Constants
• Symbolic names associated with storage locations
represent addresses
• Named constants are symbols created to represent
specific values determined by an expression
• Named constants can be numeric or string
• Some named constants can be redefined
• No storage is allocated for these values
122
Equal Sign Directive
• name = expression
– expression must be numeric
– these symbols may be redefined at any time
maxint = 7FFFh
count = 1
DW count
count = count * 2
DW count
123
EQU Directive
• name EQU expression
– expression can be string or numeric
– Use < and > to specify a string EQU
– these symbols cannot be redefined later in the
program
sample EQU 7Fh
aString EQU <1.234>
message EQU <This is a message>
124
Data Transfer Instructions
• MOV target, source • reg can be any non-
– reg, reg segment register except
– mem, reg IP cannot be the target
– reg, mem register
– mem, immed • MOV's between a
– reg, immed segment register and
• Sizes of both operands memory or a 16-bit
must be the same register are possible
125
Sample MOV Instructions
b db 4Fh • When a variable is created with a
w dw 2048 define directive, it is assigned a
default size attribute (byte, word,
mov bl,dh etc)
mov ax,w • You can assign a size attribute using
mov ch,b LABEL
mov al,255 LoByte LABEL BYTE
mov w,-100 aWord DW 97F2h
mov b,0
126
Program Segment Structure
• Data Segments • Stack Segment
– Storage for variables – used to set aside storage
– Variable addresses are for the stack
computed as offsets – Stack addresses are
from start of this computed as offsets into
segment this segment
• Code Segment • Segment directives
– contains executable .data
instructions .code
.stack size
127
Instruction types
8086 instruction set Data transfer instructions
IN Input byte or word from port
LAHF Load AH from flags
LDS Load pointer using data segment Additional 80386 instructions
LEA Load effective address LFS Load pointer using FS
LES Load pointer using extra segment LGS Load pointer using GS
MOV Move to/from register/memory LSS Load pointer using SS
OUT Output byte or word to port MOVSX Move with sign extended
POP Pop word off stack MOVZX Move with zero extended
POPF Pop flags off stack POPAD Pop all double (32 bit) registers
PUSH Push word onto stack POPD Pop double register
PUSHF Push flags onto stack POPFD Pop double flag register
SAHF Store AH into flags PUSHAD Push all double registers
XCHG Exchange byte or word PUSHD Push double register
XLATTranslate byte PUSHFD Push double flag register
130
String instructions
8086 instruction set
CMPS Compare byte or word string
LODS Load byte or word string
MOVS Move byte or word string
MOVSB(MOVSW) Move byte string (word string)
REP Repeat
REPE (REPZ) Repeat while equal (zero)
REPNE (REPNZ) Repeat while not equal (not zero)
SCAS Scan byte or word string
STOS Store byte or word string
131
Program Skeleton
.model small • Select a memory model
.stack 100H • Define the stack size
.data • Declare variables
;declarations
.code
• Write code
main proc
– organize into procedures
;code
• Mark the end of the
main endp
source file
;other procs – optionally, define the entry
end main point
132
EXAMPLE : Adding two 8 bit numbers
134
ARM Ltd
• Founded in November 1990
136
ARM Powered Products
137
Data Sizes and Instruction Sets
• The ARM is a 32-bit architecture.
138
Processor Modes
• The ARM has seven basic operating modes:
– System : privileged mode using the same registers as user mode 139
The ARM Register Set
Current Visible Registers
SVC
Undef
IRQ
FIQ
User Current
Mode
Mode
Mode
Mode
Mode Visible
r0 Registers
r1
r0
Abort Mode r2
r1
r3
r2
Banked out Registers
r4
r3
r5 Banked out Registers
r4
r6 User FIQ IRQ SVC Undef Abort
r5
r7
r6
r8
User
r8
FIQ
r8
IRQ SVC Undef
r7
r9 r9 r9
r8 r8
r10 r10 r10
r9 r9
r11 r11 r11
r10 r10
r12 r12 r12
r11 r11
r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp)
r12 r12
r14 (lr)
r13 (sp) r14 (sp)
r13 (lr) r14 (lr)
r13 (sp) r14 (sp)
r13 (lr) r14 (sp)
r13 (lr) r14 (sp)
r13 (lr) r14 (lr)
r15
r14 (pc)
(lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr)
r15 (pc)
cpsr
spsr
cpsr spsr spsr spsr spsr spsr
spsr spsr spsr spsr spsr
140
Register Organization Summary
cpsr
spsr spsr spsr spsr spsr
• The current processor mode governs which of several banks is accessible. Each mode
can access
– a particular set of r0-r12 registers
– a particular r13 (the stack pointer, sp) and r14 (the link register, lr)
– the program counter, r15 (pc)
– the current program status register, cpsr
142
Program Status Registers
31 28 27 24 23 16 15 8 7 6 5 4 0
NZCVQ J U n d e f i n e d I F T mode
f s x c
• Condition code flags • Interrupt Disable bits.
– N = Negative result from ALU – I = 1: Disables the IRQ.
– Z = Zero result from ALU – F = 1: Disables the FIQ.
– C = ALU operation Carried out
– V = ALU operation oVerflowed
• T Bit
– Architecture xT only
• Sticky Overflow flag - Q flag
– T = 0: Processor in ARM state
– Architecture 5TE/J only
– T = 1: Processor in Thumb state
– Indicates if saturation has occurred
• Mode bits
• J bit
– Specify the processor mode
– Architecture 5TEJ only
– J = 1: Processor in Jazelle state
143
Program Counter (r15)
• When the processor is executing in ARM state:
– All instructions are 32 bits wide
– All instructions must be word aligned
– Therefore the pc value is stored in bits [31:2] with bits [1:0] undefined (as instruction
cannot be halfword or byte aligned).
144
Exception Handling
• When an exception occurs, the ARM:
– Copies CPSR into SPSR_<mode>
– Sets appropriate CPSR bits 0x1C FIQ
• Change to ARM state 0x18 IRQ
• Change to exception mode 0x14 (Reserved)
• Disable interrupts (if appropriate) 0x10 Data Abort
– Stores the return address in 0x0C Prefetch Abort
0x08 Software Interrupt
LR_<mode>
0x04 Undefined Instruction
– Sets PC to vector address 0x00 Reset
• To return, exception handler needs to: Vector Table
– Restore CPSR from SPSR_<mode> Vector table can be at
0xFFFF0000 on ARM720T
– Restore PC from LR_<mode> and on ARM9/10 family
This can only be done in ARM state. devices
145
Conditional Execution and Flags
• ARM instructions can be made to execute conditionally by
postfixing them with the appropriate condition code field.
– This improves code density and performance by reducing the
number of forward branch instructions.
CMP r3,#0 CMP r3,#0
BEQ skip ADDNE r0,r1,r2
ADD r0,r1,r2
skip
146
Condition Codes
• The possible condition codes are listed below:
• Note AL is the default and does not need to be
specified
Suffix Description Flags tested
EQ Equal Z=1
NE Not equal Z=0
CS/HS Unsigned higher or same C=1
CC/LO Unsigned lower C=0
MI Minus N=1
PL Positive or Zero N=0
VS Overflow V=1
VC No overflow V=0
HI Unsigned higher C=1 & Z=0
LS Unsigned lower or same C=0 or Z=1
GE Greater or equal N=V
LT Less than N!=V
GT Greater than Z=0 & N=V
LE Less than or equal Z=1 or N=!V
AL Always 147
Examples of conditional execution
• Use a sequence of several conditional instructions
if (a==0) func(1);
CMP r0,#0
MOVEQ r0,#1
BLEQ func
148
Branch instructions
• Branch : B{<cond>} label
• Branch with Link : BL{<cond>} subroutine_label
31 28 27 25 24 23 0
Cond 1 0 1 L Offset
• The processor core shifts the offset field left by 2 positions, sign-extends it
and adds it to the PC
– ± 32 Mbyte range
– How to perform longer branches?
149
Data processing Instructions
• Consist of :
– Arithmetic: ADD ADC SUB SBC RSB RSC
– Logical: AND ORR EOR BIC
– Comparisons: CMPCMN TST TEQ
– Data movement: MOV MVN
150
EXAMPLE
151
Barrel Shifter & Memory
Instructions
152
The Barrel Shifter
LSL : Logical Left Shift ASR: Arithmetic Right Shift
CF Destination 0 Destination CF
Destination CF
Immediate value
– 8 bit number, with a range of 0-255.
• Rotated right through even number of
ALU positions
– Allows increased range of 32-bit constants
to be loaded directly into registers
Result 154
EXAMPLE
155
156
Single register data transfer
157
158
(LDM/STM)
159
(LDM/STM) OPERATIONS
160
Software Interrupt (SWI) 0
31 28 27 24 23
Condition Field
31 0
ADDS r2,r2,#1
32-bit ARM Instruction For most instructions generated by compiler:
Conditional execution is not used
Source and destination registers identical
Only Low registers used
Constants are of limited size
15 0
Inline barrel shifter not used
ADD r2,#1
162
16-bit Thumb Instruction
Example ARM-based System
16 bit RAM 32 bit RAM
Interrupt
Controller
Peripherals I/O
nIRQ nFIQ
ARM
Core
8 bit ROM
163
Basics of Input - Output Operations
164
Input - Output Interface
• Input Output Interface provides a method for
transferring information between internal storage and
external I/O devices.
165
COMMUNICATION BETWEEN CPU, MEMORY
AND I/O DEVICES
166
BUS
• A bus is a bunch of wires through which data or
address or control signals flow.
• The microprocessor communicates with the memory
and the Input/Output devices via the three buses, viz.,
data bus, address bus and control bus.
• Data flow through the DB, while address comes out
of the AB and CB controls the activities of the
microprocessor system at any instant of time.
167
Input - Output Interface
168
The Major Differences are:-
1. Peripherals are electromechnical and
electromagnetic devices and their manner of operation of
the CPU and memory, will differ. Therefore, a conversion
of signal values may be needed.
2. The data transfer rate of peripherals is usually slower than
the transfer rate of CPU and consequently, a
synchronization mechanism may be needed.
169
3. Data codes and formats in the peripherals differ
from the word format in the CPU and memory.
4. The operating modes of peripherals are different
from each other and must be controlled so as not to
disturb the operation of other peripherals connected
to the CPU.
170
Input - Output Interface
173
I/O BUS and Interface Module
Each Interface decodes the address and control received
from the I/O bus, interprets them for peripherals and provides
signals for the peripheral controller.
It is also synchronizes the data flow and supervises the
transfer between peripheral and processor.
Each peripheral has its own controller. For example, the
printer controller controls the paper motion, the print timing.
174
The control lines are referred as an I/O command. The
commands are as following:
Control command- A control command is issued to
activate the peripheral and to inform it what to do.
Status command- A status command is used to test
various status conditions in the interface and the
peripheral.
175
I/O BUS and Interface Module
Output data command- A data output command
causes the interface to respond by transferring
data from the bus into one of its registers.
Input data command- The data input command is the
opposite of the data output. In this case the
interface receives on item of data from the
peripheral and places it in its buffer register.
176
I/O BUS and Interface Module
Data
Processor Address
Control
Keyboard
and Printer Magnetic
display disk
terminal
178