Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Boolean Logic & Number Systems Today: Some Announcements First Hour: Introduction to Logic –Section 1.2, 1.3 of Katz’s Textbook –In-class Activity #1.

Similar presentations


Presentation on theme: "1 Boolean Logic & Number Systems Today: Some Announcements First Hour: Introduction to Logic –Section 1.2, 1.3 of Katz’s Textbook –In-class Activity #1."— Presentation transcript:

1 1 Boolean Logic & Number Systems Today: Some Announcements First Hour: Introduction to Logic –Section 1.2, 1.3 of Katz’s Textbook –In-class Activity #1 Second Hour: Number Systems –Appendix A.1 and A.2 of Katz’s Textbook –In-class Activity #2

2 2 Some Announcements An electronic copy of Katz’s textbook is on the website! Wait-listed students can now login –User name = ecse2610_stu –Password = ecse2610_stu

3 3 Truth Tables XYX ORY 0 0 1 1 0 1 0 1 0 1 1 1 X NOTX 0 1 1 0 0 0 1 1 XY 0 1 0 1 0 0 0 1 X ANDY Z = X Y = X Y Z = X + Y Z = X Boolean Equations Inverter ZX OR XYXY Z AND XYXY ZGates

4 4 Example Truth Tables Half adder adds two binary digits to form Sum and Carry AB 0 0 1 1 0 1 0 1 SumCarry 0 1 1 0 0 0 0 1 Sum equals A plus B (modulo 2) Carry equals (A plus B minus Sum)/2 Sum equals A plus B (modulo 2) Carry equals (A plus B minus Sum)/2 Full adder adds two binary digits and Carry in (Cin) to form Sum and Carry Out (Cout) A 0 0 0 0 1 1 1 1 B 0 0 1 1 0 0 1 1 Cin 0 1 0 1 0 1 0 1 Sum 0 1 1 0 1 0 0 1 Cout 0 0 0 1 0 1 1 1 Sum equals A plus B plus Cin (modulo 2) Carry equals (A plus B plus Cin minus Sum)/2 Sum equals A plus B plus Cin (modulo 2) Carry equals (A plus B plus Cin minus Sum)/2

5 5 Truth Tables to Equations Carry 0 1 A0011A0011 B0101B0101 Sum 0 1 0 Sum = A B + A B Carry = A B Step 1: Identify each truth table row where the function value is 1 Step 2: Construct (ANDed) product terms of the inputs for these rows If input variable is 0, it appears in complemented form If 1, it appears un-complemented Step3: “OR” together these product terms Half adder

6 6 Full Adder Example Cout 0 1 0 1 A00001111A00001111 B00110011B00110011 Cin 0 1 0 1 0 1 0 1 Sum 0 1 0 1 0 1 Sum = A B Cin + A B Cin + A B Cin + A B Cin Cout = A B Cin + A B Cin + A B Cin + A B Cin

7 7 1 1 Equations to Truth Tables Consider: Consider: Cout = A Cin + B Cin + A B Verify the equivalence of this Boolean equation: compare this Cout with the original Cout truth table Verify the equivalence of this Boolean equation: compare this Cout with the original Cout truth table Notice This row is covered 3 times Each product term in the equation covers exactly two rows in the truth table Put a 1 in each row where product term is true Fill in rest of Cout with 0s 1 1 1 1 1 1 1 0 0 0 1 0 1 1 1 CoutA 0 0 0 0 1 1 1 1 Cin 0 1 0 1 0 1 0 1 B 0 0 1 1 0 0 1 1

8 8 Equations to Circuits Carry = A B Half Adder A B Sum Carry A BA B Sum = A B + A B A BA B B A A BA B

9 9 Full Adder Cout = A B Cin + A B Cin + A B Cin + A B Cin Sum = A B Cin + A B Cin + A B Cin + A B Cin Notation: \A = A, etc.

10 10 Equivalent Circuits Cout = A Cin + B Cin + A BCout = A B Cin + A B Cin + A B Cin + A B Cin 

11 11 Some Practicalities "Rules of Composition" place limits on fan-in/fan-out Fan-out number of inputs a gate output is connected to Fan-in number of inputs available on a gate

12 12 Do Activity #1 Now Reference: –Section 1.2, 1.3 of Katz Textbook

13 13 Most modern computers use logic circuits that exhibit two states (binary digital) Large binary numbers are unwieldy, so alternative representations are used. Hexadecimal numbers are a compromise between efficient representation and conversion to a more natural (to most humans) decimal system. It is important to understand these other bases when designing hardware and software. Computers and Numbers

14 14 Notation Unless otherwise noted, the default base for quantities is decimal (base 10) Subscripts following a quantity indicate the base Examples: 123 10 is base 10 or decimal, so is 123 123 16 is base 16 or hexadecimal 101 2 is base 2 or binary Other notation (used later on in this course): %101 is binary $123 is hexadecimal

15 15 Uses 10 digits [ 0, 1, 2,... 9 ] Decimal Numbers In general: N =  N i x 10 i where N i  [0, 1, 2,...8, 9], where N i are the weights and the base of the number system is raised to the exponent i. Note: decimal fractions occur when i is negative 0.35 = 3 x 10 -1 + 5 x 10 -2 In general: N =  N i x 10 i where N i  [0, 1, 2,...8, 9], where N i are the weights and the base of the number system is raised to the exponent i. Note: decimal fractions occur when i is negative 0.35 = 3 x 10 -1 + 5 x 10 -2 Positional Number Notation Weight of digit determined by its position. Positional Number Notation Weight of digit determined by its position. Example: 246= 200 + 40 + 6 = 2 x 10 2 + 4 x 10 1 + 6 x 10 0

16 16 Binary Numbers Uses 2 digits [ 0 & 1 ] Example: 111001 2 = 100000 2 + 10000 2 + 1000 2 + 000 2 + 00 2 + 1 2 = 1 x 2 5 + 1 x 2 4 + 1 x 2 3 + 0 x 2 2 + 0 x 2 1 + 1 x 2 0 = 1 x 32 + 1 x 16 + 1 x 8 + 0 x 4 + 0 x 2 + 1 x 1 = 57 10 In general: N =  N i x 2 i where N i  [0, 1]. Note: binary fractions occur when i is negative 0.11 2 = 1x 2 -1 + 1 x 2 -2 = 0.5 10 + 0.25 10 = 0.75 10 In general: N =  N i x 2 i where N i  [0, 1]. Note: binary fractions occur when i is negative 0.11 2 = 1x 2 -1 + 1 x 2 -2 = 0.5 10 + 0.25 10 = 0.75 10 Positional Number Notation

17 17 Hexadecimal (Hex) Numbers Example: 89AB 16 = 8000 16 + 900 16 + A0 16 + B 16 = 8 x 16 3 + 9 x 16 2 + A x 16 1 + B x 16 0 = 8 x 4096 + 9 x 256 + 10 x 16 + 11 x 1 = 35243 10 Uses 16 digits [ 0, 1, 2,... 9, A, B, C, D, E, F ] In general: N =  N i x 16 i where N i  [0, 1, 2,..., 9, A, B, C, D, E, F]. Note: hexadecimal fractions occur when i is negative 0.9A 16 = 9 x 16 -1 + 10 x 16 -2 = 0.5625 10 + 0.0390625 10 = 0.6015625 10 In general: N =  N i x 16 i where N i  [0, 1, 2,..., 9, A, B, C, D, E, F]. Note: hexadecimal fractions occur when i is negative 0.9A 16 = 9 x 16 -1 + 10 x 16 -2 = 0.5625 10 + 0.0390625 10 = 0.6015625 10 Note: A - F represent the decimal values of 10 - 15, respectively. Positional Number Notation

18 18 Conversion Among Bases Conversion from any base to decimal: Use positions and weights ! Eg: Decimal value =  N i x B i where N i  [0, 1, 2,... N B-1 ] (  means “sum of”) Eg: 89AB 16 = 8 x 4096 + 9 x 256 + 10 x 16 + 11 x 1 = 35243 10 Conversion among the 2 n bases (binary, hexadecimal, octal, etc.): First convert to binary (base 2) & then regroup into n bits Then convert the groups of bits into the proper digits.

19 19 Memorize this table!!! It makes conversions between hexadecimal and binary trivial Hexadecimal  Binary HexBinaryDecimal 00000 0 10001 1 20010 2 30011 3 4 0100 4 5 0101 5 6 0110 6 70111 7 81000 8 91001 9 A101010 B101111 C110012 D110113 E111014 F111115 HexBinaryDecimal 00000 0 10001 1 20010 2 30011 3 4 0100 4 5 0101 5 6 0110 6 70111 7 81000 8 91001 9 A101010 B101111 C110012 D110113 E111014 F111115 Example: convert 10011000111001101 2  hexadecimal Group by 4s, starting at the right  expand into 4 bit groups 1 0011 0001 1100 1101 2  1 3 1 C D 16 Example: convert 10011000111001101 2  hexadecimal Group by 4s, starting at the right  expand into 4 bit groups 1 0011 0001 1100 1101 2  1 3 1 C D 16

20 20 Decimal  Binary Example: 57  2 =28,remainder = 1 (binary number will end with 1) 28  2 =14,remainder = 0 14  2 =7,remainder = 0 7  2 =3,remainder = 1 3  2 =1,remainder = 1 1  2 =0,remainder = 1 (binary number will start with 1) Therefore, collecting the remainders, 57 10 = 111001 2 (((((0x2 + 1)x2 + 1)x2 + 1)x2 +0)x2 +0)x2 +1 = 1x32 + 1x16 + 1x8 + 0x4 + 0x2 + 1x1 = 57 (check: 32 + 16 + 8 + 0 + 0 + 1 = 57) Based on the remainders after dividing the decimal number repeatedly by 2. If the decimal number is even, the corresponding binary number will end in a 0, and if it is odd, the binary number will end in a 1, and so on. Based on the remainders after dividing the decimal number repeatedly by 2. If the decimal number is even, the corresponding binary number will end in a 0, and if it is odd, the binary number will end in a 1, and so on. Successive Division: Successive Division: an easy way to convert Decimal to Binary

21 21 Decimal  Hex Example: 35243 / 16=2202,remainder = 11  B(hex number will end with B) 2202 / 16=137,remainder = 10  A 137 / 16=8,remainder = 9 8 / 16 =0, remainder = 8(hex number will start with 8) Therefore, collecting the remainders, 35243 10 = 89AB 16 (check: 8 x 4096 + 9 x 256 +10 x 16 + 11 = 35243) Successive Division: Successive Division: an easy way to convert Decimal to Hexadecimal Based on the remainders after dividing the decimal number by higher powers of 16. Notice how simple this method is

22 22 Hex  Decimal Example: BA89  B x 16 3 + A x 16 2 + 8 x 16 + 9 (CAUTION: mixed bases) = 11 x 4096 + 10 x 256 + 8 x 16 + 9 = 45056 + 2560 + 128 + 9 = 47753 We can check by converting back to hex: 47753 / 16 = 2984 + remainder, 9 2984 / 16 = 186 + remainder, 8 186 / 16 = 11 + remainder, 10  A 11 / 16 = 0 + remainder, 11  B  47753 10  BA89 16 Multiplication: Multiplication: an easy way to convert Hexadecimal to Decimal Multiply the hexadecimal weights by powers of 16.

23 23 Binary  Decimal Compare: 11010110 2  2 7 + 2 6 + 2 4 + 2 2 + 2 (exploiting the binary weights) = 128 + 64 + 16 + 4 + 2 = 214 10 11010110 2  D6 16  13 x 16 + 6 = 208 + 6 = 214 10 Multiplication: Multiplication: an easy way to convert Binary to Decimal We can multiple the binary weights by powers of 2. However, sometimes it is just as easy to convert the binary number to hexadecimal first and and then into decimal. We can multiple the binary weights by powers of 2. However, sometimes it is just as easy to convert the binary number to hexadecimal first and and then into decimal.

24 24 Do Activity #2 Now Due: End of Class Today RETAIN THE LAST PAGE (#3)!! For Next Class: Bring Randy Katz Textbook –Course website has an electronic copy available. Required Reading: – Sec A.1, A.2, 2.1, 2.2 (up to 2.2.4) of Katz This reading is necessary for getting points in the Studio Activity! Studio Session #2 Tuesday/Wednesday


Download ppt "1 Boolean Logic & Number Systems Today: Some Announcements First Hour: Introduction to Logic –Section 1.2, 1.3 of Katz’s Textbook –In-class Activity #1."

Similar presentations


Ads by Google