Other Binary Codes (3A)
Total Page:16
File Type:pdf, Size:1020Kb
Other Binary Codes (3A) Young Won Lim 1/3/14 Copyright (c) 2011-2013 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Please send corrections (or suggestions) to [email protected]. This document was produced by using OpenOffice and Octave. Young Won Lim 1/3/14 Coding A code is a rule for converting a piece of information (for example, a letter, word, phrase, or gesture) into another form or representation (one sign into another sign), not necessarily of the same type. In communications and information processing, encoding is the process by which information from a source is converted into symbols to be communicated. Decoding is the reverse process, converting these code symbols back into information understandable by a receiver. Young Won Lim Other Binary Codes (4A) 3 1/3/14 Character Coding ASCII code BCD (Binary Coded Decimal) definitions for 128 characters: Number characters (0-9) 33 non-printing control characters (many now obsolete) 95 printable charactersi Young Won Lim Other Binary Codes (4A) 4 1/3/14 Representation of Numbers Fixed Point Number representation ● 2's complement +1234 ● 1's complement 0 -582978 coding ● sign-magnitude Floating Point Number representation +23.84380 ● IEEE 754 -1.388E+08 coding Young Won Lim Other Binary Codes (4A) 5 1/3/14 Representation of Signals Analog to Digital Converter Young Won Lim Other Binary Codes (4A) 6 1/3/14 Angular Position Sensors Ideal Problems in ordinary binary coding Young Won Lim Other Binary Codes (4A) 7 1/3/14 Gray Code Young Won Lim Other Binary Codes (4A) 8 1/3/14 Encoder and Decoder Event 0 Event 1 Event 2 Event 3 Event 0 Event 1 Event 2 Event 3 Encoding A3 F1 A2 A1 F0 A0 Decoding A7 A7 A6 A6 A5 F2 F2 A5 A4 F1 F1 A4 A3 Encoder F0 F0 Decoder A3 A2 A2 A1 A1 A0 A0 Young Won Lim Other Binary Codes (4A) 9 1/3/14 Priority Encoder Priority Encoder? Young Won Lim Other Binary Codes (4A) 10 1/3/14 Binary Code Decimal the manipulation of numerical data for display can be greatly simplified by treating each digit as a separate single sub-circuit. If the numeric quantity were stored and manipulated as pure binary, interfacing to such a display would require complex circuitry. Often, smaller code results when representing numbers internally in BCD format, since a conversion from or to binary representation can be expensive on limited microprocessors. BCD arithmetic is used in calculators : No rounding off error Young Won Lim Other Binary Codes (4A) 11 1/3/14 7 Segment Display Young Won Lim Other Binary Codes (4A) 12 1/3/14 Offset Binary 23 22 21 20 100 100 100 100 0 0 0 0 2 0 0 0 0 8 0 0 0 1 1 + 1 + 1 + = – = = = = x x x x x i i i + i + i d 0 0 0 1 – 7 1 1 + 1 d d d d a a a a a r r r 0 0 1 0 – 6 + 2 r + 2 r + 2 0 0 1 1 – 5 + 3 + 3 + 3 0 1 0 0 – 4 + 4 + 4 + 4 0 1 0 1 – 3 + 5 + 5 + 5 0 1 1 0 – 2 + 6 + 6 + 6 0 1 1 1 – 1 + 7 + 7 + 7 1 0 0 0 + 0 – 8 – 7 – 0 1 0 0 1 + 1 – 7 – 6 – 1 1 0 1 0 + 2 – 6 – 5 – 2 t t e y n n d r 1 0 1 1 + 3 e – 5 e – 4 u – 3 a m m t n e e i i 1 1 0 0 + 4 l – 4 l – 3 n – 4 b p p g m m a t 1 1 0 1 + 5 o – 3 o – 2 m – 5 e c c s n f 1 1 1 0 + 6 s – 2 s – 1 g – 6 f ' ' i 1 1 1 1 O + 7 2 – 1 1 – 0 s – 7 Binary Young Won Lim Other Binary Codes (4A) 13 1/3/14 Offset Binary and 2's Complement 23 22 21 20 100 23 22 21 20 0 0 0 0 – 8 1 0 0 0 0 0 0 1 – 7 1 0 0 1 0 0 1 0 – 6 1 0 1 0 Logical 0 0 1 1 arithmetic – 5 1 0 1 1 comparison comparison 0 1 0 0 – 4 1 1 0 0 0 1 0 1 – 3 1 1 0 1 0 1 1 0 – 2 1 1 1 0 0 1 1 1 – 1 1 1 1 1 continuous JUMP 1 0 0 0 + 0 0 0 0 0 1 0 0 1 + 1 0 0 0 1 1 0 1 0 + 2 0 0 1 0 t y n r 1 0 1 1 + 3 e 0 0 1 1 a m n e i 1 1 0 0 + 4 l 0 1 0 0 b p m t 1 1 0 1 + 5 o 0 1 0 1 e c s f 1 1 1 0 + 6 s 0 1 1 0 f ' 1 1 1 1 O + 7 2 0 1 1 1 Binary Binary Young Won Lim Other Binary Codes (4A) 14 1/3/14 Offset Binary (Excess K Code) 100 23 22 21 20 23 22 21 20 0 8 2 0 0 0 0 2 1 0 0 0 1 = – = = x x x i i i d – 7 0 0 0 1 d 1 0 0 1 d a a a r r r – 6 0 0 1 0 1 0 1 0 – 5 0 0 1 1 1 0 1 1 – 4 0 1 0 0 1 1 0 0 – 3 0 1 0 1 1 1 0 1 – 2 0 1 1 0 + 1 0 0 0 1 1 1 0 – 1 0 1 1 1 1 1 1 1 JUMP + 0 1 0 0 0 0 0 0 0 n−1 + 1 1 0 0 1 K = 2 0 0 0 1 + 2 1 0 1 0 0 0 1 0 t y n r + 3 1 0 1 1 e 0 0 1 1 a m n e i + 4 1 1 0 0 l 0 1 0 0 b p m t + 5 1 1 0 1 o 0 1 0 1 e c s f + 6 1 1 1 0 s 0 1 1 0 f ' + 7 O 1 1 1 1 2 0 1 1 1 Binary Binary Young Won Lim Other Binary Codes (4A) 15 1/3/14 Offset Binary and ADC / DAC Bipolar Signal Unipolar Signal + DC Offset 2's complement Offset binary Young Won Lim Other Binary Codes (4A) 16 1/3/14 Offset Binary and Floating Pointer Numbers 7 Excess-127 Code K = 2 − 1 10 Excess-1023 Code K = 2 − 1 Young Won Lim Other Binary Codes (4A) 17 1/3/14 Excess-3 and BCD Codes 100 23 22 21 20 0 2 0 0 0 0 = x i 1 d 0 0 0 1 a 0 2 r 0 0 1 0 10 3 0 0 1 1 0 0 1 = 4 0 1 0 0 x i 1 d a 2 5 0 1 0 1 r 6 0 1 1 0 3 e d o 7 0 1 1 1 4 C D 8 1 0 0 0 e 5 C d B o 9 1 0 0 1 C 6 3 1 0 1 0 - 7 s s 1 0 1 1 e 8 c x 1 1 0 0 E 9 1 1 0 1 1 1 1 0 1 1 1 1 Binary Young Won Lim Other Binary Codes (4A) 18 1/3/14 References [1] http://en.wikipedia.org/ [2] http://planetmath.org/ [3] M.L. Boas, “Mathematical Methods in the Physical Sciences” Young Won Lim 1/3/14.