digital design, number system and data...
TRANSCRIPT
![Page 1: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/1.jpg)
Digital Design,Number System
and Data Representation
Jin-Tai Yan Introduction to Digital Logic Page 1
![Page 2: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/2.jpg)
Digital DesignDigital& Analog
Number System & OperationsBase 2, 10 and 16
Data RepresentationCharacter, Integer, Floating‐Point
Jin-Tai Yan Introduction to Digital Logic Page 2
OutlinesOutlines
![Page 3: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/3.jpg)
Digital Devices
Jin-Tai Yan Introduction to Digital Logic Page 3
2000: Pentium® 4 ProcessorUsers of Pentium® 4 processor-based PCs can create professional-quality movies; deliver TV-like video via the Internet; communicate with real-time video and voice; render 3D graphics in real time; quickly encode music for MP3 players; and simultaneously run several multimedia applications while connected to the Internet. The processor debuted with 42 million transistors and circuit lines of 0.18 microns. Intel's first microprocessor, the 4004, ran at 108 kilohertz (108,000 hertz), compared to the Pentium® 4 processor's initial speed of 1.5 gigahertz (1.5 billion hertz). If automobile speed had increased similarly over the same period, you could now drive from San Francisco to New York in about 13 seconds.
Integrated Circuits that operate on Digital Data are in 95% of every electrical powered device
![Page 4: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/4.jpg)
Analog & Digital
Jin-Tai Yan Introduction to Digital Logic Page 4
103.5
Analog Voltage meter
Digital Voltage meter
About 100
![Page 5: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/5.jpg)
Continuous & Discrete
Jin-Tai Yan Introduction to Digital Logic Page 5
![Page 6: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/6.jpg)
Ambiguity & Interpretation
Jin-Tai Yan Introduction to Digital Logic Page 6
Analog Clock
1:56 pmDigital Clock
About 2:00
1:50
1:56
1:56
![Page 7: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/7.jpg)
Advantage of Digital Data
• Digital data can have additional data added to it to allow for detection and correction of errors– Scratch a CDROM ‐ will still play fine– Scratch, stretch an analog tape ‐ throw it away
• Digital data can be transmitted over a medium that introduces errors that are corrected at receiving end– Satellite transmission of Direct TV ‐ each ‘screen’ image is digitally encoded; errors corrected when it reaches your digital Set Top receiver, shows up as a ‘Perfect’ Picture.
Jin-Tai Yan Introduction to Digital Logic Page 7
![Page 8: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/8.jpg)
Binary Representation
• The basis of all digital data is binary representation.
• Binary ‐ means ‘two’– 1, 0
– True, False
– Hot, Cold
– On, Off
• More than just values are handled for real worlds– 1, 0, 56
– True, False, Maybe
– Hot, Cold, LikeWarm, Cool
– On, Off, Leaky
Jin-Tai Yan Introduction to Digital Logic Page 8
![Page 9: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/9.jpg)
Binary Codes
Jin-Tai Yan Introduction to Digital Logic Page 9
One binary digit (one bit) can take on values 0, 1.
(0 = hot, 1 = cold), (1 = True, 0 = False), (1 = on, 0 = off).Two binary digits (two bits) can take on values of 00, 01, 10, 11.
(00 = hot, 01 = warm, 10 = cool, 11 = cold).
Three binary digits (three bits) can take on values of 000, 001, 010, 011, 100, 101, 110, 111.
000 = Black, 001 = Red, 010 = Pink, 011 = Yellow,
100 = Brown, 101 = Blue, 110 = Green , 111 = White.
N bits (or N binary digits) can represent 2N different values.
![Page 10: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/10.jpg)
Base 10 and Base 2
• A digit in base 10 ranges from 0 to 9.
• A digit in base 2 ranges from 0 to 1 (binary number system). A digit in base 2 is also called a ‘bit’.
• ‘%’ will be used for base 2 (%10101111)
Jin-Tai Yan Introduction to Digital Logic Page 10
![Page 11: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/11.jpg)
Base 2, 8 and 16
• A digit in Base 16 can range from 0 to 16‐1 (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F).
• Use letters A‐F to represent values 10 to 15.
• Base 16 is also called Hexadecimal or just ‘Hex’.
• ‘$’ will be used for base 16 ( $A2F)
Jin-Tai Yan Introduction to Digital Logic Page 11
81 = 8 = 23
161 = 16 = 24
![Page 12: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/12.jpg)
Number Positional Notation(Polynomial Notation)
Jin-Tai Yan Introduction to Digital Logic Page 12
Number value is determined by multiplying each digit by a weight and then summing. The weight of each digit is a POWER of the BASE and is determined by position.
953.78 = 9 x 102 + 5 x 101 + 3 x 100 + 7 x 10-1 + 8 x 10-2
= 900 + 50 + 3 + 0.7 + 0.08
= 953.78
![Page 13: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/13.jpg)
Powers of 2
Jin-Tai Yan Introduction to Digital Logic Page 13
2-3 = 0.1252-2 = 0.252-1 = 0.520 = 121 = 222 = 423 = 824 = 16
160 = 1 = 20
161 = 16 = 24
162 = 256 = 28
163 = 4096 = 212
210 = 1024 = 1 K220 = 1048576 = 1 M (1 Megabits) = 1024 K
230 = 1073741824 = 1 G (1 Gigabits)
25 = 3226 = 6427 = 12828 = 25629 = 512210 = 1024211 = 2048212 = 4096
![Page 14: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/14.jpg)
Any Base to Base 10(Series Substitution Conversion)
Jin-Tai Yan Introduction to Digital Logic Page 14
Base 2 to Base 10
Base 16 to Base 10
% 1011.11 = 1x23 + 0x22 + 1x21 + 1x20 + 1x2-1 + 1x2-2
= 8 + 0 + 2 + 1 + 0.5 + 0.25 = 11.75
$ A2F = 10x162 + 2x161 + 15x160
= 10 x 256 + 2 x 16 + 15 x 1 = 2560 + 32 + 15
= 2607
![Page 15: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/15.jpg)
Base 10 to Base 2
Jin-Tai Yan Introduction to Digital Logic Page 15
Integer Conversion:Radix Divide Method
NI = bn-1xBn-1 + … + b1xB1 + b0xB0
NI/B = ( bn-1xBn-1 + … + b1xB1 + b0xB0 )/B= bn-1xBn-2 + … + b1xB0 + b0
Fraction Conversion:Radix Multiply Method
Number, N = Integer, NI + Fraction, NF
NF = b-1xB-1 + b-2xB-2 + … + b-mxB-m
NF x B = ( b-1xB-1 + b-2xB-2 + … + b-mxB-m )xB= b-1 + b-2xB-1 + … + b-mxB-(m-1)
![Page 16: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/16.jpg)
Base 10 to Base 2
Jin-Tai Yan Introduction to Digital Logic Page 16
Integer Conversion:53/2 = 26, remainder = 126/2 = 13, remainder = 013/2 = 6, remainder = 16 /2 = 3, remainder = 03/2 = 1, remainder = 11/2 = 0, remainder = 1
0.625x2 = 1.25, carry = 10.25x2 = 0.5 , carry = 00.5x2 = 1.0, carry = 1
53.625 = % 110101.101= 1x25 + 1x24 + 0x23 + 1x22 + 0x21 + 1x20 + 1x2-1 + 0x2-2 + 1x2-3
= 32 + 16 + 0 + 4 + 0 + 1 + 0.5 + 0 + 0.125
Fraction Conversion:
Number = Integer + Fraction
53.625 = 53 + 0.625
![Page 17: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/17.jpg)
Base 16 to Base 2
Jin-Tai Yan Introduction to Digital Logic Page 17
Each Hex digit represents 4 bits. To convert a Hex number to Binary, simply convert each Hex digit to four binary bits.
Single Hex digit to four binary bits:$ 0 = % 0000$ 1 = % 0001$2 = % 0010$3 = % 0011$4 = % 0100$5 = % 0101$6 = % 0110$7 = % 0111
$ 8 = % 1000$ 9 = % 1001$ A = % 1010$ B = % 1011$ C = % 1100$ D = % 1101$ E = % 1110$ F = % 1111
161 = 16 = 24
![Page 18: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/18.jpg)
Conversion of Base 16 and 2
Jin-Tai Yan Introduction to Digital Logic Page 18
$ A2F.B2 = % 1010 0010 1111.1011 0010
$ 345.C79 = % 0011 0100 0101.1100 0111 1001
= % 11 0100 0101.1100 0111 1001
% 1010001.0011011 = % 0101 0001. 0011 0110
= $ 51.36
Padded with a zero
Base 16 to Base 2
Base 2 to Base 16
![Page 19: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/19.jpg)
Binary Addition & Subtraction
Jin-Tai Yan Introduction to Digital Logic Page 19
Binary Addition 0 + 0 = 0, carry = 0
1 + 0 = 1, carry = 0
0 + 1 = 1, carry = 0
1 + 1 = 0, carry = 1
Binary Subtraction 0 - 0 = 0, borrow = 0
1 - 0 = 1, borrow = 0
0 - 1 = 1, borrow = 1
1 - 1 = 0, borrow = 0
% 101011
+ % 000001---------------
101100
% 100
- % 001-------
011
![Page 20: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/20.jpg)
Data Representation
Jin-Tai Yan Introduction to Digital Logic Page 20
Character & String– ASCII Code, Unicode
Integer Number– Unsigned
• Binary Codes, BCD Codes, Gray Code – Signed
• Signed-Magnitude,• 1’s Complement, 2’s Complement
Floating Point Number– IEEE 754 Standard Code
![Page 21: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/21.jpg)
ASCII Codes
Jin-Tai Yan Introduction to Digital Logic Page 21
ASCII code (American Standard Code for Information Interchange) is a 7-bit code for Character data.
7 bits can only represent 27 different values (128). This enough to represent the Latin alphabet (A-Z, a-z, 0-9, punctuation marks, some symbols like $)
8 bits are actually used with the 8th bit being zero or used for error detection (parity checking).
1 Byte = 8 bits ‘A’ = % 01000001 = $41‘&’ = % 00100110 = $26
![Page 22: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/22.jpg)
ASCII Codes
Jin-Tai Yan Introduction to Digital Logic Page 22
![Page 23: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/23.jpg)
Unicode
Jin-Tai Yan Introduction to Digital Logic Page 23
UNICODE is a 16-bit code for representing alphanumeric data. With 16 bits, can represent 216 or 65536 different symbols.
16 bits = 2 Bytes per character.
$0041-005A A-Z$0061-4007A a-z
Some other alphabet/symbol ranges
$3400-3d2d Korean Hangul Symbols$3040-318F Hiranga, Katakana, Bopomofo, Hangul$4E00-9FFF Han (Chinese, Japenese, Korean)
UNICODE used by Web browsers, Java.
![Page 24: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/24.jpg)
Binary Code
Jin-Tai Yan Introduction to Digital Logic Page 24
N binary digits (N bits) can represent unsigned integers from 0 to 2N-1.
4 bits = 0 to 158 bits = 0 to 25516 bits = 0 to 65535
Binary Code0 = % 00001 = % 00012 = % 00103 = % 00114 = % 01005 = % 01016 = % 01107 = % 0111
8 = % 10009 = % 100110 = % 101011 = % 101112 = % 110013 = % 110114 = % 111015 = % 1111
![Page 25: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/25.jpg)
BCD Codes
Jin-Tai Yan Introduction to Digital Logic Page 25
BCD Code0 = % 00001 = % 00012 = % 00103 = % 00114 = % 01005 = % 01016 = % 01107 = % 01118 = % 10009 = % 1001
Each decimal digit simply represented by 4 bits.
Advantage: Easy to convertDisadvantage: Takes more bits to store a number
255 = % 1111 1111 = $ FF (binary code)255 = % 0010 0101 0101 = $ 255 (BCD code)
![Page 26: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/26.jpg)
Gray Code
Jin-Tai Yan Introduction to Digital Logic Page 26
Gray Code0 = % 00001 = % 00012 = % 00113 = % 00104 = % 01105 = % 01116 = % 01017 = % 01008 = % 1100
9 = % 1101
A Gray code changes by only 1 bit for adjacent values. This can help reduce circuit complexity and also reduce signal noise.
![Page 27: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/27.jpg)
Unsigned Overflow
Jin-Tai Yan Introduction to Digital Logic Page 27
Overflow occurs when two unsigned numbers added or subtracted, and the correct result is a number that is outside of the range of allowable numbers for that precision.
8 bits -- unsigned integers 0 to 28 -1 or 0 to 255.
16 bits -- unsigned integers 0 to 216-1 or 0 to 65535
![Page 28: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/28.jpg)
Signed Magnitude Number
Jin-Tai Yan Introduction to Digital Logic Page 28
The Most Significant Bit(MSB) is used to represent the sign. ‘1’ is used for a ‘-’ (negative sign), a ‘0’ for a ‘+’ (positive sign).
The format of a SM number in 8 bits is:
% smmmmmmm
where ‘s’ is the sign bit and the other 7 bits represent the magnitude.
-5 = % 1 0000101 = $ 85+5 = % 0 0000101 = $ 05+127 = % 0 1111111 = $ 7F-127 = % 1 1111111 = $ FF+ 0 = % 0 0000000 = $ 00- 0 = % 1 0000000 = % 80
![Page 29: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/29.jpg)
SM is Correct ?
Jin-Tai Yan Introduction to Digital Logic Page 29
8-bit number can represent the signed integers -127 to +127.
N-bit number can represent the signed integers
-(2(N-1) – 1) to + 2(N-1) - 1
Two problems for SM representation:
(1) Two ways of representing 0 (-0, and +0) .
(2) Addition of K + (-K) does not give Zero
-5 + 5 = $ 85 + $ 05 = $8A = -10
![Page 30: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/30.jpg)
Complementary Number
Jin-Tai Yan Introduction to Digital Logic Page 30
Radix Complement(r’s Complement):
The radix complement [N]r of a number (N)r is defined as
[N]r = rn - (N)r ,
where n is the number of digits in (N)r
(r-1)’s Complement:
The (r-1)’s complement [N]r of a number (N)r is defined as
[N]r = rn – 1 - (N)r ,
where n is the number of digits in (N)r
![Page 31: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/31.jpg)
1’s Complement Number
Jin-Tai Yan Introduction to Digital Logic Page 31
To encode a negative number, get the binary representation of its magnitude, then COMPLEMENT each bit.
Complementing each bit mean that 1s are replaced with 0s, 0s are replaced with 1s.
+5 = % 00000101 = $ 05-5 = % 11111010 = $ FA+127 = % 01111111 = $ 7F-127 = % 10000000 = $ 80+ 0 = % 00000000 = $ 00- 0 = % 11111111 = $ FF
![Page 32: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/32.jpg)
1’s Complement is Correct ?
Jin-Tai Yan Introduction to Digital Logic Page 32
8-bit number can represent the signed integers -127 to +127.
N-bit number can represent the signed integers
-(2(N-1) – 1) to + 2(N-1) - 1
One Problem for 1’s complement representation
(1) two ways of representing 0 (-0, and +0),
K + 0 = K only works if we use +0, does not work if we use -0.
5 + (+0) = $05 + $00 = $05 = 5 (ok)
5 + (-0) = $05 + $FF = $04 = 4 !!! (wrong)
![Page 33: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/33.jpg)
2’s Complement Number
Jin-Tai Yan Introduction to Digital Logic Page 33
To encode a negative number, get the binary representation of its magnitude, COMPLEMENT each bit, then ADD 1.
(get Ones complement, then add 1).
+5 = % 00000101 = $ 05-5 = % 11111011 = $ FB+127 = % 01111111 = $ 7F-127 = % 10000001 = $ 81-128 = % 10000000 = $80
+ 0 = % 00000000 = $ 00- 0 = % 00000000 = $ 00
![Page 34: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/34.jpg)
2’s Complement is Correct ?
Jin-Tai Yan Introduction to Digital Logic Page 34
8-bit number can represent the signed integers -128 to +127.
N-bit number can represent the signed integers
-2(N-1) to + 2(N-1) - 1
There is only one zero, and K + (-K) = 0.
-5 + 5 = $ FB + $ 05 = $00 = 0
2’s complement is a correct representation of signed numbers.
![Page 35: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/35.jpg)
Representation & Meaning
Jin-Tai Yan Introduction to Digital Logic Page 35
$FE as an 8 bit unsigned integer = 254$FE as an 8 bit signed magnitude integer = -126$FE as an 8 bit 1’s complement integer = -1$FE as an 8 bit 2’s complement integer = -2
$7F as an 8 bit unsigned integer = 127$7F as an 8 bit signed magnitude integer = +127$7F as an 8 bit 1’s complement integer = +127$7F as an 8 bit 2’s complement integer = +127
![Page 36: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/36.jpg)
Integer & Representation
Jin-Tai Yan Introduction to Digital Logic Page 36
+34 as an 8 bit SM number is % 00100010 +34 as an 8 bit 1’s complement number is % 00100010 +34 as an 8 bit 2’s complement number is % 00100010
-20 as an 8 bit SM number is % 10010100 -20 as an 8 bit 1’s complement number is % 11101011 -20 as an 8 bit 2’s complement number is % 11101100
![Page 37: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/37.jpg)
Integer Representation
Jin-Tai Yan Introduction to Digital Logic Page 37
Binary Number Sign-Magnitude 1’s Complement 2’s Complement% 0000 +0 +0 +0 +0% 0001 +1 +1 +1 +1% 0010 +2 +2 +2 +2% 0011 +3 +3 +3 +3% 0100 +4 +4 +4 +4% 0101 +5 +5 +5 +5% 0110 +6 +6 +6 +6% 0111 +7 +7 +7 +7
% 1000 +8 -0 -7 -8% 1001 +9 -1 -6 -7% 1010 +10 -2 -5 -6% 1011 +11 -3 -4 -5% 1100 +12 -4 -3 -4% 1101 +13 -5 -2 -3% 1110 +14 -6 -1 -2% 1111 +15 -7 -0 -1
![Page 38: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/38.jpg)
Signed Overflow
Jin-Tai Yan Introduction to Digital Logic Page 38
Signed overflow occurs in
Add two POSITIVE numbers and get a NEGATIVE resultAdd two NEGATIVE numbers and get a POSITIVE result
$ FF = -1
+ $ 80 = -128--------
$ 7F = +127 (incorrect!!)
![Page 39: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/39.jpg)
Excess(Biased) Representation
Jin-Tai Yan Introduction to Digital Logic Page 39
2’s Complement Excess-8+7 0111 1111+6 0110 1110+5 0101 1101+4 0100 1100+3 0011 1011+2 0010 1010+1 0001 1001+0 0000 1000
-1 1111 0111-2 1110 0110-3 1101 0101-4 1100 0100-5 1011 0011-6 1010 0010-7 1001 0001-8 1000 0000
![Page 40: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/40.jpg)
Single Precision Floating Point
Jin-Tai Yan Introduction to Digital Logic Page 40
Numbers are represented by X = (-1)S x 2E-127 x 1.M
S = Sign bit
E = Biased integer, 0 ≤ E ≤ 255
M = Normalized fraction with hidden 1
Sign
32 bits
23 bits of mantissaexcess-127exponent
8-bit
S M E
+0 denotes–1 denotes
![Page 41: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/41.jpg)
Underflow & Overflow
Jin-Tai Yan Introduction to Digital Logic Page 41
Positive Minimal Number : s = 0, E = 0, M = 0,Npmin = (-1)0 x 2-127 x 1.0 = 2-127
Positive Maximal Number : s = 0, E = 255, M = 11...11, Npmax = (-1)0 x 2128 x (2 - 2-23) = (1 - 2-24) x2129
Negative Minimal Number : s = 1, E = 0, M = 0,Npmin = (-1)1 x 2-127 x 1.0 = -2-127
Negative Maximal Number : s = 1, E = 255, M = 11...11, Npmax = (-1)1 x 2128 x (2 - 2-23) = -(1 - 2-24) x2129
Underflow = -2-127 ~ 2-127
Overflow = -∞ ~ -(1 - 2-24) x2129 and +(1 - 2-24) x2129 ~ +∞
![Page 42: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/42.jpg)
Double Precision Floating Point
Jin-Tai Yan Introduction to Digital Logic Page 42
52 bits of mantissa11-bit excess-1023exponent
64 bits
Sign
S M E
Numbers are represented by X = (-1)S x 2E-1023 x 1.M
S = Sign bit
E = Biased integer, 0 ≤ E ≤ 2047
M = Normalized fraction with hidden 1
![Page 43: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/43.jpg)
Underflow & Overflow
Jin-Tai Yan Introduction to Digital Logic Page 43
Positive Minimal Number : s = 0, E = 0, M = 0,Npmin = (-1)0 x 2-1023 x 1.0 = 2-1023
Positive Maximal Number : s = 0, E = 255, M = 11...11, Npmax = (-1)0 x 21024 x (2 - 2-52) = (1 - 2-53) x21025
Negative Minimal Number : s = 1, E = 0, M = 0,Npmin = (-1)1 x 2-1023 x 1.0 = -2-1023
Negative Maximal Number : s = 1, E = 255, M = 11...11, Npmax = (-1)1 x 21024 x (2 - 2-52) = -(1 - 2-53) x21025
Underflow = -2-1023 ~ 2-1023
Overflow = -∞ ~ -(1 - 2-53) x21025 and +(1 - 2-53) x21025 ~ +∞
![Page 44: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/44.jpg)
Data Representation in C Language
Jin-Tai Yan Introduction to Digital Logic Page 44
char ---> 8 bit ASCII code
unsigned int ----> 16 bit unsigned integer
(signed) int ---> 16 bit 2’s complement integer
unsigned long int ---> 32 bit unsigned integer
(signed) long int ---> 32 bit 2’s complement integer
float ---> 32 bit single precision floating point number
double ---> 64 bit double precision floating point number
![Page 45: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/45.jpg)
Error Detection Codes
Jin-Tai Yan Introduction to Digital Logic Page 45
Simple Parity Code
Even-Parity Code
Odd-Parity Code
2-out-of-5 Code
0 = % 000111 = % 001012 = % 010013 = % 100014 = % 001105 = % 010106 = % 100107 = % 011008 = % 101009 = % 11000
Parity bit
Information bits
![Page 46: Digital Design, Number System and Data Representation140.126.122.189/upload/1061/B02205B20176685291.pdf · Binary Representation • The basis of all digital data is binary representation](https://reader033.vdocuments.net/reader033/viewer/2022051921/600ef03eae53287d8a19ab5b/html5/thumbnails/46.jpg)
Homework
• 1.1, 1.3, 1.4, 1.5, 1.10, 1.12, 1.14, 1.16, 1.18
Jin-Tai Yan Introduction to Digital Logic Page 46