Documente Academic
Documente Profesional
Documente Cultură
Basic abstractions.
• On, off.
• Wire: propagates on/off value.
• Switch: controls propagation of on/off values through wires.
Wires
power
connection
1
4
Controlled Switch Controlled Switch
control OFF
control OFF
input ON output ON
Controlled Switches: A First Level of Abstraction Controlled Switches: A First Level of Abstraction
Some amusing attempts to prove the point: Real-world examples that prove the point:
technology switch
transistor
fluid water pressure
“pass transistor” in
integrated circuit
relay electric potential
atom-thick transistor
11 12
Controlled Switches: A First Level of Abstraction ? Circuit Anatomy
Technology:
Deposit materials on substrate.
drawing
Key property:
Crossing lines are controlled switches.
circuit
Key challenge in “abstract” world:
Understanding behavior of circuits
with billions of controlled switches
Second Level of Abstraction: Logic Gates Second Level of Abstraction: Logic Gates
15 16
Multiway Gates Multiway Gates
17 18
Wires
Boolean Algebra
Controlled switches
Gates
AND u’vwx’y’z 1
19
Boolean Algebra Boole Orders Lunch
History.
• Developed by Boole to solve mathematical logic problems (1847).
• Shannon master's thesis applied it to digital circuits (1937).
“possibly the most important, and also the most famous,
master's thesis of the [20th] century” — Howard Gardner
Boolean algebra.
• Boolean variable: value is 0 or 1.
• Boolean function: function whose inputs and outputs are 0, 1.
Relationship to circuits.
• Boolean variable: signal.
• Boolean function: circuit.
21 22
x y xy 1 0 0 0 1 1 0 0 1 1
1 1 0 1 0 1 0 1 0 1
0 0 0
truth table for all Boolean functions of 2 variables
0 1 0
1 0 0
x y NOR EQ y' x' NAND ONE
1 1 1
0 0 1 1 1 1 1 1 1 1
AND truth table 0 1 0 0 0 0 1 1 1 1
1 0 0 0 1 1 0 0 1 1
1 1 0 1 0 1 0 1 0 1
23 24
Truth Table for Functions of 3 Variables Universality of AND, OR, NOT
Truth table. Fact. Any Boolean function can be expressed using AND, OR, NOT.
• 16 Boolean functions of 2 variables. every 4-bit value represents one • { AND, OR, NOT } are universal.
• 256 Boolean functions of 3 variables. every 8-bit value represents one • Ex: XOR(x, y) = xy' + x'y. notation meaning
• 2^(2^n) Boolean functions of n variables! every 2n-bit value represents one x' NOT x
xy x AND y
x+y x OR y
25 26
27 28
Translate Boolean Formula to Boolean Circuit Translate Boolean Formula to Boolean Circuit
Sum-of-products. XOR. Key transformation from abstract to real circuit Example 1. XOR. Key transformation from abstract to real circuit
29 30
Translate Boolean Formula to Boolean Circuit Translate Boolean Formula to Boolean Circuit
31 32
Translate Boolean Formula to Boolean Circuit Translate Boolean Formula to Boolean Circuit
33 34
Many possible circuits for each Boolean function. Problem: Compute the value of a boolean function
• Sum-of-products not necessarily optimal in:
– number of switches (space) Ingredients.
– depth of circuit (time) • AND gates.
• OR gates.
Ex. MAJ(x, y, z) = x'yz + xy'z + xyz' + xyz = xy + yz + xz. • NOT gates.
• Wire.
Instructions.
• Step 1: represent input and output signals with Boolean variables.
• Step 2: construct truth table to carry out computation.
• Step 3: derive (simplified) Boolean expression using sum-of products.
• Step 4: transform Boolean expression into circuit.
Bottom line (profound idea):
It is easy to design a circuit to compute ANY boolean function.
size = 10, depth = 2 size = 7, depth = 2
35
Caveat (stay tuned): Circuit might be huge. 36
Translate Boolean Formula to Boolean Circuit Translate Boolean Formula to Boolean Circuit
37 38
39
Let's Make an Adder Circuit Let's Make an Adder Circuit
same idea scales to 64-bit
adder in your computer cout cin
Goal. x + y = z for 4-bit integers. Goal. x + y = z for 4-bit integers.
• We build 4-bit adder: 9 inputs, 4 outputs. 1 1 1 0 x3 x2 x1 x0
• Each output bit is a boolean function of the inputs. 2 4 8 7 Step 2. [first attempt] + y3 y2 y1 y0
• Standard method applies. + 3 5 7 9 • Build truth table. z3 z2 z1 z0
6 0 6 6
Step 1. Represent input and output in binary. 4-bit adder truth table
c0 x3 x2 x1 x0 y3 y2 y1 y0 z3 z2 z1 z0
1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1
0 0 0 0 0 0 0 1 0 0 0 1 0
+ 0 1 1 1
0 0 0 0 0 0 0 1 1 0 0 1 1 28+1 = 512 rows!
1 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0
. . . . . . . . . . . . .
1 1 1 1 1 1 1 1 1 1 1 1 1
x3 x2 x1 x0
41 42
cout c3 c2 c1 c0 = 0 cout c3 c2 c1 c0 = 0
Goal. x + y = z for 4-bit integers. Goal. x + y = z for 4-bit integers.
x3 x2 x1 x0 x3 x2 x1 x0
Step 2. Do one bit at a time! + y3 y2 y1 y0 Step 3. A surprise! + y3 y2 y1 y0
• Build truth table for carry bit. z3 z2 z1 z0 • carry bit is majority function z3 z2 z1 z0
• Build truth table for summand bit. • summand bit is odd parity function.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 1 1 0 0 1 0 0 0 0 1 1 1
0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 0 1 1
0 1 1 1 0 1 1 0 0 1 1 1 1 0 1 1 0 0
1 0 0 0 1 0 0 1 1 0 0 0 0 1 0 0 1 1
1 0 1 1 1 0 1 0 1 0 1 1 1 1 0 1 0 0
1 1 0 1 1 1 0 0 1 1 0 1 1 1 1 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
43 44
Let's Make an Adder Circuit Adder: Interface
x0
x1
Goal. x + y = z for 4-bit integers. x2
x3
input buses
y0
y1
Step 4. y2
y3
• Transform Boolean expression into circuit (use known components!).
• Chain together 1-bit adders.
• That’s it!
output bus
z0
z1
z2
z3
A bus is a group of wires that connect (carry data values) to other components.
45 46
47 48
Useful Combinational Circuits Decoder
Decoder. [n-bit]
• n address inputs, 2n data outputs.
Adder • Addressed output bit is 1; others are 0.
• Compact implementation of n Boolean functions
0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0
Bitwise AND, XOR (easy)
0 1 0 0 0 1 0 0 0 0 0
0 1 1 0 0 0 1 0 0 0 0
Decoder [next slide]
1 0 0 0 0 0 0 1 0 0 0
1 0 1 0 0 0 0 0 1 0 0
1 1 0 0 0 0 0 0 0 1 0
Shifter (clever, but we’ll skip details)
1 1 1 0 0 0 0 0 0 0 1
49 50
Decoder 0 1
1 0 0
1 Decoder application: Your computer’s ALU!
Decoder. [n-bit]
• n address inputs, 2n data outputs. 0
ALU: Arithmetic and Logic Unit 10-bit input buses
• Addressed output bit is 1; others are 0. • implements instructions TOY opcode bits
• Compact implementation of n Boolean functions 1
0 • input, output connects
sub
to registers via buses
0
add
Ex: TOY-Lite (10 bit words)
x0 x1 x2 z0 z1 z2 z3 z4 z5 z6 z7
0 1: add and
0 0 0 1 0 0 0 0 0 0 0
2: subtract xor
0 0 1 0 1 0 0 0 0 0 0
0 3: and
0 1 0 0 0 1 0 0 0 0 0 shift
4: xor
0 1 1 0 0 0 1 0 0 0 0 0 5: shift left
1 0 0 0 0 0 0 1 0 0 0
6: shift right right
1 0 1 0 0 0 0 0 1 0 0 0
1
1 1 0 0 0 0 0 0 0 1 0 Details:
51 52
Summary
53