Interface Technology Chapter VI - input and output interface and data transfer control summary

We are learning interface technology and computer composition principle, there is some overlap in the middle part of it put together, as DMA, interrupt and the like will be explained on the back

6.1 Interface Overview

Hardware interface is commonly referred to as I / O interface, the peripheral circuits connected with the microcomputer called peripheral interface circuit, referred to as the peripheral interface. I / O interface, a CPU transfer station for the exchange of information with the outside world

Why use interface

  1. An outer peripheral slow speed mismatch
  2. Timing mismatch external device has its own individual timing control circuit, its own transmission speed, the CPU does not match with the timing
  3. It does not match the information format, different formats for storing and processing information peripherals
  4. Type mismatch information, some digital circuits, analog circuits and some

 

The type of data transfer between the CPU and peripherals

  1. Data information including analog, digital, digital, input can be output
  2. This state information is the information about the current state of the peripheral port corresponding to this I / O port to the CPU's, CPU for reference analysis
  3. This information is sent to CPU control I / O device control command, the corresponding external device to perform specific operations

In 8086/8088, the three input and output information are basically the same, different port addresses can be distributed, at the same port address, the order of the operations may be predetermined, or set the flag in the data input

 

Functional interface (back)

  1. CPU control command execution command of the CPU will be sent to the peripheral interface circuit of the command register to control peripheral working as expected
  2. Peripheral status Returns peripheral registers (opening state) is completed, comprising a normal operating condition and a fault condition
  3. Data buffering function (smoothing effect) interface data register circuit (data port) of data between the CPU and peripheral device transit
  4. Address information of the device addressing functions of the CPU at certain time and only a peripheral exchanging data, sent via the CPU interface circuit of the selected address decode I / O device
  5. ADC conversion signal conversion function, ah, ah level conversion and the like
  6. Function string data width of parallel data format conversion functions such transformed

 

 

Port and addressing modes

Refers to the address port interface circuit microprocessor can directly access the register

The microprocessor sends a command to the interface circuit through which the register address (port), read status, and transmitting data.

Computer interface circuits to each register is assigned a port, CPU at the time of the visit, they only need to specify the port address does not need to know what is the access register. Thus, access port is a register access interface circuit in the input output program of said IO operations that normally operate on the IO port, i.e., CPU associated with the accessed ports IO device, the device itself rather than IO

 

 

 

 

 

Input and output mode

Input / output interface Category:

       1, according to the data transfer points: serial, parallel,

       2, peripheral access by CPU control:

          Program queries, interrupt, DMA, channel control, I / O processor

       3, according to the need for a unified control clock: synchronous, asynchronous

       4, according to GM: GM, for

 

IO port addressing modes

Register image addressing and independent addressing

Register Addressing the IO port address is placed in memory space, and a storage unit for compiling

Advantage: various addressing modes can be used to address the memory port (can use a command system), disadvantage: occupy a memory address and the port address and the memory must be the same length, running slow

Independent addressing: the port address individually addressable interface, forming two independent addressing space in the computer. Pros: do not take up storage space, a dedicated IO instruction, IO command, run fast, and separate IO operations and memory operations, readability is good, the disadvantage is to re-design a new instruction set

 

IO port address decoding

Three kinds of decoding circuit - fixed port address decoder, the fixed decoding circuit and an optional multi-port address decoding circuitry formula

 

  1. Fixed single port address decoding circuitry

Fixed single port address decoding circuitry means that the port address decoding circuit can generate a unchangeable

See notes and textbook 240

 

  1. Fixed multi-port address decoding circuitry

Fixed multi-port address decoding circuitry can be translated simultaneously a plurality of addresses, each address is fixed

The 74LS138 (38 decoder), 74LS154 (4-16 decoder), 74LS139 (2-4 decoder)

 

FIG 74138 symbols as follows

 

 

 

 

 

A0-A2 are input, Y0-Y7 is an output terminal, E2a and E2b active low, high effective E1, which is a three-enabled client, the E2A and E2B are active low, a high electric E1 effective level

  1. Selectable address decoding circuitry

If the user requests to leave the extended space port address of the interface circuit to adapt to different situations of address assignment, or after the system

It describes an alternative type decoding circuit composed of a comparator

 

 

 

首先要知道这个如何工作,就得先知道比较器和三八译码器如何工作

三八译码器的工作原理在上面,不赘述了

下面来讲讲74LS85比较器

这玩意有八个端子,A0-A3,B0-B3,我们观察到,A=B是连在了VCC上,所以这个玩意的功能是要求A和B要想等

那这个东西的比较法则如何呢

真值表如下

 

首先比较高位,高位不相等直接输出

然后逐位开始比较,到最后都相等的时候,输出A=B端口为1

如果A=B,则输出和输入是相等的

如果A<B,  则输出中A<B is high with A=B and A>B is low

反之亦然

所以该比较器可选译码电路就是如下原理

A8-A11连接了74LS85芯片的A0-A3,现在当S0-S3的开关都打开,则B0-B3为1111,则A0-A3为1111,则A8-A11为1111

A6,A7为38译码器的使能端,为00

A3-A5为选择端口,如果选择Y2,则A5-A3为010

A0-A2为任意

 

IO指令

  1. IO端口寻址 分为两种,直接寻址和间接寻址
    1. 直接寻址,范围是0-255

指令格式 IN AL,32H ;32H为8为端口地址

  1. 间接端口寻址

间接端口寻址由DX寄存器指出端口地址

指令格式为 IN AL,DX

记住,间接端口寻址的范围是0-65535,必须要通过DX来间接寻址

2 IO操作指令

  1. 输入指令

格式: IN 累加器,端口

例如:IN AL ,21H ;把端口21H的8位数据放入AL中

         MOV DX,210H

         IN AX ,DX;把端口210H和202H放入AX中

  1. 输出指令

格式 OUT 端口,累加器

OUT 22H,AL;把AL的内容放入22H中

MOV DX,511H

OUT DX,AX

 

 

 

 

CPU与外设数据的传输控制方式

有三种形式:程序查询,中断,DMA,(大型机巨型机的通道)

程序控制方式是指输入输出指令实现信息传输的方式,是一种软件控制方式,根据程序控制的方法不同,可以分为无条件传输方式和有条件传输方式

 

无条件传输

 

 

 

这个无条件选择就是当RD为低电平(非门转化为1),IO/M(上划线)为高电平的时候,与门为1,经过两个非门后为1,到三态缓冲器,三态缓冲器打开,数据经数据总线送到CPU中

输出类似

 

在这种方式下,CPU不需要知道外设的工作状态,只需每隔一段时间,CPU与外设进行数据交换,进行数据的发送和接受

 

有条件程序查询式

条件传送方式又称查询方式,即通过程序查询相应设备的状态,如果该设备未处于“准备好的状态”则CPU不能进行输入输出操作

逻辑图如下:

 

 

具体电路图如下:

 

当输入设备准备好数据之后,发出选通信号。它一方面把输入数据锁存到数据锁存器中,另一方面使状态标志触发器置1。状态标志是一位信号,通过缓冲器后,接到CPU数据总线的某一位上,假设接至D7位。CPU先读状态口,查询D7是否为1。若D7=1,表示输入数据已经准备好,再读数据口,取走输入数据,同时使状态标志触发器复位。

 

数据传送过程的3个步骤:

①CPU先读取状态字

②检查状态字是否表明数据准备就绪

③如果准备就绪,则执行输入指令读取数据,且使状态位清零。这样便开始下一个数据传输过程。

 

/*****自我总结

输入的工作原理如下:

当外设准备好的时候,会发送选通信号,一方面数据进入锁存器,另一方面触发器D,使READY信号发送。当CPU来读的时候,IO/M选通,RD为0,地址译码,与门输出为1,经过两个非门为1,三态缓存器选通,READY信号通过数据总线送到CPU,然后开始开始读锁存器内的数据,同时状态位清零

******/

输出的电路图如下

 

输出过程:

  当前输出设备空闲时,状态标志触发器清0。

  CPU在输出数据之前,先读取状态信息。假设忙闲标志接至数据线D0位,当D0=0时,表示输出设备空闲,CPU再对数据口执行输出指令。

  数据口选中信号一方面把输出数据写入锁存器,一方面使状态标志触发器置1,通知输出设备。当输出设备取走当前数据后,向接口发出确认信号ACK,使状态标志触发器清0, 表示输出设备空闲。

 

/******自我总结

工作原理:CPU通过地址总线,经过地址译码器,输出数据端口,IO/M为0,WD为1,发送选通信号,数据进入接口锁存器和触发器D为1,这个D有两个作用,一个告诉外设可以读取数据了,另一个让状态寄存器为BUSY,防止CPU继续写数据。

当外设把数据都读完后,回送一个ACK,让触发器复位,D为0,清空状态寄存器。

*******/

总结:得多看看,每次传送数据的时候都会有一个状态信息,然后读完数据都会复位

优点:软件比较简单

缺点:CPU效率低,数据传送的实时性差,速度较慢

 

中断

   中断控制的输入和输出方式,也称中断传送方式,即当外设的输入数据准备好或接收数据的锁存器为空时,主动向CPU发出中断请求,使CPU中断原来执行的程序(主程序),转去执行为外设服务的输入或输出操作,服务完毕,CPU再继续执行原来的程序。 

   中断传送方式中, CPU和外设(甚至多个外设)可同时工作, 从而大大提高了CPU的效率和控制程序执行的实时性。必须经过 (1)暂停主程序,实现程序的转移,即中断响应。(2)保护和恢复有关寄存器内容。(3)执行I/O操作,并实现内存到累加器再到端口之间的传送。(4)实现中断返回。

 

输入设备将数据送到锁存器中,同时发送选通信号,选通信号一方面让数据进入三态缓冲期,另一方面令D为1,经过与门让INTR为1,发送中断请求。当CPU收到中断请求之后,会通过地址译码器和读写信号,经过与非门。与非门发送的信号一方面打开三态缓冲期,让数据进入数据总线,另一方面复位触发器,D为0.中断完成。

DMA
数据在I/O接口与存储器之间的传送,不经CPU的干预,而是在专用硬件电路的控制下直接传送。这种方法称为DMA 。在这种方式下,传送的速度就只取决于存储器和外设的工作速度。这大大提高了数据传送速度。

DMA传送主要应用于高速度大批量数据传送的系统中,如磁盘存取、图像处理、高速数据采集系统等,以提高数据的吞吐量。

DMA传送一般有三种形式

①存储器与I/O设备之间的数据传送;

②存储器与存储器之间的数据传送;

③I/O设备与I/O设备之间的传送。

 

DMA控制器必须有以下功能:

①能接收外设发出的DMA 请求信号,然后向CPU 发出总线接管请求信号。

②当CPU发出总线请求允许信号并放弃对总线的控制后,DMAC能接替对总线的控制,进入DMA方式。

③DMAC得到总线控制权后,要往地址总线发送地址信号,能修改地址指针,并能发出读/写控制信号。

④能决定本次DMA传送的字节数,判断DMA传送是否结束。

⑤DMA过程结束时,能发出DMA 结束信号,将总线控制权交还给CPU

 

计原中一些概念

输入输出系统:主要作用是连通计算机的各个功能部件和设备,在它们之间进行数据交换。

输入输出系统的基本功能:是管理主机和外设以及外设与外设之间的信息交换,由硬件和软件共同完成此项任务,基本原则是:不丢失数据,快速传输数据,成本低廉,主机和外设、外设和外设之间尽可能并行工作已充分发挥各自的潜力

输入输出设备的重要任务

  1. 将用户编写的程序/数据输入至主机
  2. 将计算结果输出给用户
  3. 实现输入/输出系统与主机协调工作

 

计算机总线:计算机各部件之间的公共通道(包括数据总线,控制总线和地址总线)

主机与外设的接口信息

  1. 数据信息 可以通过输入设备送到计算机的输入数据
  2. 控制信息 CPU对外设的控制信息或管理命令
  3. 状态信息 表示外设的状态
  4. 联络信息 主机和外设间工作的时间配合信息
  5. 外设识别信息 I/O寻址的信息

 

数据传送的方式:异步和同步

CPU访问的方式:程序查询式,中断式,DMA式,通道式

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/Kevin-Weng/p/11961346.html