790 likes | 917 Vues
This guide explores fundamental concepts in computer science, emphasizing logic gates, truth tables, and the universal method of circuit design using AND, OR, and NOT gates. Learn about collaboration policies for labs and problem sets, including acceptable practices like discussing concepts with others while writing up your work independently. Understand the implications of using logic gates for creating circuits for any truth table and the practical limits of this method. Dive into numerical representation in computing and the significance of powers of two.
E N D
Administrivia • New students? • No class Thursday 9/27 • Lab • Problem Set • Favorite browser and why • Favorite search engine and why • Questions??
Collaboration Policy • On Problem Sets / Labs: • Allowed (actually, encouraged): • Talk with friends (or strangers) about problems, but write up on your own • Not Allowed: • Copying verbatim • On Exams: • Obviously, no collaboration allowed. • Exams will be open notes
Big Ideas in Computer Science
A Simple Logic Puzzle • Frank will go to the party if Ed goes AND Dan does NOT. • Dan will go if Bob does NOT go OR if Carole goes. • Ed will go to the party if Alice AND Bob go. • Alice and Bob decide to go,but Carol stays home. • Will Frank go to the party?
AND Gate (cont.) X W Z Y AND W X Y Z 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1
OR Gate (cont.) OR W Z W X Y Z 0 0 0 ? 0 0 1 ? 0 1 0 ? 0 1 1 ? 1 0 0 ? 1 0 1 ? 1 1 0 ? 1 1 1 ? X Y
NOT Gate NOT • “Yanni will go to the party if Xena does NOT go.” Y X Shorthand: Y X X Y 0 1 1 0 Truth Table
AND AND OR Logic Puzzle Circuit Alice Ed Frank Bob Dan Carole
Modified AND Gate AND A F A B C F 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 0 B C
Can realize any Truth Table by the Universal Method AND AND AND A A B C F 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 0 B C A B C A B C
Universal Method AND AND AND OR A B C A F B C A Combine AND gates with an OR gate. B C Build an AND gate for each 1 in the truth table
Universality • For ANY Truth Table we can write down,we can make a circuit for it using only 3 Logic Gates: AND, OR, NOT • In real life, make AND/OR/NOT gatesout of Transistors
Our First Abstract Tool Universal Method: Circuits for ANY Truth Table 0’s & 1’s Universal Method Computers We are here
Next Time: Why are 0’s and 1’s allwe need?
Limits of the Universal Method • For how large a circuit can we realistically expect to use the Universal Method? • What do we do for larger circuits?
Numeracy • How large do circuits get? • How large do truth tables get?
Numeracy (cont.) X Y 0 1 1 0 1-input Truth Table 2 rows
Numeracy (cont.) X Y Z 0 0 0 0 1 1 1 0 1 1 1 1 X Y 0 1 1 0 1-input Truth Table 2 rows 2-input Truth Table 4 rows
Numeracy (cont.) A B C F 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 0 3-input Truth Table: 8 rows
Numeracy (cont.) • Each input can be 0 or 1 : 2 possibilities. • So if there are 4 inputs, that is a total of 2 * 2 * 2 * 2 = 16 possible input values.
Numeracy (cont.) • Each input can be 0 or 1 : 2 possibilities. • In general, if there are n inputs, there will be 2n possible input values.
Powers of 2 • 2n comes up a lot in Computer Science. • Numbers to memorize: • 21 = 2, 22 = 4, 23 = 8, • 24 = 16, 25 = 32, 26 = 64, • 27 = 128, 28 = 256, 29 = 512, • 210 = 1024
Powers of 2 (cont.) • 210 = 1,024 • 220 = 1,048,576 • 230 = 1,073,741,824 • 240 = 1,099,511,627,776 • 250 = 1,125,899,906,842,624 • 260 = 1,152,921,504,606,846,976
Powers of 2 (cont.) • Some rough numbers: • 210 = 1,024 1,000 (103 ) • 220 = 1,048,576 1,000,000 (106 ) • 230 1,000,000,000 (109 ) • 240 1,000,000,000,000 (1012 ) • 250 1015 • 260 1018
Powers of 2 (cont.) • Some rough numbers: • 210 1,000 (103 ) kilo • 220 1,000,000 (106 ) mega RAM • 230 109 giga disk • 240 1012 tera BIG disk • 250 1015 peta • 260 1018 exa knowledge
Sidebar on Exabytes • It's taken the entire history of humanity through 1999 to accumulate 12 exabytes of information. By the middle of 2002 the second dozen exabytes will have been created • 1 exabytes = 50,000 times the library of congress • Floppys to make 1 exabyte would stack 24 million miles high.
Powers of 2 (cont.) • 16 inputs means Truth Tablehas216 = 210 * 26 = 1,024 * 64 64,000 rows • Circuit could have 64,000 or more gates
Universal Method (cont.) • What about 100 inputs: • Is it reasonable to use Universal Method on Truth Table with 100 inputs?
Universal Method (cont.) • What about 100 inputs: • Is it reasonable to use Universal Method on Truth Table with 100 inputs? • 2100 1030 • Each AND/OR/NOT gate uses at least 1 transistor. • This is way beyond current technology,in fact . . .
Numeracy (cont.) • State-of-the-art transistors are about.1 micrometer (mm) on a side: • Lined end-to-end, you could fit10,000,000 transistors in 1 m. ( 3 f.) • In a 1 m. by 1 m. square, you could fit100,000,000,000,000 transistors • That’s still 999,999,999,999,999, 900,000,000,000,000too few for 100 input Truth Table !
No good? • How sad should we be?
No good? • How sad should we be? Not very. • You just need to use many Truth Tables each having fewer inputs. • Can make an entire computer using only 16-input Truth Tables and the Universal Method! • On the other hand, must realize that in some cases, we need more efficientspecial purpose circuits than the UniversalMethod. (We won’t cover these.)
Our First Abstract Tool Universal Method: Circuits for ANY Truth Table 0’s & 1’s Universal Method Computers We are here
So what? • We can deal with 0’s and 1’s now, but why should we? • Answer: Because we canrepresent so many thingswith 0’s and 1’s.
Meaning • In Logic, we thought of 0 and 1 as meaning True and False. • Now, we remove these connotations. • Definition: a bit is just a single variable that can be 0 or 1.
Representing Information • Information in the world comes in manyforms – letters, numbers, pictures, sounds… • How can we represent these thingswith 0’s and 1’s? • Start with numbers.
Representing Numbers • Before computers, in devices, numbers typically represented continuously. • e.g. Clocks:
Binary Numbers • How do we count normally? • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, …19, 20, …99, 100, … 999, 1000, … • Suppose we only had two numerals – 0 and 1. • Then how would we count?0, 1, 10, 11, 100, 101, 110, …
Binary Numbers (cont.) 0 1 2 3 4 5 6 7 8 0 1 1 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 1 0 0 0
Binary Numbers (cont.) • Addition : • 1 0 1 • + 1 1 1 • _______________
Binary Numbers (cont.) • Addition – Our “basic” addition table is really easy now: • 0 + 0 = 0 • 0 + 1 = 1 • 1 + 0 = 1 • 1 + 1 = 10
Binary Numbers (cont.) • Addition – just like usual: • 1 0 1 • + 1 1 1 • _______________ 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10
Binary Numbers (cont.) • Addition – just like usual: • 1 • 1 0 1 • + 1 1 1 • _______________ • 0 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10
Binary Numbers (cont.) • Addition – just like usual: • 11 • 1 0 1 • + 1 1 1 • _______________ • 0 0 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10