04 Input and output

āĻāĻ—ā§‹āχāĨ¤ āĻļ⧁āϧ⧁ āφāϗ⧇āϰ check-āĻāϰ āωāĻ¤ā§āϤāϰ āĻŽāύ⧇ āϰāĻžāĻ–ā§‹: active-low signal 0 āĻĨ⧇āϕ⧇ 1 āĻšāϞ⧇ inactive āĻšā§ŸāĨ¤

āĻāĻŦāĻžāϰ Input and Output Devices — §2.2.4, āĻŦāĻ‡ā§Ÿā§‡āϰ āĻĒ⧃āĻˇā§āĻ āĻž ā§§ā§ŠāĨ¤

CPU āĻŦāĻžāχāϰ⧇āϰ āϝāĻ¨ā§āĻ¤ā§āϰ āĻĨ⧇āϕ⧇ data āĻ¨ā§‡ā§Ÿ input port āĻĻāĻŋā§Ÿā§‡ āĻāĻŦāĻ‚ āĻŦāĻžāχāϰ⧇āϰ āϝāĻ¨ā§āĻ¤ā§āϰ⧇ data āĻĒāĻžāĻ āĻžā§Ÿ output port āĻĻāĻŋā§Ÿā§‡āĨ¤ āĻāĻ–āĻžāύ⧇ port āĻŦāϞāϤ⧇ CPU āĻ“ peripheral-āĻāϰ āĻŽāĻ§ā§āϝ⧇ data āφāĻĻāĻžāύāĻĒā§āϰāĻĻāĻžāύ⧇āϰ interface āĻŦā§‹āĻāĻžāĻšā§āϛ⧇; āĻļ⧁āϧ⧁ āĻŦāĻžāχāϰ⧇āϰ cable connector āύ⧟āĨ¤

Operation Direction Example
Input Peripheral → CPU Keyboard āĻĨ⧇āϕ⧇ key-āĻāϰ āϤāĻĨā§āϝ āύ⧇āĻ“ā§ŸāĻž
Output CPU → Peripheral Printer-āĻ āĻ›āĻžāĻĒāĻžāύ⧋āϰ data āĻĒāĻžāĻ āĻžāύ⧋

Exam answer:

“Input and output ports provide interfaces for transferring data between the microprocessor and external peripherals. Input ports receive data from peripherals, whereas output ports send data to peripherals.”

I/O read āϕ⧀āĻ­āĻžāĻŦ⧇ āĻšā§Ÿ?

āϧāϰ⧋, CPU āĻāĻ•āϟāĻŋ input port āĻĨ⧇āϕ⧇ data āύ⧇āĻŦ⧇:

  1. CPU address bus-āĻ port-āĻāϰ address āĻĻā§‡ā§ŸāĨ¤
  2. Control bus-āĻ I/O Read signal āĻĻā§‡ā§ŸāĨ¤
  3. āύāĻŋāĻ°ā§āĻŦāĻžāϚāĻŋāϤ port data bus āĻĻāĻŋā§Ÿā§‡ CPU-āϤ⧇ data āĻĒāĻžāĻ āĻžā§ŸāĨ¤

I/O write āϕ⧀āĻ­āĻžāĻŦ⧇ āĻšā§Ÿ?

CPU āĻāĻ•āϟāĻŋ output port-āĻ data āĻĒāĻžāĻ āĻžāϤ⧇ āϚāĻžāχāϞ⧇:

  1. Address bus-āĻ port-āĻāϰ address āĻĻā§‡ā§ŸāĨ¤
  2. Data bus-āĻ āĻĒāĻžāĻ āĻžāύ⧋āϰ data āϰāĻžāϖ⧇āĨ¤
  3. Control bus-āĻ I/O Write signal āĻĻā§‡ā§ŸāĨ¤

āĻŦāĻ‡ā§Ÿā§‡āϰ notation-āĻ IOR āĻ“ IOW-āĻāϰ āĻ“āĻĒāϰ āĻĻāĻžāĻ— āĻĨāĻžāĻ•āϞ⧇ āϏ⧇āϗ⧁āϞ⧋ active-low signalāĨ¤

Memory operation-āĻāϰ āϏāĻ™ā§āϗ⧇ āĻĒāĻžāĻ°ā§āĻĨāĻ•ā§āϝ

āĻĒāĻĻā§āϧāϤāĻŋāϟāĻŋ āĻĒāϰāĻŋāϚāĻŋāϤ: address āĻĻ⧇āĻ“ā§ŸāĻž, control signal āĻĻ⧇āĻ“ā§ŸāĻž, data transfer āĻ•āϰāĻžāĨ¤ āĻĒāĻžāĻ°ā§āĻĨāĻ•ā§āϝ āĻšāϞ⧋ āĻ•āĻžāϕ⧇ access āĻ•āϰāĻž āĻšāĻšā§āϛ⧇āĨ¤

Operation What is accessed? Data direction
Memory read Memory location Memory → CPU
Memory write Memory location CPU → Memory
I/O read Input port Port → CPU
I/O write Output port CPU → Port

Exam answer: I/O read operation

“The microprocessor places the port address on the address bus and activates the I/O read signal. The addressed input port then transfers data to the microprocessor through the data bus.”

Quick check—āϛ⧋āϟ āωāĻ¤ā§āϤāϰāχ āϝāĻĨ⧇āĻˇā§āϟ:

  1. The CPU receives keyboard data through a port. Is this I/O read or memory read?
  2. During an I/O write, in which direction does data flow?
  3. Which bus carries the port address?