CH 8 Input-Output
CH 8 Input-Output
Input Output
• Peripheral Devices
• Input-Output Interface
• Modes of Transfer
• Priority Interrupt
• Input-Output Processor
• Serial Communication
2
Peripheral Devices
PERIPHERAL DEVICES
3
Input/Output Interfaces
INPUT/OUTPUT INTERFACES
* Provides a method for transferring information between internal storage
(such as memory and CPU registers) and external I/O devices
- Unit of Information
Peripherals - Byte
CPU or Memory - Word
- Operating Modes
Peripherals - Autonomous, Asynchronous
CPU or Memory - Synchronous
4
Input/Output Interfaces
Keyboard
and Printer Magnetic Magnetic
display disk tape
terminal
Interface
- Decodes the device address (device code)
- Decodes the commands (operation)
- Provides signals for the peripheral controller
- Synchronizes the data flow and supervises
the transfer rate between peripheral and CPU or Memory
Typical I/O instruction
Op. code Device address Function code
(Command)
5
Input/Output Interfaces
Physical Organizations
* Many computers use a common single bus system
for both memory and I/O interface units
- Use one common bus but separate control lines for each function
- Use one common bus with common control lines for both functions
* Some computer systems use two separate buses,
one to communicate with memory and the other with I/O interfaces
I/O Bus
- Communication between CPU and all interface units is via a common
I/O Bus
- An interface connected to a peripheral device may have a number of
data registers , a control register, and a status register
- A command is passed to the peripheral by sending
to the appropriate interface register
- Function code and sense lines are not needed (Transfer of data, control,
7
and status information is always via the common I/O Bus)
Input/Output Interfaces
Memory-mapped I/O
- A single set of read/write control lines
(no distinction between memory and I/O transfer)
- Memory and I/O addresses share the common address space
-> reduces memory address range available
- No specific input or output instruction
-> The same memory reference instructions can
be used for I/O transfers
- Considerable flexibility in handling I/O operations
8
Input/Output Interfaces
I/O INTERFACE
Port A I/O data
register
Bidirectional Bus
data bus buffers
Port B I/O data
register
Handshaking
- A control signal is accompanied with each data
being transmitted to indicate the presence of data
- The receiving unit responds with another control
signal to acknowledge receipt of the data
10
Asynchronous Data Transfer
STROBE CONTROL
* Employs a single control line to time each transfer
* The strobe may be activated by either the source or the destination unit
Strobe Strobe
11
Asynchronous Data Transfer
HANDSHAKING
Strobe Methods
Source-Initiated
Destination-Initiated
12
Asynchronous Data Transfer
Valid data
Data bus
Timing Diagram
Data valid
Data accepted
Data valid
Valid data
Data bus
1 1 0 0 0 1 0 1
Start Character bits Stop
bit bits
(1 bit) (at least 1 bit)
Internal Bus
register control
and clock
Chip select CS
Register select Status Receiver Receiver CS RS Oper. Register selected
RS Timing clock
register control 0 x x None
I/O read and and clock 1 0 WR Transmitter register
RD Control 1 1 WR Control register
I/O write Receive 1 0 RD Receiver register
WR Receiver Shift data
1 1 RD Status register
register register
Transmitter Register
- Accepts a data byte(from CPU) through the data bus
- Transferred to a shift register for serial transmission
Receiver
- Receives serial information into another shift register
- Complete data byte is sent to the receiver register
Status Register Bits
- Used for I/O flags and for recording errors
Control Register Bits
- Define baud rate, no. of bits in each character, whether
to generate and check parity, and no. of stop bits
16
Modes of Transfer
Data transfer to and from peripherals
1) Programmed I/O :
Read status register
2) Interrupt-initiated I/O :
3) Direct Memory Access (DMA) : Check flag bit
Status Operation no
I/O write F complete ?
register Data accepted
yes
Interrupt-initiated I/O
1) Non-vectored : fixed branch address
2) Vectored : interrupt source supplies the branch address
17 (interrupt vector)
Software Considerations
I/O routines
software routines for controlling peripherals and for
transfer of data between the processor and peripherals
I/O routines for standard peripherals are provided by the
manufacturer (Device driver, OS or BIOS)
I/O routines are usually included within the operating system
I/O routines are usually available as operating system
procedures ( OS or BIOS function call)
Priority Interrupt
Priority Interrupt
Identify the source of the interrupt when several sources will
request service simultaneously
Determine which condition is to be serviced first when two or
more requests arrive simultaneousl
1) Software : Polling
18
2) Hardware : Daisy chain, Parallel priority
Polling
Identify the highest-priority source by software means
One common branch address is used for all interrupts
Program polls the interrupt sources in sequence
The highest-priority source is tested first
Polling priority interrupt
If there are many interrupt sources, the time required to
poll them can exceed the time available to service the I/O
device
Hardware priority interrupt
Daisy-Chaining :
Processor data bus
VAD 1 VAD 2 VAD 3
Device 2
Interrupt Request “1” PIDevicePO
1
“1” Device 2
PI PO “0” Device 3
PI PO
To next
Device
Interrupt request
INT
CPU
Interrupt acknowledge
INTACK
19
VAD
INTACK Priority in
PI Enable
Vector address
No interrupt request
Invalid : interrupt request, but no acknowledge
No interrupt request : Pass to other device (other device
requested interrupt )
Interrupt request
20
Parallel Priority
Priority Encoder arallel Priority :
Interrupt Enable F/F (IEN) : set or
cleared by the program Interrupt
register
VAD
Interrupt Status F/F (IST) : set or disk 0
I0
to CPU
y
cleared by the encoder output Printer 1
x
I1
Priority Encoder Truth Table : Priority
encoder
0
0
Interrupt Cycle
Reade 2
I2
r 0
0
At the end of each instruction cycle, Keyboard 3
I3
0
22
Transfer Modes
1) Burst transfer : Block
2) Cycle stealing transfer : Byte
DMA Controller ( Intel 8237 DMAC ) :
DMA Initialization Process Address bus
1) Set Address register :
o memory address for read/write
Data bus Address bus
2) Set Word count register : Data bus
buffers buffers
Internal bus
Address register
o read/write, DMA select CS
Register select RS
o burst/cycle stealing, Word count register
Read RD
o I/O to I/O, Write WR
Control
o I/O to Memory, Bus request BR logic Control register
I/O device
24
Input-Output Processor (IOP)
IOP :
Communicate directly with all I/O devices
Fetch and execute its own instruction
IOP instructions are specifically designed to facilitate I/O
transfer
DMAC must be set up entirely by the CPU
Designed to handle the details of I/O processing
Central Processing
unit (CPU)
Memory bus
Peripheral devices
Memory unit PD PD PD PD
Input-output
processor (IOP) I/O bus
Command
Instruction that are read form memory by an IOP
Distinguish from instructions that are read by the CPU
Commands are prepared by experienced programmers and
are stored in memory
25 Command word = IOP program
CPU - IOP Communication :
Memory units acts as a message center : Information
each processor leaves information for the other
Send instruction
Transfer status word
to test IOP path
to memory location
Message Center
If status OK. , send
start I/O instruction Access memory for
to IOP IOP program
Continue
26
IBM 370 I/O Channel
Channel = I/O Processor in IBM 370 computer
Three types of channel
1) Multiplexer channel : slow-medium speed device, operating with
a number of I/O devices simultaneously
2) Selector channel : high-speed device, one I/O operation at a time
3) Block-Multiplexer channel : 1) + 2)
I/O instruction format :
Operation code : 8
o Start I/O, Start I/O fast release (less CPU time),
Test I/O, Clear I/O, Halt I/O, Halt device, Operation Channel Device
code address address
Test channel, Store channel ID (a) I/O instruction format
Key : Protection used to prevent unauthorized (b) Channel status word format
access
Command
Data address Flags Count
Address : Last channel command word address code
28 same device
Intel 8089 IOP :
Select
Bus System
Memory unit 8089
Controller bus PB address Memory address
IOP
program
Byte count
Device address
8089 Local bus
IOP
Track and sector
30
Half-duplex : both directions but only one direction at a time
Full-duplex : both directions simultaneously
Data Link
The communication lines, modems, and other equipment used
in the transmission of information between two or more
stations
Data Link Protocol
1) Character-Oriented Protocol
2) Bit-Oriented Protocol
Character-Oriented Protocol
Message
SYN format
SYN SOHfor Character-Oriented
Header STX Protocol :ETX
Text BCC
TEXT :
BCC : Block Check Character (LRC or CRC)
ASCII Communication Control Character :
SYN (0010110) : Establishes synchronism
SOH (0000001) : Start of Header (address or control
information)
STX (0000010) : Start of Text
31 ETX (0000011) : End of Text
Data Transparency
Character-Oriented Protocol
Character-Oriented Protocol Data Transparency DLE (Data Link Escape)
DLE
Inserting a DLE character (bit pattern = 00010000) before each control
character
Exam) DLE ETX DLE SYN
DLE character is inefficient and somewhat complicated to implement
Bit-Oriented Protocol
Bit-Oriented Protocol
Transmit a serial bit stream (Frame) of any length without character
boundaries
Examples of bit-oriented protocol
1) SDLC (Synchronous Data Link Control) : IBM
2) HDLC (High-level Data Link Control) : ISO
3) ADCCP (Advanced Data Communication Control Procedure) :
Frame format for bit-oriented protocol :
Flag Address Control Information Frame check Flag
01111110 8 bits 8 bits any number of bits 16 bits 01111110
34