Computer Operations Explained with Gate Circuits
1. Computer
- The film "Hidden Figures (2016)" tells the true story of the African American women mathematicians whose work helped make NASA’s space program successful.
- In this film, the women mathematicians hold the job title "computer."
- A computer is a machine that performs calculations. But how does it actually carry them out?
- A computer performs logical and arithmetic operations using "Gate Circuit"s made up of numerous transistors.
2. Operation
2.1. Basic
- When current flows (ON), the light bulb turns on, and when it does not flow (OFF), it turns off.
※ In actual physics, the electrons that create electric current move from (–) to (+). However, before electrons were known to exist, Franklin defined electric charge as moving from (+) to (–), and that convention remained in use for a long time. As a result, even today, the direction of current is conventionally described as flowing from (+) to (–).
2.2. Transistor
- A Semiconductor can either allow electricity to flow or block it.
- One representative example is the Transistor, which uses this property of semiconductors to control the flow of current.
👉 circuitjs-transistor
2.3. Gate
- Using transistors, we can implement the basic operations AND, OR, NOT, NOR, XOR.
- These are called Gate Circuits, and by combining multiple gates, we can build complex digital logic circuits.
👉 circuitjs-gate_xor
2.3.1. AND Gate
- ON when both X and Y are ON
2.3.2. OR Gate
- ON when either X or Y is ON
2.3.3. NOT Gate
- ON when X is OFF
2.3.4. NOR Gate
- ON when both X and Y are OFF
2.3.5. XOR Gate
- ON when X and Y are different
3. Adder
- An adder is a circuit that performs addition.
- A computer’s CPU is built on countless adders, which form the basis of all operations.
- Multiplication is repeated addition, subtraction is handled as addition using a complement, and division is performed through repeated subtraction.
[Source] Intel - The Transistor, Explained
※ A complement is, mathematically, a number that fills in the amount missing from a reference value.
- In computers, complements are used to convert subtraction into addition. In other words, subtraction A - B is calculated by converting it into addition A + (the two’s complement of B).
- One’s complement: the value obtained by inverting the bits
- Two’s complement: the value obtained by adding 1 to the one’s complement
5 - 3 = ?
※ 0011 (3) → 1100 (one’s complement of 3) → 1101 (two’s complement of 3)
0101 (5) + 1101 (two’s complement of 3) ------- 10010 ∴ Discard the leftmost 1 bit (overflow) from the 5-bit result → 0010 (2)
3.1. Half Adder
- A circuit that adds 2 bits
3.2. Full Adder
- A circuit that adds 3 bits
3.3. Adder Example
10 (2) + 11 (3) ------ 101 (5)
👉 circuitjs-adder
3.3.1. First Bit
Half Adder
A(0), B(1) → S=1, C=0
📟 1
3.3.2. Second Bit
Full Adder
A(1), B(1), C(0) → S=0, C=1
📟 0
3.3.3. Third Bit
Full Adder
A(0), B(0), C(1) → S=1, C=0
📟 1
3.3.4. Result
1 0 1