Lecture 10

Input/Output (I/O)

How does our machine communicate with the outside world?

Simplest Solution: Memory Mapped I/O

Connect up the memory so that accessing certain memory locations causes data to be transferred to or from the outside world.

      ______________
    0|              |
    .|              |
    .|    Memory    |
     |              |
     |______________|
a0000|              |
    .|    I/O       |
     |______________|
b0000|              |
    .|              |
    .|    Memory    |
     |______________|
This diagram shows which parts of the memory are used for storage and which for I/O, it is called the memory map.

For example, the screen on a PC is mapped into memory between address 0xa0000 and 0xaffff. Writing to one of these memory locations causes a dot to appear on the screen.

 ______________
|012345...     |
|              |
|   Screen     |
|              |
|______________|

Interrupts

Memory Mapped I/O is good for output but not for input if it is not known when the input will happen. Such input is called Asynchronous input and is very common.

For example: consider keyboard input. Using Memory Mapped I/O, there may be a memory location holding the ASCII value of the key currently being pressed. The CPU could keep looking at this memory location to see if an input has occurred (this is what my cpu in lecture 8 did).

Unfortunately, the CPU can now do nothing else because if it looked away from the keyboard I/O location, it may miss a key-press (in fact my cpu is so slow that it does sometimes miss key presses).

Better is if the CPU can be told when data is ready. The input device interrupts the CPU to tell it that data is ready.

Interrupt driven I/O

The control bus has an extra signal that can interrupt the CPU called the interrupt request (IRQ). In order for the CPU to identify which device caused the interrupt, each device must identify itself. On a PC this is done by an 8 bit number called the IRQ number. The device will also have memory mapped I/O.

I/O Controllers

For I/O that transfers large quantities of data, it is inefficient for the CPU to be interrupted for each word of data. In this case an I/O Controller can be used to perform the complete I/O operation. The Controller will have access to the Address and Data Bus and perform the I/O while the CPU is free for other things.

Common I/O Devices

Serial

The bits in the data are transferred one at a time. Speed is measured in Bits per Second (bps).

Parallel

Data is transferred as whole words.