Elec. Power Engineering Cairo University, Giza, Egypt Computer Engineering By Dr. M. Moustafa Hassan Elec. Power Engineering Cairo University, Giza, Egypt
Dr. M. A. Moustafa Hassan Cairo University Computer Engineering Topics Binary Representation Reliability thereof Binary Storage Devices Learning Objectives Understand why binary is used, to translate between decimal and binary and to do simple binary calculations Know the conditions of a bistable environment and the way light switches, magnetic cores and transistors meet them. 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Data Representation Notational conventions for representing information Decimal representation for numerical values 0,1,2,3,4,5,6,7,8,9 Signed notation +,- (unsigned means positive only) Decimal Notation for real numbers Decimal point separates whole number part from fractional part The 26 letters A,B,C,…X,Y,Z for text Plus lowercase and punctuation Digitizing Sound and Images 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Data Representation 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Decimal Representation In decimal, the following symbols are used to represent different values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Here’s four thousand, seven hundred and sixty-three in decimal. 1000s 100s 10s 1s 103 102 101 100 4 7 6 3 or, it can be written this way: (4 x 1000) + (7 x 100) + (6 x 10) + (3 x 1) = 4763 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Binary Representation In the binary system, just two symbols are used: 0 and 1. Therefore any number must be represented by 0s and 1s only Let’s examine a 6 digit (bit) binary number 1 1 1 0 0 1 Position value 25 24 23 22 21 20 32 + 16 + 8 + 0 + 0 + 1 = 57 This kind of a table makes conversions easy 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Binary-to-Decimal Conversion Table 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Converting Decimal Numbers to Binary 53 = 32 + 16 + 4 + 1 = 25 + 24 + 22 + 20 = 1*25 + 1*24 + 0*23 + 1*22 + 0*21 + 1*20 = 110101 in binary = 00110101 as a full byte in binary 211= 128 + 64 + 16 + 2 + 1 = 27 + 26 + 24 + 21 + 20 = 1*27 + 1*26 + 0*25 + 1*24 + 0*23 + 0*22 + 1*21 + 1*20 = 11010011 in binary 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Converting Decimal Numbers to Binary What is 10011010 in decimal? 10011010 = 1*27 + 0*26 + 0*25 + 1*24 + 1*23 + 0*22 + 1*21 + 0*20 = 27 + 24 + 23 + 21 = 128 + 16 + 8 + 2 = 154 What is 00101001 in decimal? 00101001 = 0*27 + 0*26 + 1*25 + 0*24 + 1*23 + 0*22 + 0*21 + 1*20 = 25 + 23 + 20 = 32 + 8 + 1 = 41 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Max. Integer Every computer has a maximum number of bits used to store an integer Given k bits, the largest unsigned integer is 2k - 1 16 bit 216 – 1 = 65,535 32 bit 232 – 1 = 4,294,967,296 Adding just one more (than max) causes an arithmetic overflow error. 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Neg. Integer – Sign/Magnitude We desire the availability of negative integers Let the most significant bit will represent negation – negative if on, positive if off Our previous 6 digit binary now needs an extra bit to make it negative Here it is in full 1 byte representation Can you see a problem with this scheme? 1 0 1 1 1 0 0 1 Position value neg. 26 25 24 23 22 21 20 - 0 + 32 + 16 + 8 + 0 + 0 + 1 = - 57 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Neg. Integer – Two’s Complement The most common way of storing integers The most significant bit will represent negative 128 (-128) Here’s 57 and -57 in full 1 byte representation What’s the range of a 1 byte integer ? 1 1 0 0 0 1 1 1 Position value -27 26 25 24 23 22 21 20 -128 + 64 + 0 + 0 + 0 + 4 + 2 + 1 = - 57 0 0 1 1 1 0 0 1 -0 + 0 + 32 + 16 + 8 + 0 + 0 + 1 = 57 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Representing Real Numbers Real numbers may be put into binary scientific notation for storage: “a x 2b” First, convert from decimal to binary Example: 5.75 is 101.11 in binary 5 is 101 and .75 is .11 in decimal there are 10ths, 100ths, 1000ths, etc while in binary there are halves, quarters, eighths, etc So .75 is made up of a half and a qtr written .11 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Step 3) Normalize 5.75 = 101.11 x 20 5.75 = 10.111 x 21 5.75 = 1.0111 x 22 5.75 = .10111 x 23 Which is (1/2 + 1/8 + 1/16 + 1/32) x 8 = 5.75 Real Numbers Second, use scientific binary notation 101.11 is 101.11 x 20 Third, normalize so that first significant digit is immediately to the right of the binary point (see next for further explanation) .10111 x 23 Fourth, store mantissa and exponent 0 1 0 1 1 1 0 0 0 0 0 0 0 0 1 1 Mantissa Exponent Sign of Mantissa Sign of Exponent 21-Nov-18 Binary Point Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Negative Real Numbers First, convert to binary -5/16 is -(1/4 + 1/16) is -0.0101 Second, use scientific binary notation -0.0101 x 20 Third, normalize -.101 x 2-1 Fourth, stored mantissa and exponent 1 1 0 1 0 0 0 0 0 0 1 0 0 0 0 1 Mantissa Exponent Sign of Mantissa Sign of Exponent 21-Nov-18 Binary Point Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Let’s Practice Convert the following to binary using the standard notation 78, 255 Convert the following to binary using two’s complement notation -78, -105, 118 Convert several bit patterns to decimal HINT: use windows calc to check your answers Convert -3.0625 to binary 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Binary Representation of Characters Each character is represented by a unique (binary) number The ASCII table is the most common scheme Uses 8 bits – 28 or 256 different characters First 7 bits only (actually 8-bit ASCII is a misnomer) Unicode Uses 16 bits – 216 or 65,536 different characters Go to http://www.cs.tut.fi/~jkorpela/chars.html for an excellent tutorial on character code issues IMPORTANT NOTE: the numeric value of number characters is NOT the same as the usual arithmetic value. ie: The character 7 has the numeric value 55 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Examples of ASCII Codes 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University IMPORTANT NOTE The computer does not know what a specific bit pattern in memory means The meaning is imposed only as a result of how some process has been designed to interpret the pattern Strong Typing – In writing programs we declare how we will use locations in memory (java & c) boolean b – means 1 bit that can be true or false byte number – means a signed 8 bit integer int number – means a signed 32 bit integer char ch – means a 16 bit “uni-code” character (note: we only discuss the 7 bit portion used in the lower ASCII char set) Loose Typing – Some programming (scripting) languages are able to do this automatically (php, perl) Which is better? – it depends! Read More !!. 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Binary Representation of Sound Multimedia data is sampled to store in digital form, with or without detectable differences Representing sound data Sound data must be digitized for storage in a computer Digitizing means periodic sampling of amplitude values 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Sound (continued) From samples, original sound may be approximated To improve the approximation: Sample more frequently Use more bits for each sample value 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Figure 4.5 Digitization of an Analog Signal (a) Sampling the Original Signal (b) Recreating the Signal from the Sampled Values 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Representing Image Data Images are sampled by reading color and intensity values at even intervals (a grid) across the image 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Representing Image Data The size of the grid is called resolution 1024 x 768 or 1600 x 1200 Each sampled point is a pixel Image quality depends on number of bits at each pixel True-Color (24bit) uses 1 byte for each of red, green & blue to represent over 16 million colours at each pixel What is the storage requirement (size) of a True-Color image with a resolution of 1600 x 1200? 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Putting it into Perspective Encoding the text (no images) like a text book: 100,000 words x 5 char/word x 8 bits/char = 4,000,000 bits 1 minute of sound using MP3 (44,100 samples/sec using a 16 bit depth: 44,100 samples/sec x 16 bits/sample x 60 sec/minute = 42,000,000 bits 1 photo using a 3 mega pixel camera: 3,000,000 pix/photo x 24 bits/pixel = 72,000,000 bits 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Data Compression Compression Ratio Ratio = Size of Uncompressed / Size of Compressed Lossless No data is lost during compression Used when compressing text 1.5 to 1.7 compression ratios Lossy The higher the compression the higher the loss Used for sound and images 10, 20 & higher compression ratios 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Reliability Q: Why binary ? A: Electrical systems work best in a bistable environment. That is, an electrical component can remain accurate as it ages (and drifts). If it only needs to deal with voltage or no voltage; circuit on/circuit off The text points out that nearly a 50% drift in voltage is still tolerable when interpreting a stored value. 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Binary Storage Devices Binary Hardware Criteria 2 stable energy states A large energy barrier between them Ability to read the state without destroying it Ability to change the state as needed Two approaches Magnetic Cores – historic Transistors – current 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Magnetic Cores An Iron oxide-coated donut can be magnetized by running current through a wire strung through its whole The direction of the resulting magnetic field is dependant upon the direction of the current “right-hand” rule Even though these mag cores where small (1/50” dia) it would take a cube 230’ per side to construct a modern 512 mb memory !!! 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Magnetic Cores to Represent Binary Values 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Transistor Just a switch; it’s turned on/off electrically Current technology (at text book printing) Switch state – 1 billionth of a sec Density – 30 to 50+ million per cm2 Made from semiconductors (silicon or gallium arsenide) Transistors are printed photographically onto a wafer of silicon using a mask. This is used to produce many copies of the circuit (chip). 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Relationship of Transistors, Chips … 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Transistor Model 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Interesting Links Binary Numbers http://www.math.grin.edu/~rebelsky/Courses/152/97F/Readings/student-binary.html Character Issues http://www.cs.tut.fi/~jkorpela/chars.html Core Memory http://www.psych.usyd.edu.au/pdp-11/core.html Transistor http://www.pbs.org/transistor/ Semiconductor http://www.answers.com/topic/semiconductor 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University George Boole (1815 – 1864) Created a new form of logic containing the values true and false and the operators AND OR NOT Developed a set of rules to interpret and manipulate expressions that contain these values 100 years later his theories became the framework for designing computer systems 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Boolean Logic Boolean Logic deals with manipulating the values “true” and “false” Anything stored in a sequence of binary digits can also be viewed as a sequence of logical values, true and false The operators AND, OR, & NOT map a set of True False values into a single (true/false) result 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Boolean Logic Any expression can be either true or false IE: x = y + 25 A boolean expression combines arithmetic expressions using the boolean operators AND (x = y + 25 AND y < 100) OR (x = y OR x < 10) NOT (NOT (x = y)) 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University AND rule a AND b, also written as a·b, is true only if the value of a and the value of b is true Otherwise the expression a·b has the value of false To check a test score S in the range 90 to 100 inclusive: S>=90 AND S<=100 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Truth Table for AND Operation Input Output a b a AND b FALSE TRUE 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University OR rule a OR b, also written as a+b, is true if the value of a is true, if value of b is true, or both are true Otherwise the expression a+b has the value of false To check a student’s major: (major = math) OR (major = comp science) 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Truth Table for OR Operation Input Output a b a OR b FALSE TRUE 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University NOT rule NOT reverses or complements the value of the Boolean expression Not a, also written as ā, is true if a has the value of false and false if a has the value of true To compare a student’s gpa: (gpa > 3,5) is true if your gpa is greater than 3.5 NOT (gpa > 3.5) is true only if your gpa ≤ 3.5 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Truth Table for NOT Operation Input Output a NOT a FALSE TRUE 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Precedence The order of precedence rule for boolean operations is NOT first, AND second and OR third. So x AND NOT y OR z Means (x AND (NOT y)) OR z Parentheses can be used to change the order and are recommended where needed to enhance readability 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Other Boolean Logic Symbols English Math Java TRUE 1 true FALSE 0 false NOT ! (Negation: NOT false is true and NOT true is false) AND && (Conjunction: P AND Q is true only when both P & Q are true) OR || (Disjunction: P OR Q is true when P is true, or Q is true, or both) 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Truth Table 1 Shows the truth or falsity of a logical expression for every possible logical value assignment. P Q R P || (Q && R) 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 1 1 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Truth Table 2 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 P Q R P && !(Q || R) 1 1 1 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Review of Boolean Algebra Just like Boolean logic Variables can only be 1 or 0 Instead of true / false 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Review of Boolean Algebra Not is a horizontal bar above the number 0 = 1 1 = 0 Or is a plus 0+0 = 0 0+1 = 1 1+0 = 1 1+1 = 1 And is multiplication 0*0 = 0 0*1 = 0 1*0 = 0 1*1 = 1 _ _ 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Review of Boolean Algebra _ _ _ Example: translate (x+y+z)(xyz) to a Boolean logic expression (xyz)(xyz) We can define a Boolean function: F(x,y) = (xy)(xy) And then write a “truth table” for it: x y F(x,y) 1 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Basic Logic Gates Not And Or Nand Nor Xor 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Question 1 Find the output of the following circuit Answer: (x+y)y Or (xy)y x+y (x+y)y y __ 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Question 2 Find the output of the following circuit Answer: xy Or (xy) ≡ xy x x y x y y _ _ ___ 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Question 3 Draw the circuits for the following Boolean algebraic expressions x+y __ x x+y 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Question 4 Draw the circuits for the following Boolean algebraic expressions (x+y)x _______ x+y (x+y)x x+y 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Writing XOR Using AND/OR/NOT p q (p q) ¬(p q) x y (x + y)(xy) x y xy 1 ____ x+y (x+y)(xy) xy xy 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Gates: AND, OR, & NOT A gate operates on binary inputs to produce binary outputs 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University The NOT Gate 1 1 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University NAND and AND Gates 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University NOR and OR Gates 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Important Note Gates are another abstraction in Computer Science “we don’t have to deal with transistors, resistors and capacitors or voltages, current and resistance; the building block of circuit construction (for us) will be gates and the rules of Boolean logic!” 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Building Computer Circuits A combinational circuit (just “circuit” to us) is made up of logic gates That transform a set of binary inputs into a set of binary outputs, Where the values of the outputs depend only on the values of the inputs (no feedback loops) Sequential circuits (containing feedback loops) feed the output from a gate back as input to an earlier gate – not discussed here 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Diagram of a Typical Computer Circuit 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Our First Circuit c = (a OR b) d = NOT ( (a OR b) AND (NOT b ) ) 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Circuit Construction Algorithm Construct the truth table Every output of 1 denotes a sub-expression Create sub-expressions using AND & NOT each sub-expression becomes a sub-circuit of the completed circuit Combine sub-expressions using OR sub-circuits are joined with OR gates Construct the circuit Repeat 2 through 4 for each output column 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
The Sum-of-Products Circuit Construction Algorithm 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Truth Table input output a b o1 o2 1 What general concept do you think that each output represents? Create the sub-expressions Combine them Construct the circuit 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Circuit Construction IMPORTANT: The “Sum of Products” Algorithm doesn’t always produce an optimal circuit The circuit on the right has the same output as the one on the left. 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University “Addition” Circuit Binary addition 11 (the carry bit) + 001101 (bin value 13) 001110 (bin value 14) 011011 (bin value 27) Relate this to the truth table required for the circuit (next slide) 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
How to Add Binary Numbers Consider adding two 1-bit binary numbers x and y 0+0 = 0 0+1 = 1 1+0 = 1 1+1 = 10 Carry is x AND y Sum is x XOR y The circuit to compute this is called a half-adder x y Carry Sum 1 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University The Half-Adder Sum = x XOR y Carry = x AND y 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Using Half Adders We can then use a half-adder to compute the sum of two Boolean numbers 1 1 1 0 0 + 1 1 1 0 ? 1 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University How to Fix This We need to create an adder that can take a carry bit as an additional input Inputs: x, y, carry in Outputs: sum, carry out This is called a full adder Will add x and y with a half-adder Will add the sum of that to the carry in What about the carry out? It’s 1 if either (or both): x+y = 10 x+y = 01 and carry in = 1 x y c carry sum 1 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University The Full Adder The “HA” boxes are Half-Adders 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
1-Add Circuit and Truth Table Note how the truth table supports binary addition on the previous slide Create sub-expressions for Si Write the expression for Si 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Sum Output for 1-Add 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University 1-Add 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Building the Full Adder Put rightmost bits into 1-ADD, with zero for the input carry Send 1-ADD’s output value to output, and put its carry value as input to 1-ADD for next bits to left Repeat process for all bits 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
The Full Adder Add Circuit 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
The Process of Abstraction Full Adder as a circuit Full Adder using 1-Add 1-Add using gates Gates using transistors 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University The Full Adder The full circuitry of the full adder 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Adding Bigger Binary Numbers Just chain of full adders together 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Adding Bigger Binary Numbers A half adder has 4 logic gates A full adder has two half adders plus a OR gate Total of 9 logic gates To add n bit binary numbers, you need 1 HA and n-1 FAs To add 32 bit binary numbers, you need 1 HA and 31 FAs Total of 4+9*31 = 283 logic gates To add 64 bit binary numbers, you need 1 HA and 63 FAs Total of 4+9*63 = 571 logic gates 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University More About Logic Gates To implement a logic gate in hardware, you use a transistor. Transistors are all enclosed in an Integrated Circuit “IC”. The current Intel Pentium IV processors have 55 million transistors! 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Pentium Math Error 1 Intel’s Pentiums (60Mhz – 100 Mhz) had a floating point error Graph of z = y/x Intel reluctantly agreed to replace them in 1994 Graph from http://kuhttp.cc.ukans.edu/cwis/units/IPPBR/pentium_fdiv/pentgrph.html 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Pentium Math Error 2 Top 10 reasons to buy a Pentium: 10 Your old PC is too accurate 8.9999163362 Provides a good alibi when the IRS calls 7.9999414610 Attracted by Intel's new "You don't need to know what's inside" campaign 6.9999831538 It redefines computing--and mathematics! 5.9999835137 You've always wondered what it would be like to be a plaintiff 4.9999999021 Current paperweight not big enough 3.9998245917 Takes concept of "floating point" to a new level 2.9991523619 You always round off to the nearest hundred anyway 1.9999103517 Got a great deal from the Jet Propulsion Laboratory 0.9999999998 It'll probably work!! 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Flip-Flops Consider the following circuit: What does it do? 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Latches And Flip Flops RS Flip Flop What are Flip Flops? Flip Flops are digital circuits that have feedback connections. Thus, can be used as memory devices, oscillators, etc. An AND-OR gate used as a ``ones catching'' latch and its timing diagram 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
In vivo digital circuits 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Memory A flip-flop holds a single bit of memory The bit “flip-flops” between the two NAND gates In reality, flip-flops are a bit more complicated Have 5 (or so) logic gates (transistors) per flip-flop Consider a 1 Gb memory chip 1 Gb = 8,589,934,592 bits of memory That’s about 43 million transistors! In reality, those transistors are split into 9 ICs of about 5 million transistors each 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University The Digital Advantage! In a nut shell Digital signals are more reliable compared with analog signals! Positive & Negative logic We will study + & - logic and use it in the design of digital circuits. Combinational vs. Sequential circuits. We will study these two types of circuits and use them to design complex systems. Asynchronous vs. Synchronous. Sequential circuits can be further classified as synchronous or asynchronous. We will study both types. 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Transistors and Physical Size How many transistors are needed in a 32-Bit Adder? NOT: 32 x 3 = 96 NOT gates @ 1 tran/gate = 96 AND: 32 x 16 = 512 AND gates @ 3 tran/gate = 1536 OR: 32 x 6 = 192 OR gates @ 3 tran/gate = 576 Total = 2208 How big is this addition circuit? Built with vacuum tubes Built with magnetic cores Built with transistors NOTE: optimized 32-bit addition circuits can be constructed with FAR fewer transistors (500 – 600) 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Control Circuits Control circuits – used to determine the order in which operations are performed select the correct data values to process Definitions (no other meaning matters to us) Multiplexor From 2N input, select 1 output, using N selector lines Decoder N input lines determine which ONE of 2N output lines 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Multiplexor N selector lines can “select” one output from 2N input lines Useful to select data 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Multiplexor Example 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Decoder N input lines can determine which one (and ONLY one) of 2N output lines will be turned on Useful to select the correct instruction 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Decoder Example 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Truth Tables, Expressions & Circuits You need to be able to create two of these given the third. That’s any two! Always use the “sum of products” algorithm Make sure you practice the process enough that you can FULLY answer an exam question. What do I mean by “fully?” You may also have to combine circuits to create more complex circuits. 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Dr. M. A. Moustafa Hassan Cairo University Interesting Links Binary Numbers http://www.math.grin.edu/~rebelsky/Courses/152/97F/Readings/student-binary.html Character Issues http://www.cs.tut.fi/~jkorpela/chars.html Core Memory http://www.psych.usyd.edu.au/pdp-11/core.html Transistor http://www.pbs.org/transistor/ Semiconductor http://www.answers.com/topic/semiconductor 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Misconceptions And Difficulties The distinction between the ASCII representation of a number as a character and the binary representation of that number as an integer or float. Confusion with construction of gates is common Translating the goal of binary addition into the steps used in creating the adder circuit. Review the binary addition algorithm Function and design of both multiplexors and decoders is difficult. (roles/quantity of input, output and selector lines) 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Analysis and Design Tools De Morgan’s Laws The duality principle Karnaugh maps provide an alternative technique for representing Boolean functions. Equivalent circuits (AND-OR and NAND-NAND circuits) 4-signal Karnaugh map Karnaugh map representation of a 2-input AND gate 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University
Karnaugh maps software http://karnaugh.shuriksoft.com/ Interactive Karnaugh maps: http://maui.theoinf.tu-ilmenau.de/~sane/projekte/karnaugh/embed_karnaugh.html 21-Nov-18 Dr. M. A. Moustafa Hassan Cairo University