I/O MODULES Module Function

7.2 I/O MODULES Module Function

The major functions or requirements for an I/O module fall into the following categories:

• Control and timing • Processor communication • Device communication • Data buffering • Error detection

During any period of time, the processor may communicate with one or more external devices in unpredictable patterns, depending on the program’s need for I/O. The internal resources, such as main memory and the system bus, must be shared among a number of activities, including data I/O. Thus, the I/O function includes a control and timing requirement, to coordinate the flow of traffic between internal re- sources and external devices. For example, the control of the transfer of data from an external device to the processor might involve the following sequence of steps:

1. The processor interrogates the I/O module to check the status of the attached device.

2. The I/O module returns the device status.

3. If the device is operational and ready to transmit, the processor requests the transfer of data, by means of a command to the I/O module.

4. The I/O module obtains a unit of data (e.g., 8 or 16 bits) from the external device.

5. The data are transferred from the I/O module to the processor. If the system employs a bus, then each of the interactions between the proces-

sor and the I/O module involves one or more bus arbitrations. The preceding simplified scenario also illustrates that the I/O module must communicate with the processor and with the external device. Processor communi- cation involves the following:

• Command decoding: The I/O module accepts commands from the processor, typically sent as signals on the control bus. For example, an I/O module for a disk drive might accept the following commands: READ SECTOR, WRITE SECTOR, SEEK track number, and SCAN record ID. The latter two com- mands each include a parameter that is sent on the data bus.

• Data: Data are exchanged between the processor and the I/O module over the data bus.

• Status reporting: Because peripherals are so slow, it is important to know the status of the I/O module. For example, if an I/O module is asked to send data to the processor (read), it may not be ready to do so because it is still working on the previous I/O command. This fact can be reported with a status signal.

7.2 / I/O MODULES 223

Common status signals are BUSY and READY. There may also be signals to report various error conditions.

• Address recognition: Just as each word of memory has an address, so does each I/O device. Thus, an I/O module must recognize one unique address for each peripheral it controls.

On the other side, the I/O module must be able to perform device communication. This communication involves commands, status information, and data (Figure 7.2). An essential task of an I/O module is data buffering. The need for this function is apparent from Figure 2.11. Whereas the transfer rate into and out of main mem- ory or the processor is quite high, the rate is orders of magnitude lower for many pe- ripheral devices and covers a wide range. Data coming from main memory are sent to an I/O module in a rapid burst. The data are buffered in the I/O module and then sent to the peripheral device at its data rate. In the opposite direction, data are buffered so as not to tie up the memory in a slow transfer operation. Thus, the I/O module must be able to operate at both device and memory speeds. Similarly, if the I/O device operates at a rate higher than the memory access rate, then the I/O mod- ule performs the needed buffering operation.

Finally, an I/O module is often responsible for error detection and for subse- quently reporting errors to the processor. One class of errors includes mechanical and electrical malfunctions reported by the device (e.g., paper jam, bad disk track).Another class consists of unintentional changes to the bit pattern as it is transmitted from device to I/O module. Some form of error-detecting code is often used to detect transmission errors. A simple example is the use of a parity bit on each character of data. For exam- ple, the IRA character code occupies 7 bits of a byte.The eighth bit is set so that the total number of 1s in the byte is even (even parity) or odd (odd parity). When a byte is re- ceived, the I/O module checks the parity to determine whether an error has occurred.