(1) Number Systems.pdf.pptx

Full Transcript

KIE1003: DIGITAL SYSTEM Number Systems SEMESTER 1, 2024/2025 KIE1003: DIGITAL SYSTEM Analog signals Analog –continuous values Analog...

KIE1003: DIGITAL SYSTEM Number Systems SEMESTER 1, 2024/2025 KIE1003: DIGITAL SYSTEM Analog signals Analog –continuous values Analog systems can generally handle higher power than digital systems. Analog parameters have continuous range of values Example: temperature is an analogparameter Temperature increases/decreases continuously KIE1003: DIGITAL SYSTEM Digital signals Digital –discrete set of values Example: month ϵ {1, 2, 3, …, Thus, numberthe month number12} is a digital parameter (cannot be At1.5!) its most basic, digital information can assume only one of two possible values: one/zero, on/off, high/low, true/false, etc. Analog signal Digital signal KIE1003: DIGITAL SYSTEM Advantages of digital 1.Ease of design. 2 Information storage is. easy. 3.Accuracy and precision are easier to maintain. 4.Programmable operation. 5 Less affected by. noise.digital circuitry can be fabricated on IC 6.More chips. KIE1003: DIGITAL SYSTEM Analog to digital conversion Precision digital temperature control system Digital-to-Analog Converter Regenerate analogsignal from digital (DAC) form Digital input => Analog output Analog-to-Digital Converter Produces digitized version of (ADC) analogsignals Analog input => Digital output KIE1003: DIGITAL SYSTEM Digital waveforms Ideal pulse: Non-ideal pulse: KIE1003: DIGITAL SYSTEM Digital number systems Many number systems are in use in digital technology. The most common are Decimal –10 symbols (base 10) Hexadecimal –16 symbols (base 16) Octal –8 symbols (base 8) Binary –2 symbols (base 2) KIE1003: DIGITAL SYSTEM Decimal numbers 10 digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) The position of each digit in a decimal number indicates the magnitude of the quantity represented and can be assigned a weight. weights for whole numbers–positive powers of ten, increase from right to left, o = with 1. 10 beginning weight for fractional numbers–negative powers of ten, decrease from left to beginning with 10-. 1 right, The value of a decimal number is the sum of the after each digit has been multiplied by its weight. Example: 2 = x 1 1+ x 1 0 = 20 + digits 1 3 0 2 0 3 0 3 KIE1003: DIGITAL SYSTEM Binary numbers base-two system (1 and 0). weights in a binary number are based on powers of two. n In general, with nbits you can count up to a number equal to 2 -1. Example: Convert the binary whole number 1101101 to 6 5 3 2 0 110110 decimal.2 = 2 + 2 + 2 + 2 1 +=264 + 32 + 8 + 4 +1 = 109 MSB: most significant bit LSB: least KIE1003: DIGITAL SYSTEM Representing binary quantities Digital electronics uses circuits that have two states, represented by two different voltage levels called HIGH and LOW. The voltages represent numbers in the binary system. A higher range of voltages represent a valid 1 and a lower voltages 0. represent a valid range of typical digital signal timing diagram (HIGH ) (LOW) KIE1003: DIGITAL SYSTEM Decimal-to-binary conversion Sum-of-Weights One Method way to find the binary number that is equivalent to a given decimal determine the set of binary weights whose sum is equal to the decimal number.is to number Weight: 24 23 22 21 20 Binary numbe 0 1 0 0 1 r: Exampl Convert e the following decimal numbers to (a) binary: (b) 12 25 (c) (d) 58 82 KIE1003: DIGITAL SYSTEM Decimal-to-binary conversion Repeated Division-by-2 A systematic method of converting whole numbers from decimal to binaryrepeate Method division-by-2 is process. the d The remainders generated by each division form the binary first bit) remainder –LSB (least significant number. last remainder –MSB (most significant Exampl bit) e To find the binary of 10, 2 1 12 22 6 2 3 2 1 Stop when the whole- number KIE1003: DIGITAL SYSTEM Converting decimal fractions to binary Sum-of- - - Weights 0.625 = 0.5 + 0.125 = 2 Example + 2 = 1 3 : 0.101 Repeated Multiplication The by 2 carry digits, or carries, generated by the multiplications produce the binary first carry –MSB, last carry – number. LSB Example Convert the decimal fraction 0.188 to binary by repeatedly multiplying the fractional results by 2. 0.188 x 2 = carry = 0 (MSB) 0.376 0.376x 2 carry = 0 carry = 0.752 0.752x = 1 carry = 1 2 = 1.504 carry = 0 (LSB) Continue to the desired 0.504x 2 = number 0.18810=.0011 1.008 0.008x 2 of decimal places or stop = 0.016 02 (5 significant digits) KIE1003: DIGITAL SYSTEM Binary arithmetic Addition Multiplication Subtraction How if the is result negative? KIE1003: DIGITAL SYSTEM Complements of binary numbers used in digital computers for simplifying the subtraction operation and logical manipulation 1’s complement To form the 1’s complement, change all 0’s to 1’s and all 1’s to 0’s. Example: the 1’s complement of 11001010 is 0011010 1 In digital circuits, the 1’s complement is formed by using inverters: KIE1003: DIGITAL SYSTEM Complements of binary numbers 2’s complement 2’s + 1complement = 1’s complement 2’s complement = (1’s complement) adding 1 to the LSB of the 1’s + 1 complement Recall that the 1’s complement of 00110101 (1’s 11001010 is complement) To form the 2’s complement, + 1 00110110 (2’s add 1: complement) An easier way to obtain 2’s complement: KIE1003: DIGITAL SYSTEM Signed binary numbers Use Most Significant Bit (MSB) to indicate the sign. 0 indicates positive number 1 indicates negative number Signed binary numbers can be represented in three 1 sign- forms:. magnitude 2 1’s Positivenumbers are stored in tru form. complement (with a 0 for the sign bit) e Negativenumbers are stored 3 2’s in compleme form(with a 1 for the sign. complement nt bit). Drawbacks of sign-magnitude& 1’s There are two representations for zero. complement: The positive integers and negative integers need to be processed KIE1003: DIGITAL SYSTEM Signed binary numbers (Example) Express the decimal number -39 as an 8-bit number in the sign-magnitude, 1’s complement, and 2’s complement forms. Solution: (a) Sign- magnitude +39 = 00100111 −39 = 10100111 (b) 1’s complement +39 = 00100111 −39 = 11011000 (c) 2’s complement +39 = 00100111 −39 = 11011001 KIE1003: DIGITAL SYSTEM Floating-point numbers Floating point notation is capable of representing very large or small numbers by using a form of scientific notation. A 32-bit single precision number is illustrated. Example: To express 1011010010001 in floating-point Assuming this is a positive number, the sign bit (S) format is 0. 1011010010001 = 21 Exponent (E) = 12 + 1271.011010010001 = 139 = 2 x exponents are stored 2 as 8-bit unsigned integers with a bias of 127 10001011 Mantissa (F) = S E F 01101001000100000000000 The complete floating-point 011010010001000000000 0 1000101 00 number is KIE1003: DIGITAL SYSTEM Arithmetic operations with signed numbers Addition Add the two signed numbers. Discard any final carries. The result is in signed form. Overflow: Note that if the number of bits required for the answer is exceeded, overflow occur. This will occurs only if both numbers have the same sign. The overflow will be indicated by an incorrect sign bit. KIE1003: DIGITAL SYSTEM Arithmetic operations with signed numbers Subtractio 2’s n complement the subtrahend and add the numbers. Discard any final result is in signed form. The carries. Repeat the examples done previously, but subtract: 2’s complement subtrahend and add KIE1003: DIGITAL SYSTEM Arithmetic operations with signed numbers (Example) Perform the operation (13 1 –12 ) in 2’s complement. Use 8-bit binary system. 0 0 Solution 131 0000110 2 : 0 1 + + −21 1111111102 0 2 = 11 1 00001011 0 Discard (> 8 bit) KIE1003: DIGITAL SYSTEM Octal numbers 8 digits (0, 1, 2, 3, 4, 5, 6, 7) weights are powers of 8, which increase from right to left Octal-to- 0) 237 8 = (2 x 38 ) + (3 2x 8 ) + (7 1 x 8 ) + (4 4 decimal x8 = 1024 + 192 + 56 +4 = 1276 KIE1003: DIGITAL SYSTEM Octal numbers Decimal-to- octal1 359 = 8 35 0 8 9 4 (?)8 84 5 0 Octal-to- uses binarya 3 bit groups -each octal digit is converted to its 3-bit Example (257)8 = (010 binary 2 : 101111) KIE1003: DIGITAL SYSTEM Hexadecimal numbers base of 16 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F) Example 2 1 0 :4AC= (4 x 16 ) + (10 x 16 ) + (12 )x=16 11961 0 simpler form to write a binary number – four bits per hex digit Example: 2 1 (110110100011) = 1101 10100011= 6 DA3 KIE1003: DIGITAL SYSTEM Hexadecimal numbers Decimal to hexadecimal conversion: 1 = 1 0 (?) 6 650 Remainde 1 65 r 6 10 4 A (LSD) 8 6 10 2 2 (MSD) 6 0 650 = 1 1 0 28A 6 KIE1003: DIGITAL SYSTEM Summar y 3 bits 4 bits grou grou p p Octa Binar Hexadecim l y al  base position weigh repeatedl  base position t y repeatedl weigh y t Decim al KIE1003: DIGITAL SYSTEM Binary coded decimal (BCD) not a number system -to express each of the decimal digits with a binary code Each decimal digit is represented by 4 bits Decimal to BCD conversion Decima 0 1 2 3 4 5 6 7 8 9 table l BCD 0000 0001 0010 0011 0100 0101 0 011 1000 1001 1 1 Note that 1010, 1011, 1100, 1101, 1110, and 1111 1 0 are invalid in BCD. Exampl 1 (387)1 = (0011 1000 0111) e BC. 0110100000111001 0 BC =D 1 2 6839 D 0. KIE1003: DIGITAL SYSTEM Gray code unweighted and is not an arithmetic code (there are no specific weights assigned to bitthe positions) exhibits only a single bit change from one code word to the next in sequence Gray code is used to avoid problems in systems where an error can occur if more than one bit changes at a time. Binary-to-Gray Code + + + + Binary 1 0 1 1 0 Conversion Gra 1 1 1 0 1 y Gray-to-Binary Code GraConversion 1 0 1 1 + + + + y 1 Binary 1 0 0 1 0 KIE1003: DIGITAL SYSTEM Application of gray code A shaft encoder is a typical application. Three IR emitter/detectors are used to encode the position of the shaft. The encoder on the left uses binary and can have three bits change together, creating a potential error. The encoder on the right uses gray code and only 1-bit changes, eliminating potential errors. KIE1003: DIGITAL SYSTEM American Standard Code for Information Interchange (ASCII) ASCII is a code for alphanumeric characters and control characters. In its original form, ASCII encoded 128 characters and symbols using 7-bitsbinary code to represent a character such as 'a' or '@' or an action of some sort. KIE1003: DIGITAL SYSTEM Parity bit an extra bit that is attached to a group of bits for bit error detection. The parity bit is made either 0 or 1 to make the total group of number always 1s in even a or always odd. Two Even Parity Odd Parity 1 even-parity P BCD P BCD. bit odd- methods: 0 000 1 000 2 parity bit 1 0 0 0. 1 000 0 000 0 1 1 1 1 001 0 001 0 0 1 0 0 001 1 001 1 1 0 1 1 010 0 010 0 0 1 0 010 010 KIE1003: DIGITAL SYSTEM Cyclic redundancy check an error detection method that can detect multiple errors in larger blocks of dat a At the sending end, a checksum is appended to a block of data. At the receiving end, the check sum is generated and compared to the sent checksum. If the check sums are the same, no error is detected

Use Quizgecko on...
Browser
Browser