A car wash, such as the one shown above, operates as a pipeline. Pipelines break jobs down into a sequence of specialized stages. Each stage is performed by a separate person (or team of workers), using specialized methods and/or tools, on a continuous stream of cars moving through the pipeline.
In each Pipeline Period (the columns in the diagram above the photo), each of five stages in the Car-Wash Cycle can be performed: Rinse 1, Soap, Scrub, Rinse 2, and Dry. The cars moving through the pipeline are shown as rows in the diagram, with the labels Car 1, Car 2, Car 3, ... at the left of each row.
For example, in pipeline period 5 (column 5 in the diagram above), Car 1 is being dried, Car 2 is receiving rinse 2, Car 3 is being scrubbed, Car 4 is being soaped, and Car 5 is receiving rinse 1.
Most microprocessors have pipelines that work like a car-wash pipeline, except that microprocessors execute instructions rather than wash cars, and they do so billions of time faster than cars can be washed.
The stream moving through the pipeline is the sequence of instructions being processed. In each Clock Period (the columns in the diagram above), each of five stages in the instruction cycle can be performed: IF (instruction fetch), ID (instruction decode), EX (execute), MEM (memory access), and WB (write back to a short-term storage register). The instructions moving through the pipeline are shown as rows in the diagram, with the labels Instruction 1, Instruction 2, Instruction 3, ... at the left of each row.
For example, in clock period 5 (column 5), Instruction 1 is in the WB stage, Instruction 2 is in the MEM stage, Instruction 3 is in the EX stage, Instruction 4 is in the ID stage, and Instruction 5 is in the IF stage.
Here is the typical plumbing for a faucet in a household sink. The visible valves (Valve #1 and Valve #2) and spout are shown at the top. The shut-off valves installed beneath the sink (Valve #3 and Valve #4) are shown at the bottom.
There are two valves for hot water (Valves #1 and #3) and two valves for cold water (Valves #2 and #4). For water to flow out of the spout, the lower valve AND the upper valve for the hot water must be open, OR the lower valve AND the upper valve for the cold water must be open.
Logic Gates Depicting a Water Faucet
Computer engineers use logic gates to depict the flow of information through electronic circuits. Each logic gate has one or more inputs and one output. In many cases, these logic gates work like water faucets.
The logic diagram above depicts the water-faucet plumbing shown at the left. The diagram has two AND gates (blue) and one OR gate (orange). The inputs on the AND gates correspond to the water-faucet valves. The output on the OR gate corresponds to the water-faucet spout.
If both inputs to an AND gate are open (meaning both water valves are turned on), the output is also open so that water can flow to the attached input to the OR gate. If either input to the OR gate is open, the output (representing the water spout) is also open and water can flow out.
Road Intersection With Inputs and Outputs
Road intersections controlled by traffic lights work like Internet routers. They arbitrate access to the intersection among the road segments that the intersection connects.
In the figure above, each road segment of the intersection is labeled with an input number—In 1, In 2, In 3, In 4. Each road segment leaving the intersection is labeled with an output number—Out 1, Out 2, Out 3, Out 4. These labels correspond to the input and output numbers in the diagrams shown on the right.
The road intersection has multiple lanes in each direction. Traffic arrives at input 1 (In 1) in lanes that are assigned to specific outputs:
- Lane Out 1 is a U turn.
- Lane Out 2 is a left turn.
- Lane Out 3 is straight through.
- Lane Out 4 is a right turn.
The arrival lanes act as buffers (queues) for cars awaiting transit through the intersection.
Internet Router With Inputs and Outputs
The top diagram, above, depicts the road intersection shown on the left. The bottom diagram depicts a geometrically equivalent version that represents an Internet router. The bottom diagram was derived from the top diagram by simply twisting the inputs and outputs (colored boxes) to rearrange them, without changing the connections (representing roads or communication channels) between inputs and outputs.
The road intersection functions like an Internet router with multiple lanes (called queues) at each input. Each lane on an input serves a specific output. The small, colored boxes in the lanes of the diagram above represent data packets. These data packets correspond to cars waiting in departure lanes at an intersection until it is their turn to move through the router.
This type of router is called a virtual-output-queue (VOQ) router.
Cooking Dinner in a Kitchen
The figure above shows dinner being prepared in a kitchen. The recipes and ingredients are stored in the cupboards. The cooking is done using the cook top or oven. During cooking, ingredients are placed in short-term storage so that the cook can access them more quickly than if they remained in the cupboards.
The procedure for cooking dinner is:
1. Groceries and Cookbooks (input) are brought into the kitchen and stored in the cupboards (Main Storage).
2. The cook takes cookbook Recipes (instructions) and Ingredients (data) from the cupboards and places them on the cook top or in Short-Term Storage.
3. The cook uses the cook top for Cooking (processing).
4. The finished Dinner (output) is taken to the dining table.
Processing Data in a Computer
Most general-purpose computers have a stored-program organization, in which both Instructions (programs) and Data (the information that instructions operate on) are stored in the same memory, called Main Storage or Main Memory. The figure above shows this organization.
The processing of data works much like the cooking of food. The recipes and ingredients for cooking are comparable to the instructions and data in a computer. The computer’s main storage can accept Input and provide Output, through which data and instructions flow between main storage and the external environment—usually a disk drive or network connection.
The Processing is done by applying Instructions, copied from Main Storage, to data that is moved between Main Storage and Short-Term Memory. The short-term memory typically consists of registers and cache memory, which can be accessed much faster than the main storage.