CHAPTER 1 DIGITAL SYSTEMS AND BINARY NUMBERS 1 LECTURE 1 OUTLINE OF CHAPTER 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 Digital Systems Binary Numbers Number-base Conversions Octal and Hexadecimal Numbers Complements Signed Binary Numbers Binary Codes Binary Storage and Registers Binary Logic 2 2 DIGITAL SYSTEMS AND BINARY NUMBERS Digital computers General purposes Many scientific, industrial and commercial applications Digital systems Digital Telephone Digital camera Electronic calculators Digital TV 3 3 ANALOG AND DIGITAL SIGNAL Analog system The physical quantities or signals may vary continuously over a specified range. Digital system The physical quantities or signals can assume only discrete values. X(t) X(t) t Analog signal t Digital signal 4 4 BINARY DIGITAL SIGNAL For digital systems, the variable takes on discrete values. Two level, or binary values. Binary values are represented abstractly by: Digits 0 and 1 Words (symbols) False (F) and True (T) Words (symbols) Low (L) and High (H) And words Off and On 5 DECIMAL NUMBER SYSTEM Base (also called radix) = 10 Digit Position Weight = (Base) 1 0 5 1 2 -1 -2 7 4 Position Magnitude 2 Integer & fraction Digit Weight 10 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } 100 10 1 0.1 0.01 10 2 0.7 0.04 Sum of “Digit x Weight” Formal Notation 500 d2*B2+d1*B1+d0*B0+d-1*B-1+d-2*B-2 (512.74)10 6 6 OCTAL NUMBER SYSTEM Base = 8 Weights Weight = (Base) Position Magnitude 8 digits { 0, 1, 2, 3, 4, 5, 6, 7 } Sum of “Digit x Weight” Formal Notation 64 8 1 1/8 1/64 5 1 2 7 4 2 -1 1 0 -2 5 *82+1 *81+2 *80+7 *8-1+4 *8-2 =(330.9375)10 (512.74)8 7 7 BINARY NUMBER SYSTEM Base = 2 Weights 2 digits { 0, 1 }, called binary digits or “bits” Weight = (Base) Position Magnitude Sum of “Bit x Weight” Formal Notation Groups of bits 8 bits = Byte 11000101 4 2 1 1/2 1/4 1 0 1 0 1 2 -1 1 0 -2 1 *22+0 *21+1 *20+0 *2-1+1 *2-2 =(5.25)10 (101.01)2 8 8 HEXADECIMAL NUMBER SYSTEM Base = 16 Weights Weight = (Base) Position Magnitude 16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F } Sum of “Digit x Weight” Formal Notation 256 16 1 1/16 1/256 1 E 5 7 A 2 -1 1 0 -2 1 *162+14 *161+5 *160+7 *16-1+10 *16-2 =(485.4765625)10 (1E5.7A)16 9 9 THE POWER OF 2 n 2n n 2n 0 20=1 8 28=256 1 21=2 9 29=512 2 22=4 10 210=1024 3 23=8 11 211=2048 4 24=16 12 212=4096 5 25=32 20 220=1M Mega 6 26=64 30 230=1G Giga 7 27=128 40 240=1T Tera Kilo 10 10 ADDITION Decimal Addition 1 + 1 1 Carry 5 5 5 5 1 0 = Ten ≥ Base ➔ Subtract a Base 11 11 BINARY ADDITION Column Addition 1 1 1 1 1 1 1 1 1 1 0 1 = 61 1 0 1 1 1 = 23 1 0 1 0 1 0 0 = 84 + ≥ (2)10 12 12 BINARY SUBTRACTION Borrow a “Base” when needed 1 2 0 2 2 0 0 2 − = (10)2 1 0 0 1 1 0 1 = 77 1 0 1 1 1 = 23 0 1 1 0 1 1 0 = 54 13 13 BINARY MULTIPLICATION Bit by bit 1 0 1 1 1 x 1 0 1 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 1 1 1 1 1 1 0 0 1 1 0 14 14 DECIMAL (INTEGER) TO BINARY CONVERSION Divide the number by the ‘Base’ (=2) Take the remainder (either 0 or 1) as a coefficient Take the quotient and repeat the division Example: (13)10 Quotient Remainder 13 / 2 = 6/2= 3/2= 1/2= Answer: 6 3 1 0 1 0 1 1 Coefficient a0 = 1 a1 = 0 a2 = 1 a3 = 1 (13)10 = (a3 a2 a1 a0)2 = (1101)2 15 MSB LSB 15 DECIMAL (FRACTION) TO BINARY CONVERSION Multiply the number by the ‘Base’ (=2) Take the integer (either 0 or 1) as a coefficient Take the resultant fraction and repeat the multiplication Example: (0.625)10 Integer Fraction Coefficient 0.625 * 2 = 0.25 * 2 = 0.5 *2= Answer: 1 0 1 . . . 25 5 0 a-1 = 1 a-2 = 0 a-3 = 1 (0.625)10 = (0.a-1 a-2 a-3)2 = (0.101)2 MSB LSB 16 16 DECIMAL TO OCTAL CONVERSION Example: (175)10 Quotient Remainder 175 / 8 = 21 / 8 = 2 /8= 21 2 0 Answer: Coefficient a0 = 7 a1 = 5 a2 = 2 7 5 2 (175)10 = (a2 a1 a0)8 = (257)8 Example: (0.3125)10 Integer Fraction Coefficient 0.3125 * 8 = 0.5 *8= Answer: 2 4 . . 5 0 a-1 = 2 a-2 = 4 (0.3125)10 = (0.a-1 a-2 a-3)8 = (0.24)8 17 17 BINARY − OCTAL CONVERSION 8 = 23 Each group of 3 bits represents an octal digit Assume Zeros Example: ( 1 0 1 1 0 . 0 1 )2 ( 2 6 . 2 )8 Octal Binary 0 000 1 001 2 010 3 011 4 100 5 101 6 110 7 111 Works both ways (Binary to Octal & Octal to Binary) 18 18 BINARY − HEXADECIMAL CONVERSION 16 = 24 Each group of 4 bits represents a hexadecimal digit Assume Zeros Example: ( 1 0 1 1 0 . 0 1 )2 (1 6 . 4 )16 Hex Binary 0 1 2 3 4 5 6 7 8 9 A B C D E F 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Works both ways (Binary to Hex & Hex to Binary) 19 19 OCTAL − HEXADECIMAL CONVERSION Convert to Binary as an intermediate step Example: ( 2 6 . 2 )8 Assume Zeros Assume Zeros ( 0 1 0 1 1 0 . 0 1 0 )2 (1 6 . 4 )16 Works both ways (Octal to Hex & Hex to Octal) 20 20 DECIMAL, BINARY, OCTAL AND HEXADECIMAL Decimal Binary Octal Hex 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17 0 1 2 3 4 5 6 7 8 9 A B C D E F 21 21