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 āύā§āĻŦā§:
- CPU address bus-āĻ port-āĻāϰ address āĻĻā§ā§āĨ¤
- Control bus-āĻ I/O Read signal āĻĻā§ā§āĨ¤
- āύāĻŋāϰā§āĻŦāĻžāĻāĻŋāϤ port data bus āĻĻāĻŋā§ā§ CPU-āϤ⧠data āĻĒāĻžāĻ āĻžā§āĨ¤
I/O write āĻā§āĻāĻžāĻŦā§ āĻšā§?
CPU āĻāĻāĻāĻŋ output port-āĻ data āĻĒāĻžāĻ āĻžāϤ⧠āĻāĻžāĻāϞā§:
- Address bus-āĻ port-āĻāϰ address āĻĻā§ā§āĨ¤
- Data bus-āĻ āĻĒāĻžāĻ āĻžāύā§āϰ data āϰāĻžāĻā§āĨ¤
- 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âāĻā§āĻ āĻāϤā§āϤāϰāĻ āϝāĻĨā§āώā§āĻ:
- The CPU receives keyboard data through a port. Is this I/O read or memory read?
- During an I/O write, in which direction does data flow?
- Which bus carries the port address?