【Lecture2】Computer Systems & Networks
Contents
Digital Logic

- All digital computers are built from a set of low level digital logic switches or Logic Gates.
- Gates operate on binary signals that only have one of two values:
Signals from 0 to 1 volt is used to represent a binary 0 (OFF)
Signals from 2 to 5 volts is used to represent a binary 1 (ON) - Three basic logic functions that can be applied to binary signals:
AND: Output true if ALL inputs are true
OR: Output true if ANY input is true
NOT: Output is the reverse of the input - More complex functions can be build from these three basic gates
Basic Logic Gates

Combinatorial Logic Gates

- NAND: The opposite of the And
- NOR: The opposite of the Or
- XOR: 計算式の中の繰上げ時に使用される
Equivalent of XOR

Math Functions
Half Adders
The simplest math function is the half-adder which can add 2 digits (bits) to give a sum and a carry bit. However, if we want to add more than 1 bit values together we need to deal with the carry. Full-adders accept the two inputs to be added plus the carry from a previous stage.
Full-Adders
The logic to perform “add with carry” combines two half adders together.
Binary Calculation

Contents
- 1. Natural numbers and Integers
- 2. Addition
- 3. Subtraction
- 4. Multiplication
- 5. Division
Natural numbers and Integers
- N: 1, 3, 0, 7 (Natural Numbers)
- Z: -1, -7, -1234, 5, 0, 763 (Integers)
The letter (Z) is the symbol used to represent integers.
Addition

Subtraction
How to represent “-” in binary

- Negative numbers always start with “1”
- Positive numbers always start with “0”
There’s 256 patterns in a bite, but the positive numbers are until 127 and the negative numbers are until -128. This is because 0 is included in “positive”. In total, there are 256 patterns.
つまり、127より大きい数を1バイトで表している場合、それは負の数を表していることになる。256通りの中で負の数と正の数を表す。
Subtraction

Multiplication
Pattern 1

Pattern 2

Division

//Formula (Algorithm)
for n times:
(P,A) >> 1
if P-B >= O:
P = P-B
A = A+1
end if
end for
// A: Numerator, B: Denominator, P: Temporary Variable (0*数字Aの桁数分), N: Word Size (数字Aの桁数)