Input/output

advertisement
Input/Output
What is I/O?
• How we get the CPU to communicate with
devices
• From the computer’s point of view, it’s just
1’s and 0’s
• Gets interpreted by the device it is sent to
(output)
• Computer interprets data received (input)
2
Devices
What are devices?
Obvious ones…
• Mouse
• Keyboard
• Printer
• Modem
Not so obvious ones…
• Floppies
• CD-ROM
• Hard disc drives
3
The Bus - Reminder
A collection of wires which carry data between the
CPU, memory and I/O devices
• Address Bus: carries memory address values from
the CPU to the memory and I/O
• Data Bus: carries all data, including machine
codes, in all directions
• Control Bus: a small number of wires carrying the
read/write and enable signals, and a few other
‘control’ signals
4
I/O Devices
Address bus
Data bus
Control bus
I/O Port
Interface between computer’s
bus and I/O device
Device-specific
communication link
Peripheral
Actual I/O device
5
Peripherals
These are the devices that actually do the physical
input, output and data storage operations.
Examples: keyboard
printer
mouse
floppy disk
VDU
modem
They do not connect directly to the computer’s bus.
A peripheral is anything connected to the computer
except the CPU, memory and power supply
6
I/O Ports
These are the devices that provide interfaces between
the computer’s buses and the peripherals. In
general, they do the following:
• Recognise when they are being addressed, or
selected
• Provide at least one (but typically at least two)
addressable locations that can be read and/or
written like a memory location. These locations
are called I/O registers, and can be classified into
data registers and control registers
7
I/O Ports
• Respond to commands from the CPU
– CPU writes to the control registers
• For input devices: transfer data from device
to input data registers
– CPU can then read data from these registers
• For output devices: transfer data from data
registers to device
– CPU will have already written data to registers
8
I/O Ports
• Provide a variety of protocols for data transfer to
and from the peripheral, all under CPU control
• Provide status and error information to the CPU
e.g. ready, broken, run out of paper etc
• Issue interrupts to signal the occurrence of certain
events (e.g. data received), as specified by the
CPU (more later)
9
Parallel and Serial Interfaces
I/O ports can be classified according to the
type of interface they implement. The two
commonest are:• parallel interface
(e.g. to a printer)
• serial interface
(e.g. to a VDU or modem)
10
Parallel Interface (typical)
Think: pins
on a printer
cable before
USB!
11
Example protocol: Handshake
RDY: sender says
data is ready
ACK: receiver
acknowledges receipt
12
Receiver acknowledges
transmission over
Receiver acknowledges receipt
Sender stops asserting data ready
Sender asserts data ready
Sender puts data on lines
The Handshake
13
Serial
Interface
(transmitter)
14
The Serializer
The serializer takes the (8 bits of) input, and
translates them to a single stream of data
It tells the CPU (status and control register)
when data transmission is complete
It reads from the status & control register
information about how to format the data, and
what speed to send it
15
USB
• A bit different…
• Four wires
– Two for data transmission
– One for ground
– One for voltage (+5V)
• Data sent in packets, addressed to destination
• Lower noise, fewer errors => faster data transfer
than traditional serial and parallel ports
16
Firewire
• Like USB but better
– Nearly twice as fast (USB2.0=480Mb/s;
Firewire800=800Mb/s)
– Allows longer cables (USB2.0 max 4.5m; Firewire
100m
• And also more expensive
– Which is why, although Firewire has been around since
1995 (Apple created it), USB is more used
• For really fast connections (e.g. video) Firewire is
best; for others, it doesn’t matter
17
Test Yourself!
1. Think of some peripherals. Do they use
serial or parallel interfaces?
2. What is an I/O port?
3. How does handshaking work?
4. Can you draw a timing diagram for
parallel interface handshaking?
5. What about the serial interface?
18
Download