The role of the I/O interface
The host exchanges information with the outside world called input/output (I/O). The information exchange between the host and the outside world is carried out through the input/output devices. General input/output devices are mechanical or electromechanical combination of products, such as the conventional outside with keyboards, monitors, printers, scanners, disk drives, mouse, and so on, they are relatively high-speed central processing unit, the speed is much slower. In addition, the signal form and data format of different peripherals vary. As a result, external devices cannot be directly connected to the CPU, and the corresponding circuitry is required to perform speed matching, signal conversion, and some control functions. Typically, a buffer circuit between the host and the peripheral is called the I/O interface circuit, referred to as the I/O interface (Interface), as shown in 7.1. For the host, the I/O interface provides the working status and data of the external device, and for external devices, the I/O interface remembers all commands and data sent by the host to the peripherals, allowing the host to work in unison with the peripherals.
For a microcomputer, when designing a microprocessor CPU, it does not design the interface between it and peripherals, but instead designs the interface circuit of the input/output device as a relatively independent component, through which the various types of peripherals are connected to the CPU to form a complete micro-computer hardware system. Therefore, the input/output system of a microcomputer should include I/O interfaces, I/O devices and related control software. A microcomputer system's comprehensive processing ability, system reliability, compatibility, performance and price ratio, and even in a situation can be used are closely related to I/O system. Input/output system is one of the important parts of computer system, any high-performance computer, if there is no high-quality input/output system to work with it, the machine can not play.
7.1.2 CPU-to-peripherals exchange information
The information exchanged between host and I/O device can be divided into three categories: data information, status information and control information.
A Data information
The data information is divided into three forms: digital quantity, analogue quantity and switching volume.
1. Digital quantity
Digital is the data that a computer can send, receive, and process directly. For example, I/O peripherals, such as keyboards, monitors, printers, and disks, exchange information with the CPU, which are numbers represented in binary form or as ASCII code.
2. Analog quantity
When computer application in the control system, the input information is generally from the field of continuous changes in physical quantities, such as temperature, pressure, flow, displacement, humidity, etc., these physical quantities through the sensor and amplified processing to obtain analog voltage or current, These analog quantities must first be converted to digital (A/D conversion) before they can be entered into the computer. In turn, the computer output control signals are digital, you must first through the digital to analog conversion (d/A conversion), the digital conversion to analog capacity to control the scene.
3. Switching volume
The switching volume can represent two states, such as the disconnection and closure of the switch, the operation and stop of the machine, the opening and closing of the valve, etc. These switching volumes are usually subject to a corresponding level shift to connect to the computer. The switching volume is represented by a single binary number.
Two Status information
The status information, as the contact information when exchanging data between the CPU and the peripheral, reflects the working state of the current peripheral, and the peripheral is sent to the CPU via the interface. The CPU can read the signal of the peripheral status to know whether the data of the input device is ready and the output device is idle. For input devices, the ready signal is generally used to indicate whether the data to be entered is ready and, for the output device, whether the output device is idle, such as idle, to receive information about the CPU output, otherwise the CPU will halt the number of sends. Therefore, the status information can ensure that the CPU and peripherals are properly exchanged for data.
Three Control information
The control information is the CPU transmits to the peripheral through the interface, the CPU sends the control information to set up the peripheral (including the interface) The working mode, the control peripheral work. such as the start signal and stop signal of the peripheral is the common control information. In fact, control information often has different meanings depending on how the peripherals work.
Although the meaning of data information, status information and control information are different, in microcomputer system, the CPU can only use input instruction (in) and output instruction (out) to transmit the data through the interface and peripheral, so the state information and control information are transmitted as data information, that is, the status information is used as- input data, and control information as an output data, so that the status information and control information is also transmitted through the data bus. But in the interface, these three kinds of information are stored separately in different registers.
Basic structure of the 7.1.3 I/O interface
The basic structure of the I/O interface is shown in 7.2. Each interface circuit contains a set of registers, CPU and peripherals for information exchange, various types of information in the interface into different registers, generally referred to as the I/O port, referred to as Port (port). The data registers used to hold the data transmitted between the CPU and peripherals (such as numbers, characters, and a particular encoding), and for input/output data buffers, are called data ports, and the status registers used to store peripherals or interface components themselves are called status ports. The control register used to store the control commands that the CPU sends to the peripherals is called the control port.
Just as each storage unit has a physical address, each port also has an address corresponding to it, which is called the port address. With the port address, the external input/output operation of the CPU is actually a read/write operation on each port in the I/O interface. The data port is generally bidirectional, and the data is input or output, depending on the read/write control signal that the CPU sends to the interface circuit when the port address is operated. Because the status port is only input operation, control port only for output operation, so sometimes in order to save the system address space, the interface is often designed to share a port address, and then use read/write signals to select access respectively.
It should be noted that the address used by the input/output operation is always for the port, not for the interface. Interfaces and ports are two different concepts, and several ports, along with corresponding control circuitry, form an interface.
7.1.4 address of the I/O port
There are two ways to address the I/O port in a microcomputer system: I/O port and Memory unit are unified address and I/O port and memory unit.
A I/O port and Memory Unit Unified addressing
This method of addressing, is the I/O port and Memory unit in accordance with the memory Unit address method of the uniform layout of the addresses, by the I/O port address and storage unit address together constitute a unified address space, for example, for a 16 address line of the microcomputer system, if the use of unified addressing method, the address space of the structure 7.3 is shown. With the unified addressing method, the CPU's input/output operation to the I/O port acts as a read/write operation to the memory unit, and all instructions to access it can also be used to access the I/O port, thus simplifying the design of the instruction system without special I/O instructions; The various addressing methods of the memory also apply to the I/O port access, to provide users with great convenience. However, because I/O ports occupy a portion of the memory address space, the address availability range of memory is relatively reduced.
Two I/O port and Memory unit stand-alone addressing
In this method of addressing, two address spaces are established, one for memory address space and one for I/O address space. The memory address space and the I/O address space are relatively independent, by controlling the bus to determine whether the CPU is going to access the memory or the I/O port. To ensure that the control bus sends the correct signal, the system also provides input/output instructions for data transfer between the CPU and the I/O port, in addition to the instructions to access the memory.
The microcomputer system composed of 80X86CPU is used as an independent addressing method. In the 8086/8088 system, there are 20 address lines for memory addressing, the address range of memory is 00000H~FFFFFH, and the I/O port is addressed with the low 16 bits of address bus, so the address range of the I/O port is shown in 0000h~ffffh,7.4. When accessing memory and peripherals, the CPU uses different control signals to differentiate. For example, when the m/io signal of 8086CPU is 1 o'clock, the address on address bus is a memory address, and 0 o'clock, the address on address bus is a port address.
With the Independent addressing method, the memory address space is not affected by the I/O port address space, and the dedicated input/output instruction differs significantly from the access memory instruction for easy understanding and inspection. However, the specialized I/O directives increase the complexity of the instruction system, with fewer I/O instruction types and less flexibility in programming, and require the CPU to provide specialized control signals to differentiate the operation of the memory and I/O ports, adding complexity to the control logic.
Third, address decoding of I/O port
Commonly used in microcomputer system I/O interface circuit is generally designed as a general-purpose I/O interface chip, an interface chip can have a number of addressable ports. Therefore, all interface chips have a chip-select signal line and an address line for on-chip port addressing. For example, there are four port addresses in an interface chip, and there will be two address lines outside the chip. The eighth chapter of this book will detail several commonly used I/O interface chips.
I/O port address decoding method is diverse, the general principle is that the CPU for the I/O port addressing the address line is divided into high address line and low address line two parts, the low address line directly to the I/O interface chip corresponding address pin, to achieve on-chip addressing, that is, select the on-chip port , the high-level address line and the CPU control signal combination, through the address decoding circuit to generate the I/O interface chip selection signal.
The role of IO port