This lecture will cover sections 5.1 through 5.4 from Chapter 5 of the book.
In the beginning …
computer = the one who computes
Origin of modern computing architectures
Jacquard Loom
Charles Babbage’s Analytical Machine
Hollerith Census Machine (eventually becomes IBM)
ENIAC: First computer
Modern computer architecture
von Neuman architecture
General purpose
A binary computer instead of a decimal computer
Stored-program
Logic Gates
Building blocks of the digital circuitry that implements arithmetic, control, and storage functionality in a digital computer.
Logic gates are created from transistors that are etched into a semiconductor material (e.g. silicon chips).
Transistors act as switches that control electrical flow through the chip. A transistor can switch its state between on or off (between a high or low voltage output). Its output state depends on its current state plus its input state (high or low voltage).
2.1 Basic Logic Gates
AND, OR, and NOT form a set of basic logic gates from which any circuit can be constructed.
A
B
A AND B
A OR B
NOT A
NOT B
0
0
0
0
1
1
0
1
0
1
1
0
1
0
0
1
0
1
1
1
1
1
0
0
2.2 Electronic Circuit
Transistors
Electrical currents activate/deactivate other current flows.
Example of AND gate
2.3 Other gates
A
B
A NAND B
A NOR B
A XOR B
0
0
1
1
0
0
1
1
0
1
1
0
1
0
1
1
1
0
0
0
Circuits
Core functionality of the architecture
Instruction Set Architecture (ISA)
Categories
Arithmetic/logic
Control
Storage
All three are contained in a standard processor
3.1. Arithmetic: Addition
Mathematical operations:
Bit-wise with carry
$0 + 0 = 0$
$0 + 1 = 1$
$1 + 0 = 1$
$1 + 1 = 0$ and carry $1$ to the next bit operation (or add 1 to left of the most significant bit position)
This works for both unsigned and 2’s complement notation
Example 1: 4-bit unsigned $2+6=8$
\[\ 0010 \\ +\ 0110 \\ \hline \ 1000\]
Example 2: 4-bit unsigned $11+12=23$
\[\ 1011 \\ +\ 1100 \\ \hline \ 10111\]
Example 3: 4-bit signed $5-7=5+(-7)=(-2)$
Positive to negative conversion in 2’s complement: flipped bit and add 1.
### 3.3. Negation
- Negate through complement and increment:
- `~x + 1 == -x`
- Implement a C program called `negation.c` that implements and validates
the equation in slide 24. The program should take in a command line argument
that takes in a number of type `short` to be negated.
- What happens if you try to negate `-32768`?
:::{dropdown} Solution
<script src="https://gist.github.com/linhbngo/d1e9336a82632c528ea797210ed0f553.js?file=negation.c"></script>
:::