2Parallel I/O I/O devices connect to processor through PORTS Ports are: registers (part of the I/O interface)8, 16, or 32 bits wideAddressed in the range 0000-FFFFhAccessed with 2 instructions – IN, OUT
3Modes of I/O Instructions Direct I/O – the port address is one of the operands.Address must be 00-FFh.IN AL, 27hData flows through the accumulatorMOV AX, BXOUT 26h, AX ; move 16-bit data from AX to port ; 26h (AL to 26h and AH to 27h)Indirect I/O – the port address is preloaded into DXAddress can be 0000-FFFFhString I/O – allows data to pass directly through the accumulator (from I/O device to memory)
5Ways to Differentiate I/O Memory-Mapped versus I/O-Mapped Portsaddress of 80x86 processors is divided into 1M, 4GB, or 64GB of memory space and 64K of I/O space.With memory-mapped I/O, because I/O ports are mapped to a memory address, any of the memory read/write instructions are available to use. Address can be computed using any of the addressing modes.With I/O mapped ports, restricted to simple IN/OUT instructions. Address must be in DX.Memory Space20-, 32-, or 36-bitaddressI/O Space16-bitaddressM/IO’ = 0M/IO’ = 1
6Memory-Mapped I/O I/O Devices and memory share the same address space. Each I/O Device is assigned a unique set of addresses.When the processor places a particular address on the address lines, the device recognizing this address responds to the commands on the control lines.The processor requests either a read or a write operation, and the requested data is transferred over the data lines.Any machine instruction that can access memory can be used to transfer data to/from I/O devices.Mov datain, R0
7Intel ArchitectureIntel processors have a separate 16-bit address bus for I/O devicesDesigner has the option ofconnecting I/O devices to use special address spaceor simply incorporating them as part of the memory address space.The later approach leads to simpler software.One advantage of a separate address bus for I/O is reduced number of address lines needed for I/O devices.Not physically separate address lines on processor. Special signal (I/OR or I/OW, MemR or MemW)
8Ways to Drive Hardware Devices using Parallel Buses Programmed I/O through I/O portsInterrupt I/O using (hardware) interruptsDirect Memory Access
9Programmed I/O (driving Hardware devices through I/O ports) External devices are almost always connected not directly to the system bus but to an INTERFACE.Registers in the interface allow for a wide range of possibilities for the designer to determine how it is to interface to the bus.TO avoid confusion with the main registers in the 8086, peripheral interface chip registers are usually referred to as PORTS.
10Interface Ports Typically consists of three registers Control Port - the setting of which will determine if the interface is to send or receive.Data Port – for the data element to be transmitted or to hold a data element received.Status Port – used to obtain information such as “printer out of paper, don’t send any more data” or, for a serial transmission, “all the bits of the data element haven’t yet been received”Simple interfaces may have status and control combined into one port; sophisticated ports may have multiple control and status ports.
11I/O Interface for an Input Device Address LinesData LinesControl LinesAddressDecoderControlCircuitsData andStatus RegistersI/O InterfaceInput Device
12I/O Device SpeedsProcessors can operate at speeds that are vastly different than I/O speeds.When a human is entering characters on a keyboard, the processor can execute millions of instructions between successive character entries.So, how does the processor handle I/O inputs…..
13Three types of I/O Strategies Polled I/OInterrupt Driven I/ODMA I/O
14Polled IO versus Interrupt Driven I/O Polled IO – processor continually checks IO device to see if it is ready for data transferInefficient, processor wastes time checking for ready conditionInterrupt Driven IO – IO device interrupts processor when it is ready for data transferProcessor can be doing other tasks while waiting for last data transfer to complete – very efficient.
15I/O InterfacingA lot of handshaking is required between the CPU and most I/O devices.All I/O devices operate asynchronously with respect to the CPU. The events that determine when an input device has data available or when an output device needs data are independent of the CPU.
16Three I/O strategiesMust be capable of data rates fast enough to keep up with the demands of the device, but must not be allowed to transfer data faster than the device can process it.Polled waiting loopsInterrupt-driven I/ODirect memory Access (DMA)
17SynchronizationThe CPU must have some way of checking the status of the device and waiting until it is ready to transfer
18Transfer RateA measure of the number of bytes per second transferred between the CPU and an external device.Maximum transfer rate – a measure of the bandwidth capability of a particular method of doing I/O.
19Comparison of transfer rates Polled waiting loops provide data rates that are a bit slower, but still quite reasonable.Interrupt-driven I/O requires overhead of saving and restoring the machine state (significantly degrades data rates unless more than one byte can be transferred per interrupt.DMA has fastest transfer rates (additional hardware complexity needed.
20LatencyMeasure of the delay from the instant that the device is ready until the time the first data byte is transferred. Latency is equivalent to the “response time”
21Comparison of LatencyPolled Waiting Loops – latency can be very high (the computer may not even be checking the device for new data when it arrives).Interrupt-driven I/O – dramatically lower than polled, but still imposes a software overhead.DMA – very low (lower than the others)
22Polled Waiting I/OUse software to test the status of a device,before transferring each data byte.Continuously checking the peripheral’s BUSY/READY flagTies up the CPU – no other tasks can be performed.