Originally published by Robert Beisert at fortcollinsprogram.robert-beisert.com

CS 101 – Get on the Bus

As we have discussed previously, computers operate as a huge array of switches, which operate in the “on” and “off” positions. What, we can reasonably ask, defines whether the switch is “off” or “on”?

The answer: electricity.

Buses: Wires connecting switches

The average computer contains many hundreds of feet of wire, designed to carry electrical charges between switches. The wires which travel between different sets of switches (which we already know as “components”) are given particular names, corresponding to their purposes. These sets of wires are referred to as “buses“.

Between the CPU and main memory, for example, we have three general buses: the data bus, the address bus, and the control bus. The purposes of these buses are exactly as described in the name.

The data bus is made of a set of wires sufficient to carry one word of data. In a 32-bit machine, the data bus must contain 32 wires to carry one 32-bit word at a time.

The address bus contains a set of wires sufficient to carry one address. If the size of a memory chip is below 128 GB (aka, all commercial RAM), we need 32 wires to address each word, as we can store up to 2^32 words in 128GB of memory.

The control bus contains enough wires to control every operation the CPU can perform. This means that, if you have only 32 instructions (like many RISC machines in the past), you need 5 wires ( log(2 , 32) ) in your control bus.

USB: Universal Serial Bus

Another commonly employed bus is the Universal Serial Bus (USB). This bus defines a set of wires (four in USB-A, five in Mini/Micro USB) which are used to transmit data at a high rate.

The four wires in the USB-A are:

  • Voltage Supply (5V)
  • Data –
  • Data +
  • Ground (0V)

USB uses “serial” communication – it only sends one bit at a time, on one wire, in a stream. This is opposed to parallel communication, employed in the CPU-Memory buses, in which we send a bunch of bits over a bunch of wires.

The USB system is truly innovative. On each clock cycle (see next post), the computer reads whether the Data + or Data – lines is powered. If the Data – line is powered, the computer reads whatever the previous bit was, and if the Data + line is powered it inverts the previous bit. This is called the Non-Return-to-Zero line code, and is a slightly more advanced topic of discussion.

This is the reason it is “universal”: it can transmit any kind of data, and can do so relatively quickly. It can also supply power, which allows it to charge your phone.