21.0 Number & codes Digital vs. analog quantities Decimal numbering system (Base 10)Binary numbering system (Base 2)Hexadecimal numbering system (Base 16)Octal numbering system (Base 8)Number conversionBinary arithmetic1’s and 2’s complements of binary numbers
3Number & codes Signed numbers Arithmetic operations with signed numbersBinary-Coded-Decimal (BCD)ASCII codesGray codesDigital codes & parity
4Digital vs. AnalogueDigital signals are represented by only two possible -1 (binary 1) 0r 0 (binary 0)Sometimes call these values “high” and “low” or “ true” and “false””Example : light switch , it can be in just two position – “ on ” or “ off ”More complicated signals can be constructed from 1s and 0s by stringing them end-to end. Example : 3 binary digits, have 8 possible combinations :000,001,010,011,100,101,110 and 111.The diagram : example a typical digital signal, represented as a series of voltage levels that change as time goes on.
5Digital vs. AnalogueAnalogue electronics can be any value within limits.Example : Voltage change simultaneously from one value to the next, like gradually turning a light dimmer switch up or down.The diagram below shows an analoq signal that changes with time.
6Digital vs. Analogue Why digital ? Problem with all signals – noise Noise isn't just something that you can hear - the fuzz that appears on old video recordings also qualifies as noise. In general, noise is any unwanted change to a signal that tends to corrupt it.Digital and analogue signals with added noise:Analog : never get back a perfect copy of the original signalDigital : easily be recognized evenamong all that noise : either 0 or 1
7Digital and analog quantities Two ways of representing the numerical values of quantities :i) Analog (continuous)ii) Digital (discrete)Analog : a quantity represented by voltage, current or meter movement that is proportional to the value that quantityDigital : the quantities are represented not by proportional quantities but by symbols called digits
8Digital and analog systems Digital system:combination of devices designed to manipulate logical information or physical quantities that are represented in digital formsExample : digital computers and calculators, digital audio/video equipments, telephone system.Analog system:contains devices manipulate physical quantities that are represented in analog formExample : audio amplifiers, magnetic tape recording and playback equipment, and simple light dimmer switch
11Introduction to Numbering Systems We are all familiar with decimal number systems - use everyday :calculator, calendar, phone or any common devices use this numbering system :Decimal = Base 10Some other number systems:Binary = Base 2Octal = Base 8Hexadecimal = Base 16
12Numbering Systems Decimal Binary Octal Hexadecimal 0 ~ 9 0 ~ 1 0 ~ 7 0 ~ F
14Most significant digit Least significant digit Significant DigitsBinary:Most significant digit Least significant digitHexadecimal: 1D63A7A
15Decimal numbering system (Base 10) Example : 39710Weights for whole numbers are positive power of ten that increase from right to left , beginning with 1003 X 102+9 X 101+7 X 100==39710
16Binary Number System 1X 22 + 0 X 21 + 1 X 20 = 4 + 0 + 1 = 510 Base 2 system – (0 , 1)used to model the series of electrical signals computers use to represent information0 represents the no voltage or an off state1 represents the presence of voltage or an on stateExample :Weights in a binary number are based on power of two, that increase from right to right to left,beginning with 201X 22+0 X 21+1 X 20==510
17Octal Number System + + = = Base 8 system – (0,1,2,3,4,5,6,7) 7X 82 multiplication and division algorithms for conversion to and from base 10Example : convert to decimal:Weights in a binary number are based on power of eight that increase from right to right to left,beginning with 80+7X 825 X 81+6 X 80=49410=Readily converts to binaryGroups of three (binary) digits can be used to represent each octal numberExample : convert to binary :
18Hexadecimal Number System BINARY0000100012001030011401005010160110701118100091001A101010B111011C121100D131101E141110F151111Base 16 systemUses digits 0 ~ 9 &letters A,B,C,D,E,FGroups of four bits represent each base 16 digit
19Hexadecimal Number System Base 16 system –multiplication and division algorithms for conversion to and from base 10Example : A9F16 convert to decimal:A FWeights in a hexadecimal number are based on power of sixteen that increase from right to right to left,beginning with 16010X 162+9 X 161+15 X 160=271910=Readily converts to binaryGroups of four (binary) digits can be used to represent each hexadecimal numberExample : A9F8 convert to binary :A F16
20Number ConversionAny Radix (base) to Decimal Conversion
21Number Conversion (BASE 2 –BASE 10) Binary to Decimal Conversion
22Binary to Decimal Conversion Convert ( )2 to its decimal equivalent: Binary Positional Valuesxxxxxxxx2726252423222120Products17310
23Octal to Decimal Conversion Convert 6538 to its decimal equivalent:Octal DigitsxxxPositional ValuesProducts42710
24Hexadecimal to Decimal Conversion Convert 3B4F16 to its decimal equivalent:Hex Digits3 B FxxxxPositional ValuesProducts15,18310
25Number Conversion INTEGER DIGIT: Decimal to Any Radix (Base) ConversionINTEGER DIGIT:Repeated division by the radix & record the remainderFRACTIONAL DECIMAL:Multiply the number by the radix until the answer is in integerExample:to Binary
40Binary Subtraction0 - 0 = 01 - 1 = 01 - 0 = 110 -1 = with a borrow of 1Example:???
41Binary Multiplication 0 X 0 = 00 X 1 = 0 Example:1 X 0 =1 X 1 = X100110000000
42Binary DivisionUse the same procedure as decimal division
431’s complements of binary numbers Changing all the 1s to 0s and all the 0s to 1sExample:Binary number’s complement
442’s complements of binary numbers Step 1: Find 1’s complement of the numberBinary #1’s complementStep 2: Add 1 to the 1’s complement
45Signed Magnitude Numbers …Sign bit31 bits for magnitude0 = positive1 = negativeThis is your basicInteger format
46Sign numbers Left most is the sign bit Sign-magnitude 1’s complement 0 is for positive, and 1 is for negativeSign-magnitude= +25sign bit magnitude bits1’s complementThe negative number is the 1’s complement of the corresponding positive numberExample:+25 is is
47Sign numbers 2’s complement Example Express +19 and -19 in The positive number – same as sign magnitude and 1’s complementThe negative number is the 2’s complement of the corresponding positive number.ExampleExpress +19 and -19 ini. sign magnitudeii. 1’s complementiii. 2’s complement
48Digital CodesBCD (Binary Coded Decimal) CodeRepresent each of the 10 decimal digits (0~9) as a 4-bit binary code.Example:Convert 15 to BCD.BCDConvert 10 to binary and BCD.
49Digital CodesASCII (American Standard Code for Information Interchange) CodeUsed to translate from the keyboard characters to computer languageCan convert from ASCII code to binary / hexadecimal/ or any numbering systems and vice versaHow to convert ?????
50Digital Codes Decimal Binary Gray Code 0000 1 0001 2 0010 0011 3 4 00001000120010001134010001105010101116The Gray CodeOnly 1 bit changesCan’t be used in arithmetic circuitsCan convert from Binary to Gray Code and vice versa.How to convert ?????
513.0 LOGIC GATESInverter (Gate Not)AND GateOR GateNAND GateNOR GateExclusive-OR and Exclusive-NORFixed-function logic: IC Gates
52Introduction Three basic logic gates AND Gate – expressed by “ . “ OR Gates – expressed by “ + “ sign (not an ordinary addition)NOT Gate – expressed by “ ‘ “ or “¯”
53NOT Gate (Inverter) a) Gate Symbol & Boolean Equation b) Truth Table (Jadual Kebenaran)c) Timing Diagram (Rajah Pemasaan)
54OR Gate a) Gate Symbol & Boolean Equation b) Truth Table (Jadual Kebenaran)c) Timing Diagram (Rajah Pemasaan)
55AND Gate a) Gate Symbol & Boolean Equation c) Timing Diagram (Rajah Pemasaan)b) Truth Table (Jadual Kebenaran)
62Boolean Operations & expression Variable – a symbol used to represent logical quantities (1 or 0)ex : A, B,..used as variableComplement – inverse of variable and is indicated by bar over variableex : Ā
63Operation : Boolean Addition – equivalent to the OR operation X = A + BBoolean Multiplication – equivalent to the AND operationX = A∙BAXBAXB
65Commutative law of addition A+B = B+Athe order of ORing does not matter.
66Commutative law of Multiplication AB = BAthe order of ANDing does not matter.
67Associative law of addition A + (B + C) = (A + B) + CThe grouping of ORed variables does not matter
68Associative law of multiplication A(BC) = (AB)CThe grouping of ANDed variables does not matter
69(A+B)(C+D) = AC + AD + BC + BD Distributive LawA(B + C) = AB + AC(A+B)(C+D) = AC + AD + BC + BD
70Boolean Rules 1) A + 0 = AIn math if you add 0 you have changed nothingIn Boolean Algebra ORing with 0 changes nothing
71Boolean Rules 2) A + 1 = 1ORing with 1 must give a 1 since if any inputis 1 an OR gate will give a 1
72Boolean Rules 3) A • 0 = 0In math if 0 is multiplied with anything youget 0. If you AND anything with 0 you get 0
73Boolean Rules 4) A • 1 = AANDing anything with 1 will yield the anything
74Boolean Rules 5) A + A = AORing with itself will give the same result
75Boolean Rules 6) A + A = 1Either A or A must be 1 so A + A =1
76Boolean Rules 7) A • A = AANDing with itself will give the same result
77Boolean Rules 8) A • A = 0In digital Logic 1 =0 and 0 =1, so AA=0 since one of the inputs must be 0.
78Boolean Rules 9) A = AIf you not something twice you are back to the beginning
79Boolean Rules 10) A + AB = AProof:A + AB = A(1 +B) DISTRIBUTIVE LAW= A∙ RULE 2: (1+B)=1= A RULE 4: A∙1 = A
80Boolean Rules 11) A + AB = A + B If A is 1 the output is 1 , If A is 0 the output is BProof:A + AB = (A + AB) + AB RULE 10= (AA +AB) + AB RULE 7= AA + AB + AA +AB RULE 8= (A + A)(A + B) FACTORING= 1∙(A + B) RULE 6= A + B RULE 4
81Boolean Rules 12) (A + B)(A + C) = A + BC PROOF(A + B)(A +C) = AA + AC +AB +BC DISTRIBUTIVE LAW= A + AC + AB + BC RULE 7= A(1 + C) +AB + BC FACTORING= A.1 + AB + BC RULE 2= A(1 + B) + BC FACTORING= A.1 + BC RULE 2= A + BC RULE 4
83Theorems of Boolean Algebra 1) A + 0 = A 2) A + 1 = 1 3) A • 0 = 0 4) A • 1 = A 5) A + A = A 6) A + A = 1 7) A • A = A 8) A • A = 0
84Theorems of Boolean Algebra 9) A = A 10) A + AB = A 11) A + AB = A + B 12) (A + B)(A + C) = A + BC 13) Commutative : A + B = B + A AB = BA 14) Associative : A+(B+C) =(A+B) + C A(BC) = (AB)C 15) Distributive : A(B+C) = AB +AC (A+B)(C+D)=AC + AD + BC + BD
85De Morgan’s TheoremsTwo most important theorems of Boolean Algebra were contributed by De Morgan.Extremely useful in simplifying expression in which product or sum of variables is inverted.The TWO theorems are :16) (X+Y) = X . Y 17) (X.Y) = X + Y
86Implications of De Morgan’s Theorem Input OutputX Y X+Y XY(b)(c)(a) Equivalent circuit implied by theorem (16)(b) Negative- AND(c) Truth table that illustrates DeMorgan’s Theorem
87Implications of De Morgan’s Theorem Input OutputX Y XY X+Y(b)(c)(a) Equivalent circuit implied by theorem (17)(b) Negative-OR(c) Truth table that illustrates DeMorgan’s Theorem
88De Morgan’s Theorem Conversion Step 1: Change all ORs to ANDs and all ANDs to Ors Step 2: Complement each individual variable (short overbar) Step 3: Complement the entire function (long overbars) Step 4: Eliminate all groups of double overbars Example : A . B A .B. C = A + B = A + B + C = A + B = A + B + C = A + B
89De Morgan’s Theorem Conversion ABC + ABC (A + B +C)D = (A+B+C).(A+B+C) = (A.B.C)+D = (A+B+C).(A+B+C) = (A.B.C)+D
90Examples: Analyze the circuit below 2. Simplify the Boolean expression found in 1
91Follow the steps list below (constructing truth table) List all the input variable combinations of 1 and 0 in binary sequentiallyPlace the output logic for each combination of inputBase on the result found write out the boolean expression.
92Exercises: Simplify the following Boolean expressions (AB(C + BD) + AB)CABC + ABC + ABC + ABC + ABCWrite the Boolean expression of the following circuit.
93Standard Forms of Boolean Expressions Sum of Products (SOP)Products of Sum (POS)Notes:SOP and POS expression cannot have more thanone variable combined in a term with an inversion barThere’s no parentheses in the expression
94Standard Forms of Boolean Expressions Converting SOP to Truth TableExamine each of the products to determine wherethe product is equal to a 1.Set the remaining row outputs to 0.
95Standard Forms of Boolean Expressions Converting POS to Truth TableOpposite process from the SOP expressions.Each sum term results in a 0.Set the remaining row outputs to 1.
96Standard Forms of Boolean Expressions The standard SOP ExpressionAll variables appear in each product term.Each of the product term in the expression is calledas minterm.Example:In compact form, f(A,B,C) may be written as
97Standard Forms of Boolean Expressions The standard POS ExpressionAll variables appear in each product term.Each of the product term in the expression is called asmaxterm.Example:In compact form, f(A,B,C) may be written as
98Standard Forms of Boolean Expressions Example:Convert the following SOP expression to an equivalent POS expression:Example:Develop a truth table for the expression:
100Karnaugh Map (K-Map)Karnaugh Mapping is used to minimize the number of logic gates that are required in a digital circuit.This will replace Boolean reduction when the circuit is large.Write the Boolean equation in a SOP form first and then place each term on a map.
101Karnaugh Map (K-Map)The map is made up of a table of every possible SOP using the number of variables that are being used.If 2 variables are used then a 2X2 map is usedIf 3 variables are used then a 4X2 map is usedIf 4 variables are used then a 4X4 map is usedIf 5 Variables are used then a 8X4 map is used
1032 Variables Karnaugh Map B BANotice that the map is going false to true, left to right and top to bottomB BThe upper right hand cell is A B if X= A B then put an X in that cellA1This show the expression true when A = 0 and B = 0
1042 Variables Karnaugh Map B BIf X=AB + AB then put an X in both of these cellsA11From Boolean reduction we know that A B + A B = BB BFrom the Karnaugh map we can circle adjacent cell and find that X = BA11
1053 Variables Karnaugh Map C CGray Code00 A B01 A B11 A B10 A B
1063 Variables Karnaugh Map (cont’d) X = A B C + A B C + A B C + A B CGray Code00 A B01 A B11 A B10 A BC C11Each 3 variable term is one cell on a 4 X 2 Karnaugh map11
1073 Variables Karnaugh Map (cont’d) X = A B C + A B C + A B C + A B CGray Code00 A B01 A B11 A B10 A BC COne simplification could beX = A B + A B1111
1083 Variables Karnaugh Map (cont’d) X = A B C + A B C + A B C + A B CGray Code00 A B01 A B11 A B10 A BC CAnother simplification could beX = B C + B CA Karnaugh Map does wrap around1111
1093 Variables Karnaugh Map (cont’d) X = A B C + A B C + A B C + A B CGray Code00 A B01 A B11 A B10 A BC CThe Best simplification would beX = B1111
110On a 3 Variables Karnaugh Map One cell requires 3 VariablesTwo adjacent cells require 2 variablesFour adjacent cells require 1 variableEight adjacent cells is a 1
1114 Variables Karnaugh Map Gray Code00 A B01 A B11 A B10 A BC D C D C D C D
112Simplify : X = A B C D + A B C D + A B C D + A B C D + A B C D + A B C D Gray Code00 A B01 A B11 A B10 A BC D C D C D C DNow try it with Boolean reductions111111X = ABD + ABC + CD
113On a 4 Variables Karnaugh map One Cell requires 4 variablesTwo adjacent cells require 3 variablesFour adjacent cells require 2 variablesEight adjacent cells require 1 variableSixteen adjacent cells give a 1 or true
114Simplify : Z = B C D + B C D + C D + B C D + A B C Gray Code00 A B01 A B11 A B10 A BC D C D C D C D111111111111Z = C + A B + B D
115Simplify using Karnaugh map First, we need to change the circuit to an SOP expression
116Simplify using Karnaugh map (cont’d) Y= A + B + B C + ( A + B ) ( C + D)Y = A B + B C + A B ( C + D )Y = A B + B C + A B C + A B DY = A B + B C + A B C A B DY = A B + B C + (A + B + C ) ( A + B + D)Y = A B + B C + A + A B + A D + B + B D + AC + C DSOP expression
117Simplify using Karnaugh map (cont’d) Gray Code00 A B01 A B11 A B10 A BC D C D C D C DY = 11111111111111111
124Karnaugh Map - Example Mapping a Standard SOP expression Example: Answer:Mapping a Standard POS expressionUsing K-Map, convert the following standard POSexpression into a minimum SOP expressionY = AB + AC or standard SOP :
125K-Map with “Don’t Care” Conditions Example :Input Output3 variables with output “don’t care (X)”
126K-Map with “Don’t Care” Conditions (cont’d) 4 variables with output “don’t care (X)”
127K-Map with “Don’t Care” Conditions (cont’d) Example:Determine the minimal SOP using K-Map:Answer:
128Minimum SOP expression is Solution :CDABXX X X X00011110ADBCCDMinimum SOP expression is
129Extra Exercise Minimize this expression with a Karnaugh map ABCD + ACD + BCD + ABCD
131K-map Product of Sums simplification Example: Simplify the Boolean function F(ABCD)=(0,1,2,5,8,9,10) in (a) S-of-p (b) P-of-sUsing the maxterms (0’s) and complimenting F Grouping as if they were minterms, then using De Morgen’s theorem to get F.F’(ABCD)= BD’+CD+ABF(ABCD)= (B’+D)(C’+D’)(A’+B’)Using the minterms (1’s)F(ABCD)= B’D’+B’C’+A’C’D
1325 variable K-mapAdjacent squares. E.g. square 15 is adjacent to 7,14,13,31 and its mirror square 11.The centre line must be considered as the centre of a book, each half of the K-map being a pageThe centre line is like a mirror with each square being adjacent not only to its 4 immediate neighbouring squares, but also to its mirror image.
1335 variable K-mapExample: Simplify the Boolean function F(ABCDE) = (0,2,4,6,11,13,15,17,21,25,27,29,31) Soln: F(ABCDE) = BE+AD’E+A’B’E’