Bsics of Logic Design: Boolen Alger, Logic Gtes Computer Science 104 Administrtive Homework #3 Due Sundy Midterm I Mondy in clss, closed ook, closed notes Ø Will provide IA32 instruction set hndout Ø Lst spring s midterm on lckord Ø Alex will schedule review session for Mondy evening Do we need one more recursion exmple? 2
Tody s Lecture Outline Building the uilding locks Logic Design Ø Truth tles, Boolen functions, Gtes nd Circuits Reding 4.2 of text, ut we re going into more detil thn the text ny other online resource you cn find 3 Wht We ve Done, Where We re Going Top Down Appliction CPU Compiler Memory Operting System Digitl Design Circuit Design Firmwre I/O system Softwre Interfce Between HW nd SW Instruction Set Architecture, Memory, I/O Hrdwre Bottom UP to CPU 4
Digitl Design Logic Design, Switching Circuits, Digitl Logic Recll: Everything is uilt from trnsistors A trnsistor is switch It is either on or off On or off cn represent True or Flse Given unch of its (0 or 1) Is this instruction movl or je? Wht register do I red? How do I dd two numers? Need method to reson out complex expressions 5 Boolen Alger Boolen functions hve rguments tht tke two vlues ({T,F} or {1,0}) nd they return single or set of ({T,F} or {1,0}) vlue(s). Boolen functions cn lwys e represented y tle clled Truth Tle Exmple: F: {0,1} 3 -> {0,1} 2 c f 1 f 2 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 0 0 1 0 1 1 0 0 1 1 1 1 1 1 6
Boolen Functions Exmple Boolen Functions: NOT, AND, OR, XOR,... NOT() 0 1 1 0 AND(,) 0 0 0 0 1 0 1 0 0 1 1 1 OR(,) 0 0 0 0 1 1 1 0 1 1 1 1 XOR(,) 0 0 0 0 1 1 1 0 1 1 1 0 XNOR(,) 0 0 1 0 1 0 1 0 0 1 1 1 NOR(,) 0 0 1 0 1 0 1 0 0 1 1 0 7 Boolen Functions nd Expressions Boolen lger nottion: Use * for AND, + for OR, ~ for NOT. Ø NOT is lso written s A nd A Using the ove nottion we cn write Boolen expressions for functions F(A, B, C) = (A * B) + (~A * C) We cn evlute the Boolen expression with ll possile rgument vlues to construct truth tle. Wht is truth tle for F? 8
Boolen Functions nd Expressions F(A, B, C) = (A * B) + (~A * C) A B C F 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 9 Boolen Function Simplifiction Boolen expressions cn e simplified y using the following rules (itwise logicl): Ø A*A = A Ø A* 0 = 0 Ø A*1 = A Ø A*~A = 0 Ø A+A = A Ø A+0 = A Ø A+1 = 1 Ø A+~A = 1 Ø A*B = B*A Ø A*(B+C) = (B+C)*A = A*B + A*C 10
Boolen Function Simplifiction c f 1 f 2 0 0 0 0 1 0 0 1 1 1 0 1 0 0 0 0 1 1 1 0 1 0 0 0 0 1 0 1 1 0 1 1 0 0 1 1 1 1 1 1 f 1 = ~*~*c + ~**c + *~*c + **c f 2 = ~*~*~c + ~*~*c + **~c + **c Simplify these functions... 11 Boolen Function Simplifiction f1 = ~*~*c + ~**c + *~*c + **c = ~*(~*c +*c) +*(~*c+*c) = ~*c*(~+) ~*c*(~+) = ~*c + *c = c*(~+) = c f2 = ~*~*~c + ~*~*c + **~c + **c = ~*(~*~c + ~*c) + *(*~c + *c) = ~*~(c+~c) * **(~c+c) = ~*~ + * 12
Boolen Functions nd Expressions The Fundmentl Theorem of Boolen Alger: Every Boolen function cn e written in disjunctive norml form s n OR of ANDs (Sum-of products) of it s rguments or their complements. Proof: Write the truth tle, construct sum-ofproduct from the tle. XNOR(,) 0 0 1 0 1 0 1 0 0 1 1 1 XNOR = (~ * ~) + ( * ) 13 Boolen Functions nd Expressions Exmple-2: c f 1 f 2 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 0 0 1 0 1 1 0 0 1 1 1 1 1 1 f 1 = ~*~*c + ~**~c + *~*~c + **c f 2 = ~*~*~c + ~*~*c + **~c + **c 14
Applying the Theory Lots of good theory Cn reson out complex oolen expressions Now we hve to mke it rel 15 Boolen Gtes Gtes re electronic devices tht implement simple Boolen functions Exmples AND(,) OR(,) NOT() XOR(,) NAND(,) NOR(,) XNOR(,) 16
Relity Check Bsic 1 or 2 Input Boolen Gte 1-4 Trnsistors Pentium III Processor Core 9.5 Million Trnsistors Totl: 28 Million Trnsistors Pentium 4 Totl: 42 Million Trnsistors Core2 Duo (two cores) Totl: 290 Million Trnsistors Corei7 (4 cores) Totl: 731 Million Trnsistors Insert Tngent out wht trnsistor is 17 Boolen Functions, Gtes nd Circuits Circuits re mde from network of gtes. (function compositions). XOR(,) F = ~* + ~* XOR(,) 0 0 0 0 1 1 1 0 1 1 1 0 F 18
Digitl Design Exmples Input: 2 its representing n unsigned numer (n) Output: n 2 s 4-it unsigned inry numer Input: 2 its representing n unsigned numer (n) Output: 3-n s unsigned inry numer 19 Design Exmple Consider mchine with 4 registers Given 2-it input (register specifier, I 1, I 0 ) Wnt one of 4 output its (O 3 -O 0 ) to e 1 Ø E.g., llows single register to e ccessed Wht is the circuit for this? 20
More Design Exmples X is 3-it quntity 1. Write logic function tht is true if nd only if X contins t lest two 1s. 2. Implement the logic function from prolem 1. using only AND, OR nd NOT gtes. (Note there re no constrints on the numer of gte inputs.) By implement, I men drw the circuit digrm. 3. Write logic function tht is true if nd only if X, when interpreted s n unsigned inry numer, is greter thn the numer 4. 4. Implement the logic function from prolem 3. using only AND, OR nd NOT gtes. (Note there re no constrints on the numer of gte inputs.) 21 Prity Exmple The prity code of inry word counts the numer of ones in word. If there re n even numer of ones the prity code is 0, if there re n odd numer of ones the prity code is 1. For exmple, the prity of 0101 is 0, nd the prity of 1101 is 1. Construct the truth tle for function tht computes the prity of four-it word. Implement this function using AND, OR nd NOT gtes. (Note there re no constrints on the numer of gte inputs.) 22
Circuit Exmple: Decoder Q 3 I 1 I 0 Q 0 Q 1 Q 2 Q 3 Q 2 0 0 1 0 0 0 0 1 0 1 0 0 Q 1 1 0 0 0 1 0 1 1 0 0 0 1 Q 0 I 1 I 0 23 Circuit Exmple: 2x1 MUX Multiplexor (MUX) selects from one of mny inputs 1 0 y MUX(A, B, S) = (A * S) + (B * ~S) s B Gte 1 Gte 3 Y = (A * S) + (B * ~S) A Gte 2 S 24
Exmple 4x1 MUX 3 c y c 2 1 y d d 0 2 s 0 s 1 S 25 Arithmetic nd Logicl Opertions in ISA Wht opertions re there? How do we implement them? Ø Consider 1-it Adder 26
Summry Boolen Alger & functions Logic gtes (AND, OR, NOT, etc) Multiplexors Reding 4.2 of text 27 DeMorgn s Lws ~(A+B) = ~A * ~B ~(A*B) = ~A + ~B Exmple: ~C*~A*B + ~C*A*~B + C*A*B + C*~A*~B Use only XOR to represent this function 28