Digital Electronics: Understanding Numbering Systems and Algebraic Switching
Learn the basics of decimal, binary, hexadecimal, and octal numbering systems, arithmetic operations, number conversions, and digital vs. analog quantities. Understand fundamental principles in digital electronics.
Digital Electronics: Understanding Numbering Systems and Algebraic Switching
E N D
Presentation Transcript
EET209/4 DIGITAL ELECTRONICS CO1: Ability to apply the basic principles of numbering system and Algebraic Switching for complex digital electronics system. CHAPTER 1
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 conversion • Binary arithmetic • 1’s and 2’s complements of binary numbers • Signed numbers • Arithmetic operations with signed numbers • Digital codes • Logic Gates
DIGITAL vs analog • Digital signals are represented by only two possible - 1 (binary 1) or 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 ”
DIGITAL vs analog • 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 shows an example a typical digital signal, represented as a series of voltage levels that change as time goes on.
DIGITAL vs analog • Analog 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 shows an analog signal that changes with time.
DIGITAL waveform (a) Positive - going pulse (b) Negative - going pulse
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 10 ( )10 • Some other number systems: Binary = Base 2 ( )2 Octal = Base 8 ( )8 Hexadecimal = Base 16 ( )16
Numbering systems • Decimal 0 ~ 9 • Binary 0 ~ 1 • Octal 0 ~ 7 • Hexadecimal 0 ~ F
Dec Hex Octal Binary 0123456789101112131415 0123456789ABCDEF 000001002003004005006007010011012013014015016017 00000000000000010000001000000011000001000000010100000110000001110000100000001001000010100000101100001100000011010000111000001111 N U M B E R S Y S T E M S
Significant digits Binary: 1 1 1 0 1 1 0 1 Most significant bit (MSB) Least significant bit (LSB) Hexadecimal: 1 D 6 3 A 7 A Most significant digit (MSD) Least significant digit (LSD)
Decimal number (base 10) • Base 10 system - (0,1,2,3,4,5,6,7,8,9) • Example : 39710 3 9 7 Weights for whole numbers are positive power of ten that increase from right to left , beginning with 100 + (7 X 100) = (3 X 102) (9 X 101) + 300 + 90 + 7 = = 39710
binary number (base 2) • Base 2 system – (0 , 1) • used to model the series of electrical signals- computers use to represent information • ‘0’represents the no voltage or an off state • ‘1’represents the presence of voltage or an on state • Example: 1012 • 10 1 Weights in a binary number are based on power of two, that increase from right to left, beginning with 20 = + (0 X 21) + (1 X 20) (1X 22) = 4 + 0 + 1 = 510
octal number (base 8) • Base 8 system – (0,1,2,3,4,5,6,7) • multiplication and division algorithms for conversion to and from base 10 (decimal) • Example: 7568convert to decimal: • 7 5 6 Weights in a binary number are based on power of eight that increase from right to left, beginning with 80 = + + (6 X 80) (7 X 82) (5 X 81) = 448 + 40 + 6 49410 =
octal number (base 8) • Readily converts to binary • Groups of three (binary) digits can be used to represent each octal number • Example: 7568convert to binary 7 6 5 111 101 1102
hexadecimal number (base 16) • Base 16 system • Uses digits 0 ~ 9 & • letters A,B,C,D,E,F • Groups of four bits • represent each • base 16 digit
hexadecimal number (base 16) • Base 16 system • multiplication and division algorithms for conversion to and from base 10 (decimal) • Example: A9F16convert to decimal • A 9 F Weights in a hexadecimal number are based on power of sixteen that increase from right to left, beginning with 160 = (10 X 162) (9 X 161) + (15 X 160) + 2560 + 144 + 15 = 271910 =
hexadecimal number (base 16) • Readily converts to binary • Groups of four (binary) digits can be used to represent each hexadecimal number • Example:A9F16convert to binary A 9 F 1010 1001 11112
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 conversion • Binary arithmetic • 1’s and 2’s complements of binary numbers • Signed numbers • Arithmetic operations with signed numbers • Digital codes • Logic Gates DONE!
NUMBER CONVERSION • Any Radix (base) to Decimal Conversion
NUMBER CONVERSION • Binary (Base 2) to Decimal (Base 10) Conversion • Example: • Convert (10101101)2 to its decimal equivalent: • Binary 1 0 1 0 1 1 0 1 • Positional Values • Products x x x x x x x x 27 26 25 24 23 22 21 20 128 + 0 + 32 + 8 + 0 + 4 + 0 + 1 17310
NUMBER CONVERSION • Octal (Base 8) to Decimal (Base 10) Conversion • Example: • Convert 6538 to its decimal equivalent: • Octal • Positional Values • Products 6 5 3 x x x 82 81 80 384 + 40 + 3 42710
NUMBER CONVERSION • Hex (Base 16) to Decimal (Base 10) Conversion • Example: • Convert 3B4F16 to its decimal equivalent: • Hex • Positional Values • Products 3 B 4 F x x x x 163 162 161 160 12288 + 2816 + 64 + 15 1518310
NUMBER CONVERSION • Decimal to Any Radix (Base) Conversion • INTEGER DIGIT: • Repeated division by the radix & record the remainder • FRACTIONAL DECIMAL: • Multiply the number by the radix until the answer is in integer • Example: • Convert 25.312510 to binary
NUMBER CONVERSION • Decimal (Base 10) to Binary(Base 2) Conversion • Example: Convert 25.312510 to binary 2 5 = 12 + 1 2 1 2 = 6 + 0 2 6 = 3 + 0 2 3 = 1 + 1 2 1 = 0 + 1 2 remainder MSB LSB 2510 = 1 1 0 0 1 2
NUMBER CONVERSION • Decimal (Base 10) to Binary(Base 2) Conversion • Example: Convert 25.312510 to binary • . 0 1 0 1 • Carry • 0.3125 x 2 = 0.625 0 • 0.625 x 2 = 1.25 1 • 0.25 x 2 = 0.50 0 • 0.5 x 2 = 1.00 1 • Answer: 1 1 0 0 1.0 1 0 12 MSB LSB
NUMBER CONVERSION • Decimal (Base 10) to Octal (Base 8) Conversion • Example: Convert 42710 to octal • 427 / 8 = 53 R3 Divide by 8; R is LSB • 53 / 8 = 6 R5 Divide Q by 8; R is next digit • 6 / 8 = 0 R6 Repeat until Q = 0 6538
NUMBER CONVERSION • Decimal (Base 10) to Hex (Base 16) Conversion • Example: Convert 83010 to hexadecimal • 830 / 16 = 51 R14 • 51 / 16 = 3 R3 • 3 / 16 = 0 R3 14 = E in Hex 33E16
NUMBER CONVERSION • Binary (Base 2) to Octal (Base 8) Conversion (vice versa) • Grouping the binary position in groups of three starting at the least significant position. • Each octal number converts to 3 binary digits • Example: • To convert 6538 to binary, • just substitute code: 6 5 3 110 101 011
NUMBER CONVERSION • Binary (Base 2) to Octal (Base 8) Conversion (vice versa) • Example: • Convert the following binary numbers to their octal equivalent (vice versa). • 1001.11112 • 47.38 • 1010011.110112 • Answer: • 11.748 • 100111.0112 • 123.668
NUMBER CONVERSION • Binary (Base 2) to Octal (Base 8) Conversion (vice versa) • Example: • Substitution code can also be used to convert binary to octal by using 3-bit groupings: • 010 101 101 010 111 001 101 010 2 5 5 2 7 1 5 2 255271528
NUMBER CONVERSION • Binary (Base 2) to Hexadecimal (Base 16) Conversion (vice versa) • Grouping the binary position in 4-bit groups, starting from the least significant position. • The easiest method for converting binary to hexadecimal is to use a substitution code. • Each hex number converts to 4 binary digits.
NUMBER CONVERSION • Binary (Base 2) to Hexadecimal (Base 16) Conversion (vice versa) • Example: • Convert the following binary numbers to their hexadecimal equivalent (vice versa). • 10000.12 • 1F.C16 • Answer: • 10.816 • 00011111.11002
NUMBER CONVERSION • Binary (Base 2) to Hexadecimal (Base 16) Conversion (vice versa) • Example: • Convert 0101011010101110011010102 to hex using the 4-bit substitution code : 0101 0110 1010 1110 0110 1010 5 6 A E 6 A 56AE6A16
BINARY ARITHMETIC • Binary Addition • 0 + 0 = 0 Sum of 0 with a carry of 0 • 0 + 1 = 1 Sum of 1 with a carry of 0 • 1 + 0 = 1 Sum of 1 with a carry of 0 • 1 + 1 = 10 Sum of 0 with a carry of 1 • Example: • 11001 111 • + 1101 + 11 • 100110 ???
BINARY ARITHMETIC • Simple Arithmetic • Addition • Example: • 100011002 • + 1011102 • 101110102
BINARY ARITHMETIC • Binary Subtraction • 0 - 0 = 0 • 1 - 1 = 0 • 1 - 0 = 1 • 10 -1 = 1 0 - 1 with a borrow of 1 • Example: • 1011 101 • - 111 - 11 • 100 ???
BINARY ARITHMETIC • Simple Arithmetic • Subtraction • Example: • 10001002 • - 1011102 • 101102
BINARY ARITHMETIC • Binary Multiplication • 0 x 0 = 0 Example: • 0 x 1 = 0 • 1 x 0 = 0 100110 • 1 x 1 = 1 x 101 • 100110 • 000000 • + 100110 • 10111110
BINARY ARITHMETIC • Binary Division • Use the same procedure as decimal division. • Example: • Perform the following binary divisions: • (a) 110 ÷ 11 • (b) 110 ÷ 10
BINARY ARITHMETIC Solution:
COMPLEMENTS OF BINARY NUMBERS • 1’s complement • Changing all the 1s to 0s and all the 0s to 1s • Example: • 1 1 0 1 0 0 1 0 1 Binary number • 0 0 1 0 1 1 0 1 0 1’s complement
COMPLEMENTS OF BINARY NUMBERS • 2’s complement • Step 1: Find 1’s complement of the number • Binary # 11000110 • 1’s complement 00111001 • Step 2: Add 1 to the 1’s complement • 00111001 • + 00000001 • 00111010
Signed magnitude numbers 110010.. …00101110010101 Sign bit 31 bits for magnitude Please remember that 0 bit indicates POSITIVE number, and a 1 sign bit indicates a NEGATIVE number. 0 = positive 1 = negative
Signed magnitude numbers • Left most is the sign bit; • ‘0’ is for positive, and ‘1’ is for negative • Sign-magnitude (always 8 bit numbers) • 0 0 0 1 1 0 0 1 = +25 • sign bit magnitude bits • 1’s complement • The positive number is same as sign magnitude. The negative number is the 1’s complement of the corresponding positive number. • Example: • +25 is 00011001 -25 is 11100110
Signed magnitude numbers • 2’s complement • The positive number – same as sign magnitude and 1’s complement • The negative number is the 2’s complement of the corresponding positive number. • Example : • Express +19 and -19 in • sign magnitude • 1’s complement • 2’s complement
Signed magnitude numbers • 2’s complement • The positive number – same as sign magnitude and 1’s complement • The negative number is the 2’s complement of the corresponding positive number. • Example : • Express +19 and -19 in • sign magnitude • 1’s complement • 2’s complement
Exercise • Convert the following numbers: • a) 62.812510 to binary • b) 19810 to binary • Perform the following binary arithmetic operations: • a) 1112 + 1012 c) 1112 x 1102 • b) 11012 – 1012 d) 10102 / 102 • a) Determine the 1’s complement of 1001010 and 1100 • b) Determine the 2’s complement of 11001100 and 1001 • Express each pair of decimal numbers below to 8-bit binary using sign magnitude, 1’s compliment and 2’s compliment. • a) +28 and -18 • b) +45 and -55