Review: communication with the memory

We have just studied the READ bus protocol used to communicate with the memory:

 

Communication with IO devices

We will now study how the CPU communicates with an IO device:

IO communication is a very complex problem and is solved using both hardware and software (interrupt handler !!)

Background information

IO devices are attached to the computer system:

Background information

An IO device is physically made up as 2 functional parts:

  • The "actual" Input/Output device:

      • The hardware that performs the input/output task        

  • The interface:

      • The digital circuits that connects to the system bus that enable the CPU and IO device to exchange data        

The "actual" IO device hardware
 

  • There are too many different kinds of IO devices

    Small sample: keyboard, mouse, touch screen, microphone, camera, ...

  • Common feature of the "actual" IO device:

      • Input devices can gather input and convert them into binary representation for processing

      • Output devices can receive binary data and present them in human-friendly representation for user "consumption"

  • In CS355, we do not study IO devices ("peripherals")

In CS355, we study how the computer system exchange data with an IO device through the interfac

The IO interfact and connection on the system bus
 

An IO interface consists of 2 different sets of circuits:

 

The IO interfact and connection on the system bus
 

The IOinterface contains special purpose registers that are connected to the system bus:

The registers are connected to the system bus in the same way as the memory circuit !!!

The IO interfact and connection on the system bus
 

How does the CPU perform an IO operation (= give a command to an IO device):

The CPU sends the command (= data) to an IO device using the bus protocol !!!

The IO interfact and connection on the system bus
 

How does the CPU input/ouput data from/to an IO device:

The CPU sends the read/write the data from/to an IO device using the bus protocol !!!

The IO interfact and connection on the system bus
 

Because IO devices are relatively slow (compared to CPU), the status register can be read to check for readiness:

The CPU reads the status register from an IO device using the bus protocol !!!

How does the CPU perform an IO operation
 

Example: the CPU wants to print the letter 'A'

 

How does the CPU perform an IO operation
 

The CPU first writes the ASCII code for 'A' to the data register of the printer:

 

How does the CPU perform an IO operation
 

CPU then writes the command code for 'output' to the command register of the printer:

The command will start the output device (printer) to output the data in the data register !

How does the CPU perform an IO operation
 

While the printer is busy printing, the status will reflect that the IO device is not ready:

Note: the IO device will usually have a larger buffer that allows the CPU to write more data before the IO device become "not ready"

The naive way to perform IO communication
 

Consider the following naive way to print (all the characters in) a file:

  while (not EOF)
  {
     Write next character to the printer's Data register
     Write the OUTPUT command to the printer's Command register 

     Read the printer's Status register
     while ( status != READY )  // BUSY wait
        Read the printer's Status register
  } 

The naive way does work...

However: while the CPU is printing the file, the whole computer will stop working (because the CPU is busy printing the file !!!)

(Printing a large file can take a long time !!!)

Difference between memory communication and IO communication
 

  • A CPU executes one (=1) instruction in less than one (=1) nano second

    (We do not want to waste this precious resource !!!)

  • Memory can perform a data transfer operation in about 3-10 nano seconds ( see: memory speeds)

  • IO devices (e.g., hard drives) usually have several milliseconds data access times (because the IO device contain moving parts and these mechanical parts can only move very slowly compared to electrical current) !!!
 

Hence: (new) off-line communication techniques must be used in the communication between CPU and an IO device whereby the CPU do not have to wait !!

How we will discuss the IO communication technique

We will discuss the following 3 topics to understand IO communication:

  • Addressing:

      • How does the CPU identify an IO device

  • Data transfer:

      • We will introduce a helper device (DMA) to relieve the CPU from transfering the data from/to the IO device

  • Synchronization:

      • A computer program that performs an IO operation must release the control of the CPU
      • How is the CPU control released ?
      • And how does the computer program reclaim the CPU when its data transfer operation has completed ?