Building A Computer
Inform a tion is encod ed w ith bits: 0 's a nd 1's .
(we've already seen 2's com plem ent num bers)
These a re encod ed using + w ell und erstood
voltages...
+ ea s y to genera te, d etect - a ffected b y environm ent
B ut w hy 1's a nd 0 's only?
Digital Representation
Example: representing a B&W picture: Black = 0 V White = 1 V 80% grey = 0.8 V ... Represent by scanning picture in xed order. Let's try doing some computation with the voltages...
Digital Representation
Flip image:
Flip back and forth...
What really happens...
Have to build system to tolerate some error (noise).
Logic Levels
Store just one bit on a wire... Gain reliability
0V
"unknown"
3.3V
anything here is logic level 0
anything here is logic level 1
Different conventions are possible
5V
"unknown"
5V
anything here is logic level 1
anything here is logic level 0
Combinational Devices
A combinational device: Output is a function of inputs only ("memoryless") Takes input to valid, stable outputs Combinational devices restore marginally valid signals!
valid input logic 0 0V valid input logic 1 3.3V
valid output logic 0
noise margin
valid output logic 1
Example
Input: logic 0 if O utput logic 0
< Vil , logic 1 if < Vol , logic
Vih Voh
Vin
if 1
> Vih if > Voh
3.3V
Vil
Vout
Vout avoid these regions!
Vol
0V 3.3V
Vin
Digital View
If input is 0 , output is 1 If input is 1, output is 0
N orm a lly w ritten in a ta b le, like this :
In 0 1
O ut 1 0
C a lled a "truth-ta b le".
Im p le m e n t a t io n : S w itc h in g N e t w o rks
Lots of ways to build switches... relays vacuum tubes transistors ...
Ptransistor
a g b g
Ntransistor
a
Connect a and b if g = 0.
Connect a and b if g = 1.
Switching Networks: Inverter
Vdd
in
in out
out 1 0
0 1
GND
Function: NOT Called an inverter Symbol:
in out
Switching Networks: NAND
Vdd
a
a
b out 0 0 1 1 1 1 1 0
0
out
1 0
b
GND
Function: NAND Symbol:
a out b
Switching Networks: NOR
Vdd b
a
a out
b out 0 0 1 1 1 0 0 0
0 1 0 1
GND
Function: NOR Symbol:
a out b
Building Functions From Gates
AND:
=
OR:
=
Can specify function by describing gates, truth table, or logic equations.
Logic Equations
AND:
out = a b out = ab out = a b
OR: NOT:
out = a + b out = a b
out = in out = in
Logic Equations
Fun with identities:
a+a=1 a+0=a a+1=1
aa = 0 a0=0 a1=a a(b + c) = ab + ac (a + b) = a b (a b) = a + b a + ab = a + b
Check by writing truth tables, or by manipulating logic equations.
Let's Build An Adder
Write down function: Two 1-bit inputs, a and b Two 1-bit outputs, sum and carry Truth-table: a 0 1 0 1 b carry sum 0 0 0 0 0 1 1 0 1 1 1 0
Let's Build An Adder
Sum output: a 0 1 0 1 Logic equation: Circuit:
a b a b ab
b sum Logic term 0 0 ab 0 1 ab 1 1 ab 1 0 ab
ab ab + ab
ab+ab
Let's Build An Adder
Carry output: a 0 1 0 1 Logic equation: Circuit: b carry Logic term 0 0 ab 0 0 ab 1 0 ab 1 1 ab
ab
a b ab
Let's Build An Adder
Final Circuit:
+0 +0
a b
ab
+2
carry
a b a b
ab
+3 +3
ab + ab
+5
sum
ab
Numbers indicate the number of sequential steps from input to output (worst-case).