Module 4 DDCO
Module 4 DDCO
INPUT/OUTPUT
ORGANIZATION
Syllabus
• Accessing I/O Devices,
• Interrupts – Interrupt Hardware,
• Enabling and Disabling Interrupts,
• Handling Multiple Devices,
• Direct Memory Access: Bus Arbitration,
• Speed, size and Cost of memory systems.
• Cache Memories – Mapping Functions.
Introduction
• One of the basic features of a computer is its ability to
exchange data with other devices.
• This communication capability enables a human operator. We
make extensive use of computers to communicate with other
computers over the Internet and access information around the
globe.
• Computers are an integral part of home appliances,
manufacturing equipment, transportation systems, banking, and
point-of sale terminals.
• In such applications, input to a computer may come from a
sensor switch, a digital camera, a microphone, or a fire alarm.
Output may be a sound signal sent to a speaker, or a digitally
coded command that changes the speed of a motor, opens a
valve, or causes a robot to move in a specified manner.
Accessing I/O devices
Processor Memory
Bus
•Multiple I/O devices may be connected to the processor and the memory via a
single bus. Bus will helpful to exchange information.
•Bus consists of three sets of lines to carry address, data and control signals.
•Each I/O device is assigned an unique set of addresses.
•To access an I/O device, the processor places the address on the address lines.
•The device recognizes the address, and responds to the commands issued on
the control lines.
Accessing I/O devices (contd..)
I/O devices and the memory may share the same
address space:
The arrangement is called as Memory-mapped I/O.
Any machine instruction that can access memory can be used to
transfer data to or from an I/O device.
Move DATAIN, R0
Move R0, DATAOUT
I/O devices and the memory may have different
address spaces:
Special instructions to transfer data to and from I/O devices.
I/O devices may have to deal with fewer address lines.
I/O address lines need not be physically separate from memory
address lines.
In fact, address lines may be shared between I/O devices and memory,
with a control signal to indicate whether it is a memory address or an
I/O address.
Accessing I/O devices (contd..)
Address lines
Bus Data lines
Control lines
Input device
•I/O device is connected to the bus using an I/O interface circuit which has:
- Address decoder, control circuit, and data and status registers.
•Address decoder decodes the address placed on the address lines thus enabling the
device to recognize its address.
•Data register holds the data being transferred to or from the processor.
•Status register holds information necessary for the operation of the I/O device.
•Data and status registers are connected to the data lines, and have unique
addresses.
•I/O interface circuit coordinates I/O transfers.
Accessing I/O devices (contd..)
• When a human operator is entering characters at a keyboard,
the processor is capable of executing millions of instructions
between successive character entries.
• Striking a key stores the corresponding character code in an 8-
bit buffer register DATAIN.
• To inform the processor that a valid character is in DATAIN, a
status control flag, SIN, is set to 1.
• A program monitors SIN, and when SIN is set to 1, the
processor reads the contents of DATAIN.
• When the character is transferred to the processor, SIN is
automatically cleared to 0.
• If a second character is entered at the keyboard, SIN is again
set to 1 and the process repeats.
Accessing I/O devices (contd..)
• A buffer register, DATAOUT, and a status control flag, SOUT,
are used for this transfer.
• When SOUT equals 1, the display is ready to receive a
character.
• Under program control, the processor monitors SOUT, and
when SOUT is set to 1, the processor transfers a character
code to DATAOUT.
• The transfer of a character to DATAOUT clears SOUT to 0.
• When the display device is ready to receive a second
character, SOUT is again set to 1.
• The buffer registers DATAIN and DATAOUT and the status
flags SIN and SOUT are part of circuitry commonly known as
a device interface.
Registers in keyboard
and display interface
Interrupt
occurs i
here
i+1
INTA1 INTA p
Priority arbitration
Device Device
INTA1
Processor
IN T R p
Device Device
INTA p
Priority arbitration
circuit
System bus
B BS Y
BR
Processor
DMA DMA
controller controller
BG1 1 BG2 2
Centralized Bus Arbitration
• Bus arbiter may be the processor or a separate unit
connected to the bus.
• Normally, the processor is the bus master, unless it grants
bus membership to one of the DMA controllers.
• DMA controller requests the control of the bus by
asserting the Bus Request (BR) line.
• In response, the processor activates the Bus-Grant1 (BG1)
line, indicating that the controller may use the bus when
it is free.
• BG1 signal is connected to all DMA controllers in a daisy
chain fashion.
• BBSY signal is 0, it indicates that the bus is busy. When
BBSY becomes 1, the DMA controller which asserted BR
can acquire control of the bus.
Centralized arbitration
DMA controller 2
asserts the BR signal. Time
Processor asserts
BR
the BG1 signal
B BS Y
Bus
master
Processor DMA controller 2 Processor
Arbitration process:
•Each device compares the pattern that appears on the arbitration lines to its
own ID, starting with MSB.
•If it detects a difference, it transmits 0s on the arbitration lines for that and
all lower bit positions.
•Device A compares its ID 5 with a pattern 0101 to pattern 0111.
•It detects a difference at bit position 0, as a result, it transmits a pattern
0100 on the arbitration lines.
•The pattern that appears on the arbitration lines is the logical-OR of 0100
and 0110, which is 0110.
•This pattern is the same as the device ID of B, and hence B has won the
arbitration.
Speed, Size, and Cost
A big challenge in the design of a computer system is to
provide a sufficiently large memory, with a reasonable
speed at an affordable cost.
Static RAM:
▪ Very fast, but expensive, because a basic SRAM cell has a complex
circuit making it impossible to pack a large number of cells onto a
single chip.
Dynamic RAM:
▪ Simpler basic cell circuit, hence are much less expensive, but
significantly slower than SRAMs.
Magnetic disks:
▪ Storage provided by DRAMs is higher than SRAMs, but is still less
than what is necessary.
▪ Secondary storage such as magnetic disks provide a large amount
of storage, but is much slower than DRAMs.
Memory Hierarchy
Pr ocessor •Fastest access is to the data held in
processor registers. Registers are at the
Re gisters top of the memory hierarchy.
Increasing Increasing Increasing •Relatively small amount of memory
size speed cost per bit
Primary L1 that can be implemented on the
cache
processor chip. This is processor cache.
•Two levels of cache. Level 1 (L1) cache
is on the processor chip. Level 2 (L2)
Secondary L2 cache is in between main memory and
cache
processor.
•Next level is main memory,
implemented as SIMMs. Much larger,
Main
memory but much slower than cache memory.
•Next level is magnetic disks. Huge
amount of inexepensive storage.
•Speed of memory access is critical, the
Magnetic disk
secondary idea is to bring instructions and data
memory that will be used in the near future as
close to the processor as possible.
Cache Memories
Processor is much faster than the main memory.
▪ As a result, the processor has to spend much of its time
waiting while instructions and data are being fetched from
the main memory.
▪ Major obstacle towards achieving good performance.
Speed of the main memory cannot be increased
beyond a certain point.
Cache memory is an architectural arrangement
which makes the main memory appear faster to
the processor than it really is.
Cache memory is based on the property of
computer programs known as “locality of
reference”.
Locality of Reference
Analysis of programs indicates that many instructions
in localized areas of a program are executed
repeatedly during some period of time, while the
others are accessed relatively less frequently.
▪ These instructions may be the ones in a loop, nested loop
or few procedures calling each other repeatedly.
▪ This is called “locality of reference”.
Temporal locality of reference:
▪ Recently executed instruction is likely to be executed again
very soon.
Spatial locality of reference:
▪ Instructions with addresses close to a recently instruction
are likely to be executed soon.
Cache memories
Main
Processor Cache memory
Block 4095
Set-Associative mapping
Cache
Main
memory
Block 0 Blocks of cache are grouped into sets.
Block 1 Mapping function allows a block of the main
tag
tag
Block 1
Block 0
memory to reside in any block of a specific set.
tag Block 2 Divide the cache into 64 sets, with two blocks per
set.
Block 63 Memory block 0, 64, 128 etc. map to block 0, and
tag Block 3
Block 64
they can occupy either of the two positions.
tag Memory address is divided into three fields:
Block 126 Block 65
- 6 bit field determines the set number.
- High order 6 bit fields are compared to the
tag
Block 127 tag fields of the two blocks in a set.
Set-associative mapping combination of direct
Block 127
T ag Block Word and associative mapping.
Block 128
5 7 4 Number of blocks per set is a design parameter.
Main memory address Block 129 - One extreme is to have all the blocks in one
set, requiring no set bits (fully associative
mapping).
- Other extreme is to have one block per set, is
Block 4095 the same as direct mapping.