Salta al contenuto
Note per Studenti Input-Output Devices and Interfaces Report

Input-Output Devices and Interfaces

In questa pagina 4

Input/output (I/O) devices let the computer communicate with the outside world. They are many, with very different speeds, from a few bytes per second to tens of MB per second. How data are then moved is in Programmed I-O and InterruptsIn programmed I/O the CPU polls the device in a busy-wait loop and wastes most cycles; with interrupts the interface raises a signal when data are ready, the CPU suspends its work, runs a service routine and returns. Interrupts can be vectored (the device supplies the address of its routine) or non-vectored; with several devices a priority scheme is needed, by software polling, by hardware daisy chain (priority = position in the chain, no parallel handling) or by parallel priority with a priority encoder and a mask register.Programmed I-O and Interrupts → and Direct Memory Access (DMA)In DMA a controller takes over the buses and moves data between a fast device and memory without involving the CPU; it asks for the bus with Bus Request, receives it with Bus Granted, increments an address register after every word, and raises a single interrupt at the end. The CPU programs it as if it were a peripheral.Direct Memory Access (DMA) →.

Some peripherals

Keyboard. Very low data rate. The pressed key is found with a scan matrix: pressing a key connects a row to a column; a microcontroller periodically scans the rows (drives one row to 1 and checks whether a 1 appears on a column) with a decoder and a multiplexer; the control signals at detection identify the key. A make code (pressed) and a break code (released) are sent. Scanning repeats hundreds of times per second, so no key press is lost.

Hard disk. Fast-spinning magnetised disks; bits are stored by the magnetisation direction of a small area and organised in tracks and sectors; a head moving along the radius reads and writes. Performance:

  • seek time: time to bring the head to the track;
  • rotational delay: time for the disk to rotate the data under the head (on average half a turn);
  • controller time: time for the electronic controller to process the data and supply them to the interface;
  • their sum is the disk access time; data are read in contiguous blocks since moving the head wastes time.

Example (illustrative values). A 7200 rpm disk: one turn lasts 60/7200=8.3360/7200=8.33 ms, the average rotational delay is half a turn, 4.174.17 ms. With seek 99 ms, controller 0.20.2 ms and a 44 KB transfer at 100100 MB/s (0.040.04 ms): access time ≈9+4.17+0.2+0.04=13.4\approx9+4.17+0.2+0.04=13.4 ms.

Liquid crystal display (LCD). Independent pixels, each with three RGB subpixels with filters; a light source lies under the pixels; liquid crystals, oriented by an electric field, block or pass the light, mixing the three colours. Data rate of hundreds of MB/s; the control electronics resembles a DRAM (rows written consecutively, the whole panel refreshed in less than 1/601/60 s).

I/O interfaces

They are needed because:

  • some peripherals work electromechanically, far from an all-electronic CPU;
  • the transfer rate of the peripheral differs from the CPU clock: a synchronisation mechanism is needed;
  • codes and formats may differ from those of CPU and memory;
  • each peripheral has its own peculiarities and must be controlled without disturbing the others.

Connection to the CPU. A single bus connects several peripherals. To talk to one, the CPU puts its address on the address bus; each interface has a decoder watching the address lines and activating its interface when it recognises its own address.

Memory-mapped and isolated I/O.

  • memory-mapped: one common bus of data, addresses and control for memory and I/O; I/O and memory addresses must be different;
  • isolated I/O: the address bus is common but the control lines are separate for memory and I/O; the addresses of the two are independent (the control lines say which one is addressed).

Transmission control

Communication between CPU and interfaces is typically asynchronous (different clocks): control and synchronisation signals are needed.

  • Strobing: a signal (strobe) says the receiver is ready (destination-initiated) or the sender has sent the datum (source-initiated). There is no acknowledgement of reception.
  • Handshaking: communication is acknowledged on both sides; it needs one more signal but is more robust: the sender signals "data valid", the receiver replies "data accepted" and only then does the transfer go on.

Serial and parallel communication

  • Parallel: several bits at the same time; faster but more complex and costly (many lines to keep in sync); for high speed and short distances.
  • Serial: one bit at a time; slower per line but cheaper (fewer lines). Raising the speed on one line is easier than on many synchronised lines: serial links are growing (disks went from PATA to SATA).

Direction: simplex (one way only), half-duplex (both, one at a time), full-duplex (both, also together). Synchronous transmission (same clock for transmitter and receiver, possibly with periodic sync signals, which can be extracted from the data) or asynchronous (different clocks). The keyboard controller uses synchronous serial communication to the interface and talks to the CPU by interrupt.

USB (Universal Serial Bus)

Packet-based serial transmission: several devices share the bus in different packets. Elements: hub (interface with control and repeater functions), devices, composite devices. Transactions consist of packets of several types: in an output transaction (computer to device) an out packet and a data packet come from the computer, a handshake packet from the device.

Definition (NRZI coding). NRZI (Non-Return-to-Zero Inverted) gives edges useful for synchronisation: a 0 is sent as a level transition; a 1 as an unchanged level. With too many consecutive 1s (more than 6) there would be no transitions: after six 1s a 0 is inserted (bit stuffing). Example, starting from level high: bits 0,1,1,0,1,0,0,10,1,1,0,1,0,0,1 give levels 0,0,0,1,1,0,1,10,0,0,1,1,0,1,1 (the level flips at every 0); the sequence 1,1,1,1,1,1,1,01,1,1,1,1,1,1,0 is sent as 1,1,1,1,1,1,0,1,01,1,1,1,1,1,0,1,0.

Common mistakes

  • Believing strobing guarantees reception: it has no acknowledgement; the acknowledgement is handshaking.
  • Confusing memory-mapped (addresses shared with memory) and isolated I/O (separate control lines).

Versione ripasso

  • Why interfaces: peripherals are often electromechanical, slower than the CPU, with different codes and formats; synchronisation and adaptation are needed.
  • Keyboard: scan matrix; the microcontroller drives one row to 1 at a time and reads the active column; make code and break code; scan repeated hundreds of times per second.
  • Disk: access time = seek + rotational delay (half a turn on average) + controller time. 7200 rpm, seek 9 ms, controller 0.2 ms, 44 KB at 100 MB/s: 9+4.17+0.2+0.04≈13.49+4.17+0.2+0.04\approx13.4 ms. Contiguous blocks avoid head movement.
  • LCD: pixels with three RGB subpixels; liquid crystals block or pass light; hundreds of MB/s.
  • Connection: one bus; the CPU puts the address on the address bus and each interface decoder activates on its own address. Memory-mapped: one bus for memory and I/O, different addresses. Isolated I/O: common address bus, separate control lines, independent addresses.
  • Strobing: a signal says the receiver is ready or the sender has sent; no acknowledgement. Handshaking: acknowledged on both sides, one more signal, more robust ("data valid" then "data accepted").
  • Serial and parallel: parallel is fast over short distances but costly; serial uses fewer lines and is growing (PATA to SATA). Simplex, half-duplex, full-duplex; synchronous or asynchronous.
  • USB: serial packets, hubs and devices; in an output transaction the computer sends an out packet and a data packet, the device a handshake packet.
  • NRZI: 0 is a transition, 1 keeps the level; after six 1s a 0 is stuffed. Starting high, bits 0,1,1,00,1,1,0 give levels 0,0,0,10,0,0,1.
  • Mistakes: strobing taken for handshaking; memory-mapped and isolated I/O confused.

Teoria collegata