Valves and Sponges
© 22 Sep 2014 Luther Tychonievich
Licensed under Creative Commons: CC BY-NC-ND 3.0
other posts

A low-level survey of computer hardware.

 

Water is Like Power

You can compare electricity to water. Voltage is pressure; current is quantity of flow.

A transistor is an electric valve. It’s got three wires; if you push against the one in the middle then current can flow between the other two. If you don’t push, it can’t.

A resistor is like a sponge. Putting it in a pressurized system with no flow won’t reduce the pressure, but putting it in a system that has flow will impede the flow and reduce the pressure on its far side.

Logic Gates

Consider the following arrangement of valves and sponges, attached to a large pool of water:

If there is pressure coming in both pipes to the left then the pressure of the pool of water up above will carry through to the pipe to the right (and some will drain out through the sponge). If either of the left pipes does not have pressure, however, the right pipe also won’t have pressure because it will be lost through the sponge. This is what we call “‍an AND gate‍” because you get output pressure only if both the first input AND the second input have pressure.

Consider the following arrangement of valves and sponges, attached to a large pool of water:

If there is pressure coming in either pipes to the left then the pressure of the pool of water up above will carry through to the pipe to the right (and some will drain out through the sponge). If neither of the left pipes does have pressure, however, the right pipe also won’t have pressure because it will be lost through the sponge. This is what we call “‍an OR gate‍” because you get output pressure only if either the first input OR the second input have pressure.

Consider the following arrangement of valves and sponges, attached to a large pool of water:

If there is pressure coming in the pipe to the left then no pressure goes out the pipe to the right When the NOT gate I’ve drawn has no output pressure, a lot of water drains from the pool. You can reduce this drainage by adding more sponges, but doing so slows down how quickly pressure can move. If there is no pressure coming from the pipe to the left then there is pressure going out the pipe to the right. This is what we call “‍a NOT gate‍” because you get output pressure only if you do NOT have input have pressure.

Consider the following arrangement of valves and sponges, attached to a large pool of water:

If there is pressure coming in both pipes to the left then no pressure makes it out the pipe to the right; but if either of the left pipes does not have pressure the right pipe will have pressure. This is what we call “‍a NAND gate‍” because you do Not get output pressure only when both the first input AND the second input have pressure.

By combining the gates above you can encode quite complicated ideas like the idea that the 2’s-place bit of binary addition is (a0 AND b0 AND ((a1 AND b1) OR (NOT a1 AND NOT b1))) OR ((NOT a0 OR NOT b0) AND ((a1 AND NOT b1) OR (NOT a1 AND b1))).

Memory

Consider the following rather odd-looking but almost magically-powerful arrangement of valves and sponges, attached to a large pool of water:

This is what is called a D flip-flop and its electronic version used as a register, which is a kind of on-chip memory, in modern computers. Let’s try to walk through how it might work. This can be messy because there are many possible states…

Let’s assume initially all the valves are closed. That means pressure will flow down the red, green, blue, magenta, yellow, and orange pipes. Pressure in red and blue will make the pressure in magenta go away. Pressure in yellow and blue will make orange’s pressure go away, giving us the stable condition where blue, green, red, and yellow have pressure (BGRY):

BGRY

The last step could have gone the other way: green and orange might make yellow go away instead of blue and yellow making orange go away, depending on how quickly pressure propagates through the different pipes; if it had gone the other way wed have a different stable condition: blue, green, orange, and red have pressure (BGOR):

BGOR

Observe that these stable conditions represent two different output (orange) pressures with no input (cyan and black) pressures. We can thus say that BGOR “‍remembers‍” an “‍on‍” or “‍high-pressure‍” state, while BGRY “‍remembers‍” an “‍off‍” or “‍low-pressure‍” state.

There are actually eight total stable states for this collection of valves, pipes, and sponges:

We can get between theses states by adding and removing the two input pressures in the cyan and magenta pipes. For example, adding cyan to the BGOR state will cause green to lose pressure, which will add pressure to yellow, which will drain pressure from orange, giving BCRY:

BGORBCRY

You can walk through the same process for each of the other 15 possible transitions, adding or removing pressure from one of the inputs from one of the states.

The key property of this arrangement that makes it useful is that the output (orange) “‍remembers‍” (that is, continues to produce) the pressure that the black input had when the cyan input last transitioned from low- to high-pressure. If we have a value we want to remember we pipe it into one of these D flip-flop contraptions via the black input; then, once we are sure the black input is stable, we put pressure on the cyan input. After that we can freely mess with the black input and drain pressure from the cyan input knowing the orange output will retain its pressure until the next time we add pressure to the cyan input.

The logic-register loop

Most of what a computer does is a combination of combinational logic (that is, networks of logic gates) and registers (like the D flip-flop above). Both the inputs and outputs of the combinational logic are registers: they all feed in a big, complicated loop. Thus the state where the registers represent “‍about to do step 1‍” in whatever process they are doing transitions to the state where the registers represent “‍just did step 1; now about to do step 2‍”, and so on. The cyan input to all registers, called “‍the clock‍” is pulsed, high-low-high-low at regular intervals which keeps all this looping logic in sync.




Looking for comments…



Loading user comment form…