Professional Documents
Culture Documents
CS-522
MS – Computer Science
Lecture: 07
Topic: Input/Output (External Devices)
Program: MS – Computer Science (Sem: 1st, 2nd, 3rd & 4th)
• An I/O module is
– Set of mechanical connectors (that wire an I/O device into the system bus)
– Contains logic/circuit for performing a communication function
between the peripheral and the bus
Input/output Problems
Why I/O module? Why not connect peripherals directly to the system bus …..?
• Categories
– Human readable (suitable for communicating with computer user)
• Screens, video displays, printer
– Machine readable (suitable for communicating with equipment)
• Magnetic disks, tapes, sensors & actuators (i.e. monitoring and control in
robotics)
– Communication (suitable for communicating with remote devices)
• Modem, another computer
External Device Block Diagram
• Control signals: determines Function the device will perform,
• send data to I/O module (READ), accept data from I/O module
(WRITE)
• report status
• perform some control function of device (e.g., position of a disk
head)
• Data signals: reveals form of a set of bits to be sent to or
received from the I/O module
• Status signals indicate the state of the device
• E.g. READY/NOT-READY (to show whether the device is ready for
data transfer)
• Transducer converts data between electrical and other forms
of energy
External Device Block Diagram
Keyboard/Monitor
• Most common means of computer/user interaction is a
keyboard/monitor arrangement
– user provides input through the keyboard
– This input is then transmitted to the computer and may also be displayed on the
monitor
– In addition, the monitor displays data provided by the computer
• The basic unit of exchange is the character
– Associated with each character is a code, typically 7 or 8 bits in length
– common text code is the International Reference Alphabet (IRA)
– Each character in this code is represented by a unique 7-bit binary code
– thus, 128 different characters can be represented
– Characters are of two types: printable and control
– Printable characters are the alphabetic, numeric, and special characters that can be
printed on paper or displayed on a screen
• Some of the control characters have to do with controlling the printing or displaying of characters
Keyboard/Monitor
• For keyboard input,
– when the user depresses a key,
– this generates an electronic signal that is interpreted by the transducer in the
keyboard
– translated into the bit pattern of the corresponding IRA code
– This bit pattern is then transmitted to the I/O module in the computer
• At the computer, the text can be stored in the same IRA code
• On output,
– IRA code characters are transmitted to an external device from the I/O module
– The transducer at the device interprets this code and
– sends the required electronic signals to the output device either to display the
indicated character or perform the requested control function
Disk Drive
• A disk drive contains
– electronics for exchanging data, control, and status signals with an I/O module
– plus the electronics for controlling the disk read/write mechanism
• A moving-head disk must also be able to cause the disk arm to move
radially in and out across the disk’s surface.
An I/O Module
14
I/O Module Function
• Control & Timing
– to coordinate the flow of traffic between internal resources and external
devices
• CPU Communication
– Involves: command decoding, data, status reporting (not Ready),
address recognition
• Device Communication
– Involves: commands, status information, and data
• Data Buffering
– I/O module must operate at acceptable transfer rate
• Error Detection
– Transmission error (parity), Mechanical/electrical errors (paper jam)
I/O Steps
(traffic between internal resources and external devices)
– Programmed I/O
– Interrupt driven I/O
– Direct Memory Access (DMA)
Three Techniques for
Input (reading) of a Block of Data
Programmed I/O
• Data are exchanged between the processor and the I/O module
• CPU has direct control over I/O through program
– Sensing status
– Read/write commands
– Transferring data
• CPU waits for I/O module to complete operation
– Disadvantage: Wastes CPU time
Programmed I/O - detail
• CPU requests I/O operation
• I/O module performs operation
• I/O module sets status bits
• CPU checks status bits periodically
• I/O module does not inform CPU directly
• I/O module does not interrupt CPU
• CPU may wait or come back later
I/O Commands
• CPU issues address
– Identifies module (& device if >1 per module)
• CPU issues command
– Control - telling module what to do
• e.g. spin up disk
– Test - check status
• e.g. power? Error?
– Read/Write
• Module transfers data via buffer from/to device
Addressing I/O Devices
• Under programmed I/O, data transfer is very similar to
memory access
• Software poll
– CPU detects an interrupt, it asks each module in turn
– with the help of command TEST I/O
– Reading the Status register of each I/O module
– Slow (time consuming)
Identifying Interrupting Module (2)
• Daisy Chain (a series of interconnected things or events) or Hardware poll or
vectored interrupt
– All modules share a common interrupt request line (INTR pin)
– Interrupt Acknowledge sent down a chain
– Module responsible places vector (word) on bus
– CPU uses this vector to identify the device
• DMA controller takes over control of the system from CPU for
I/O
Typical DMA Module Diagram
DMA Operation
• CPU tells DMA controller:-
– Read/Write
– Device address
– Starting address of memory block for data
– Amount of data to be transferred
• CPU carries on with other work
• DMA controller deals with transfer
• DMA controller sends interrupt when finished
• Processor is involve only at the begging and at the end of
transfer
DMA Transfer - Cycle Stealing
• DMA controller takes over bus for a cycle
• Transfer of one word of data at a time
• Not an interrupt
– CPU does not switch context
• CPU suspended just before it accesses bus
– i.e. before an operand fetch/data fetch/data write
• Slows down CPU by pausing for a cycle
DMA and Interrupt Breakpoints
During an Instruction Cycle
DMA Configurations (1)
49