Bsics of Logic Design: Boolen Alger, Logic Gtes Computer Science 104 Tody s Lecture Projects (groups of 2 or 3) Outline Building the uilding locks Logic Design Truth tles, Boolen functions, Gtes nd Circuits Reding Appendix C (link off course we pge/documents) http://rch.cs.duke.edu/locl/cod4ed/resources/appendix/appendix-c-p374493.pdf 2
The Big Picture The Five Clssic Components of Computer Processor/CPU Control Dtpth Memory Input Output 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 lw or eq? 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 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 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-of -product 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
Lots of good theory Applying the 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 processors) Totl: 290 Million Trnsistors Core2 Duo Extreme (4 processors, 8MB cche) Totl: 590 Million Trnsistors 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 I 1 I 0 Q 0 Q 1 Q 2 Q 3 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 1 1 0 0 0 1 23 Circuit Exmple: 2x1 MUX Multiplexor (MUX) selects from one of mny inputs y MUX(A, B, S) = (A * S) + (B * ~S) s B A Gte 1 Gte 2 Gte 3 Y = (A * S) + (B * ~S) 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 Appendix C 27