# Princess Sumaya Univ. Computer Engineering Dept. د. بســام كحـالــه Dr. Bassam Kahhaleh.

## Presentation on theme: "Princess Sumaya Univ. Computer Engineering Dept. د. بســام كحـالــه Dr. Bassam Kahhaleh."— Presentation transcript:

Princess Sumaya Univ. Computer Engineering Dept. د. بســام كحـالــه Dr. Bassam Kahhaleh

Princess Sumaya Univ. Computer Engineering Dept. Chapter 1:

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 2 / 45 Digital Systems  Discrete Data ●Examples: ♦ 26 letters of the alphabet (A, B … etc) ♦ 10 decimal digits (0, 1, 2 … etc) ●Combine together ♦ Words are made of letters (University … etc) ♦ Numbers are made of digits (4241 … etc)  Binary System ●Only ‘0’ and ‘1’ digits ●Can be easily implemented in electronic circuits AnalogDiscrete

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 3 / 45 Decimal Number System  Base (also called radix) = 10 ●10 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }  Digit Position ●Integer & fraction  Digit Weight ●Weight = (Base) Position  Magnitude ●Sum of “Digit x Weight”  Formal Notation 102-2 51274 1010.11000.01 5001020.70.04 d 2 *B 2 +d 1 *B 1 +d 0 *B 0 +d -1 *B -1 +d -2 *B -2 (512.74) 10

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 4 / 45 Octal Number System  Base = 8 ●8 digits { 0, 1, 2, 3, 4, 5, 6, 7 }  Weights ●Weight = (Base) Position  Magnitude ●Sum of “Digit x Weight”  Formal Notation 102-2 811/8641/64 51274 5 *8 2 +1 *8 1 +2 *8 0 +7 *8 -1 +4 *8 - 2 =(330.9375) 10 (512.74) 8

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 5 / 45 Binary Number System  Base = 2 ●2 digits { 0, 1 }, called b inary dig its or “bits”  Weights ●Weight = (Base) Position  Magnitude ●Sum of “Bit x Weight”  Formal Notation  Groups of bits 4 bits = Nibble 8 bits = Byte 102-2 211/241/4 10101 1 *2 2 +0 *2 1 +1 *2 0 +0 *2 -1 +1 *2 - 2 =(5.25) 10 (101.01) 2 1 0 1 1 1 1 0 0 0 1 0 1

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 6 / 45 Hexadecimal Number System  Base = 16 ●16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }  Weights ●Weight = (Base) Position  Magnitude ●Sum of “Digit x Weight”  Formal Notation 102-2 161 1/16 256 1/256 1E57A 1 *16 2 +14 *16 1 +5 *16 0 +7 *16 -1 +10 *16 -2 =(485.4765625) 10 (1E5.7A) 16

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 7 / 45 The Power of 2 n2n2n 02 0 =1 12 1 =2 22 2 =4 32 3 =8 42 4 =16 52 5 =32 62 6 =64 72 7 =128 n2n2n 82 8 =256 92 9 =512 102 10 =1024 112 11 =2048 122 12 =4096 202 20 =1M 302 30 =1G 402 40 =1T Mega Giga Tera Kilo

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 8 / 45 Addition  Decimal Addition 55 55 + 011 = Ten ≥ Base  Subtract a Base 11Carry

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 9 / 45 Binary Addition  Column Addition 101111 11110 + 0000111 ≥ (2) 10 111111 = 61 = 23 = 84

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 10 / 45 Binary Subtraction  Borrow a “Base” when needed 001110 11110 − 0101110 = (10) 2 2 2 2 2 1 000 1 = 77 = 23 = 54

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 11 / 45 Binary Multiplication  Bit by bit 01111 0110 00000 01111 01111 0 0000 01101110 x

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 12 / 45 Number Base Conversions Decimal (Base 10) Octal (Base 8) Binary (Base 2) Hexadecimal (Base 16) Evaluate Magnitude

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 13 / 45 Decimal (Integer) to Binary Conversion DD ivide the number by the ‘Base’ (=2) TT ake the remainder (either 0 or 1) as a coefficient TT ake the quotient and repeat the division Example: ( 13 ) 10 QuotientRemainder Coefficient Answer: (13) 10 = (a 3 a 2 a 1 a 0 ) 2 = (1101) 2 MSB LSB 13 / 2 = 61 a 0 = 1 6 / 2 = 30 a 1 = 0 3 / 2 = 11 a 2 = 1 1 / 2 = 01 a 3 = 1

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 14 / 45 Decimal (Fraction) to Binary Conversion MM ultiply the number by the ‘Base’ (=2) TT ake the integer (either 0 or 1) as a coefficient TT ake the resultant fraction and repeat the division Example: ( 0.625 ) 10 IntegerFraction Coefficient Answer: (0.625) 10 = (0.a -1 a -2 a -3 ) 2 = (0.101) 2 MSB LSB 0.625 * 2 = 1. 25 0.25 * 2 = 0. 5 a -2 = 0 0.5 * 2 = 1. 0 a -3 = 1 a -1 = 1

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 15 / 45 Decimal to Octal Conversion Example: ( 175 ) 10 QuotientRemainder Coefficient Answer: (175) 10 = (a 2 a 1 a 0 ) 8 = (257) 8 175 / 8 = 217 a 0 = 7 21 / 8 = 25 a 1 = 5 2 / 8 = 02 a 2 = 2 Example: ( 0.3125 ) 10 IntegerFraction Coefficient Answer: (0.3125) 10 = (0.a -1 a -2 a -3 ) 8 = (0.24) 8 0.3125 * 8 = 2. 5 0.5 * 8 = 4. 0 a -2 = 4 a -1 = 2

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 16 / 45 Binary − Octal Conversion  8 = 2 3  Each group of 3 bits represents an octal digit OctalBinary 00 0 0 10 0 1 20 1 0 30 1 1 41 0 0 51 0 1 61 1 0 71 1 1 Example: ( 1 0 1 1 0. 0 1 ) 2 ( 2 6. 2 ) 8 Assume Zeros Works both ways (Binary to Octal & Octal to Binary)

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 17 / 45 Binary − Hexadecimal Conversion  16 = 2 4  Each group of 4 bits represents a hexadecimal digit HexBinary 00 0 10 0 0 1 20 0 1 0 30 0 1 1 40 1 0 0 50 1 60 1 1 0 70 1 1 1 81 0 0 0 91 0 0 1 A1 0 B1 0 1 1 C1 1 0 0 D1 1 0 1 E1 1 1 0 F1 1 Example: ( 1 0 1 1 0. 0 1 ) 2 ( 1 6. 4 ) 16 Assume Zeros Works both ways (Binary to Hex & Hex to Binary)

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 18 / 45 Octal − Hexadecimal Conversion  Convert to Binary as an intermediate step Example: ( 0 1 0 1 1 0. 0 1 0 ) 2 ( 1 6. 4 ) 16 Assume Zeros Works both ways (Octal to Hex & Hex to Octal) ( 2 6. 2 ) 8 Assume Zeros

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 19 / 45 Decimal, Binary, Octal and Hexadecimal DecimalBinaryOctalHex 000000000 010001011 020010022 030011033 040100044 050101055 060110066 070111077 081000108 091001119 10101012A 11101113B 12110014C 13110115D 14111016E 15111117F

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 20 / 45 Complements 11 ’s Complement (Diminished Radix Complement) ●A●All ‘0’s become ‘1’s ●A●All ‘1’s become ‘0’s Example (10110000) 2  (01001111) 2 If you add a number and its 1’s complement … 1 0 1 1 0 0 0 0 + 0 1 0 0 1 1 1 1 1 1 1 1

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 21 / 45 Complements 22 ’s Complement (Radix Complement) ●T●Take 1’s complement then add 1 ●T●Toggle all bits to the left of the first ‘1’ from the right Example: Number: 1’s Comp.: 0 1 0 1 0 0 0 0 1 0 1 1 0 0 0 0 0 1 0 0 1 1 1 1 + 1 OR 1 0 1 1 0 0 0 0 00001010

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 22 / 45 Negative Numbers CC omputers Represent Information in ‘0’s and ‘1’s ●‘●‘+’ and ‘−’ signs have to be represented in ‘0’s and ‘1’s 33 Systems ●S●Signed Magnitude ●1●1’s Complement ●2●2’s Complement All three use the left-most bit to represent the sign: ♦‘♦‘ 0’  positive ♦‘♦‘ 1’  negative

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 23 / 45 Signed Magnitude Representation MM agnitude is magnitude, does not change with sign (+3) 10  ( 0 0 1 1 ) 2 (−3) 10  ( 1 0 1 1 ) 2 CC an’t include the sign bit in ‘Addition’ 0 0 1 1  (+3) 10 + 1 0 1 1  (−3) 10 1 1 1 0  (−6) 10 SignMagnitude SMagnitude (Binary)

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 24 / 45 1’s Complement Representation PP ositive numbers are represented in “Binary” NN egative numbers are represented in “1’s Comp.” (+3) 10  (0 011) 2 (−3) 10  (1 100) 2 TT here are 2 representations for ‘0’ (+0) 10  (0 000) 2 (−0) 10  (1 111) 2 0Magnitude (Binary) 1Code (1’s Comp.)

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 25 / 45 1’s Complement Range  4-Bit Representation 2 4 = 16 Combinations − 7 ≤ Number ≤ + 7 −2 3 +1 ≤ Number ≤ +2 3 − 1  n-Bit Representation −2 n−1 +1 ≤ Number ≤ +2 n−1 − 1 Decimal1’s Comp. + 70 1 1 1 + 60 1 1 0 + 50 1 + 40 1 0 0 + 30 0 1 1 + 20 0 1 0 + 10 0 0 1 + 00 0 − 01 1 − 11 1 1 0 − 21 1 0 1 − 31 1 0 0 − 41 0 1 1 − 51 0 − 61 0 0 1 − 71 0 0 0

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 26 / 45 2’s Complement Representation PP ositive numbers are represented in “Binary” NN egative numbers are represented in “2’s Comp.” (+3) 10  (0 011) 2 (−3) 10  (1 101) 2 TT here is 1 representation for ‘0’ (+0) 10  (0 000) 2 (−0) 10  (0 000) 2 0Magnitude (Binary) 1Code (2’s Comp.) 1’s Comp. 1 1 1 1 + 1 1 0 0 0 0

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 27 / 45 2’s Complement Range  4-Bit Representation 2 4 = 16 Combinations − 8 ≤ Number ≤ + 7 −2 3 ≤ Number ≤ + 2 3 − 1  n-Bit Representation −2 n−1 ≤ Number ≤ + 2 n−1 − 1 Decimal2’s Comp. + 70 1 1 1 + 60 1 1 0 + 50 1 + 40 1 0 0 + 30 0 1 1 + 20 0 1 0 + 10 0 0 1 + 00 0 − 11 1 − 21 1 1 0 − 31 1 0 1 − 41 1 0 0 − 51 0 1 1 − 61 0 − 71 0 0 1 − 81 0 0 0

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 28 / 45 Number Representations  4-Bit Example Unsigned Binary Signed Magnitude 1’s Comp.2’s Comp. Range0 ≤ N ≤ 15-7 ≤ N ≤ +7 -8 ≤ N ≤ +7 Positive Binary Negative X Binary1’s Comp.2’s Comp. 000111

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 29 / 45 Binary Subtraction Using 1’s Comp. Addition CC hange “Subtraction” to “Addition” II f “Carry” = 1 then add it to the LSB, and the result is positive (in Binary) II f “Carry” = 0 then the result is negative (in 1’s Comp.) 0 1 + 1 1 1 0 (5) 10 – (1) 10 (+5) 10 + (-1) 10 0 0 1 1 + 0 1 0 0 0 1 + 1 0 0 1 (5) 10 – (6) 10 (+5) 10 + (-6) 10 0 1 1 1 0 1 1 1 0 + 4− 1 1

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 30 / 45 Binary Subtraction Using 2’s Comp. Addition CC hange “Subtraction” to “Addition” II f “Carry” = 1 ignore it, and the result is positive (in Binary) II f “Carry” = 0 then the result is negative (in 2’s Comp.) 0 1 + 1 1 1 1 (5) 10 – (1) 10 (+5) 10 + (-1) 10 1 0 1 0 0 0 1 + 1 0 1 0 (5) 10 – (6) 10 (+5) 10 + (-6) 10 0 1 1 1 1 + 4 − 1

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 31 / 45 Binary Codes GG roup of n bits ●U●Up to 2 n combinations ●E●Each combination represents an element of information BB inary Coded Decimal (BCD) ●E●Each Decimal Digit is represented by 4 bits ●(●(0 – 9)  Valid combinations ●(●(10 – 15)  Invalid combinations DecimalBCD 00 0 10 0 0 1 20 0 1 0 30 0 1 1 40 1 0 0 50 1 60 1 1 0 70 1 1 1 81 0 0 0 91 0 0 1

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 32 / 45 BCD Addition OO ne decimal digit + one decimal digit ●I●If the result is 1 decimal digit ( ≤ 9 ), then it is a simple binary addition Example: ●I●If the result is two decimal digits ( ≥ 10 ), then binary addition gives invalid combinations Example: 5 + 3 8 0 1 + 0 0 1 1 1 0 0 0 5 + 5 1 0 0 1 + 0 1 0 1 1 0 0 0 0 1 0 0 0 0

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 33 / 45 BCD Addition II f the binary result is greater than 9, correct the result by adding 6 5 + 5 1 0 0 1 + 0 1 0 1 1 0 + 0 1 1 0 0 0 0 1 0 0 0 0 Two Decimal Digits Multiple Decimal Digits 3 5 1 0 0 1 10 1 0 0 0 1

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 34 / 45 Gray Code OO ne bit changes from one code to the next code DD ifferent than Binary DecimalGray 000000 010001 020011 030010 040110 050111 060101 070100 081100 091101 101111 111110 121010 131011 141001 151000 Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 35 / 45 ASCII Code American Standard Code for Information Interchange Info7-bit Code A1000001 B1000010............ Z1011010 a1100001 b1100010............ z1111010 @1000000 ?0111111 +0101011

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 36 / 45 Error Detecting Codes PP arity One bit added to a group of bits to make the total number of ‘1’s (including the parity bit) even or odd ●E●Even ●O●Odd GG ood for checking single-bit errors 1 0111 1000001 0 0 01111000001 1 4-bit Example 7-bit Example

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 37 / 45 Binary Logic  Operators ●NOT If ‘x’ = 0thenNOT ‘x’ = 1 If ‘x’ = 1thenNOT ‘x’ = 0 ●AND If ‘x’ = 1 AND ‘y’ = 1then‘z’ = 1 Otherwise‘z’ = 0 ●OR If ‘x’ = 1 OR ‘y’ = 1then‘z’ = 1 Otherwise‘z’ = 0

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 38 / 45 Binary Logic  Truth Tables, Boolean Expressions, and Logic Gates xyz 000 010 100 111 xyz 000 011 101 111 xz 01 10 ANDORNOT z = x y = x yz = x + yz = x = x’

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 39 / 45 Logic Signals BB inary ‘0’ is represented by a “low” voltage (range of voltages) BB inary ‘1’ is represented by a “high” voltage (range of voltages) TT he “voltage ranges” guard against noise of binary signalsExample

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 40 / 45 Switching Circuits ANDOR

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 41 / 45 Homework  Mano ●Chapter 1 ♦ 1-2 ♦ 1-7 ♦ 1-9 ♦ 1-10 ♦ 1-11 ♦ 1-16 ♦ 1-18 ♦ 1-20 ♦ 1-24(a) ♦ 1-29  Write your family name in ASCII with odd parity  Decode the following ASCII string (with MSB = parity): 11000011 01101111 11101101 11110000 11000000 01010000 01010011 01010101 11010100 Is the parity even or odd?

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 42 / 45 Homework  Mano 1-2What is the exact number of bytes in a system that contains (a) 32K byte, (b) 64M byte, and (c) 6.4G byte? 1-7Express the following numbers in decimal: (10110.0101) 2, (16.5) 16, and (26.24) 8. 1-9Convert the hexadecimal number 68BE to binary and then from binary convert it to octal. 1-10Convert the decimal number 345 to binary in two ways: (a) convert directly to binary, (b) convert first to hexadecimal, then from hexadecimal to binary. Which method is faster?

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 43 / 45 Homework 1-11Do the following conversion problems: (a) Convert decimal 34.4375 to binary. (b) Calculate the binary equivalent of 1/3 out to 8 places. Then convert from binary to decimal. How close is the result to 1/3? (c) Convert the binary result in (b) into hexadecimal. Then convert the result to decimal. Is the answer the same? 1-16Obtain the 1’s and 2’s complements of the following binary numbers: (a) 11101010 (b) 01111110 (c) 00000001 (d) 10000000 (e) 00000000

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 44 / 45 Homework 1-18Perform subtraction on the following unsigned binary numbers using the 2’s-complement of the subtrahend. Where the result should be negative, 2’s complement it and affix a minus sign. (a) 11011 – 11001 (b) 110100 – 10101 (c) 1011 – 110000 (d) 101010 – 101011 1-20Convert decimal +61 and +27 to binary using the signed- 2’s complement representation and enough digits to accommodate the numbers. Then perform the binary equivalent of (+27) + (– 61), (–27) + (+61) and (–27) + (–61). Convert the answers back to decimal and verify that they are correct.

Princess Sumaya University 4241 – Digital Logic Design Computer Engineering Dept. 45 / 45 Homework 1-24Represent decimal number 6027 in (a) BCD 1-29The following is a string of ASCII characters whose bit patterns have been converted into hexadecimal for compactness: 4A EF 68 6E 20 C4 EF E5. Of the 8 bits in each pair digit, the leftmost is a parity bit. The remaining bits are the ASCII code. (a) Convert to bit form and decode the ASCII (b) Determine the parity used: odd or even.

Download ppt "Princess Sumaya Univ. Computer Engineering Dept. د. بســام كحـالــه Dr. Bassam Kahhaleh."

Similar presentations