Escolar Documentos
Profissional Documentos
Cultura Documentos
Outline
Binary Coded Decimal (BCD)
Gray Code
Binary-to-Gray Conversion
Gray-to-Binary Conversion
Outline
Binary Coded Decimal (BCD)
Gray Code
Binary-to-Gray Conversion
Gray-to-Binary Conversion
0000
5
0101
0001
6
0110
0010
7
0111
0011
8
1000
0100
9
1001
0
0000
5
0101
1
0001
6
0110
2
0010
7
0111
3
0011
8
1000
Examples:
(234)10 = (0010 0011 0100)BCD
(7093)10 = (0111 0000 1001 0011)BCD
(1000 0110)BCD = (86)10
(1001 0100 0111 0010)BCD = (9472)10
Notes: BCD is not equivalent to binary.
Example: (234)10 = (11101010)2
4
0100
9
1001
Outline
Binary Coded Decimal (BCD)
Gray Code
Binary-to-Gray Conversion
Gray-to-Binary Conversion
Gray Code
Unweighted (not an arithmetic code).
Only a single bit change from one code number to the next.
Good for error detection.
Decimal
0
1
2
3
4
5
6
7
Binary
0000
0001
0010
0011
0100
0101
0110
0111
Gray Code
0000
0001
0011
0010
0110
0111
0101
0100
Decimal
8
9
10
11
12
13
14
15
Binary
1000
1001
1010
1011
1100
1101
1110
1111
Gray code
1100
1101
1111
1110
1010
1011
1001
1000
Gray Code
0000
0001
0011
0001
0010
0000
0010
0110
0111
0011
0101
0001
0100
0000
1100
0100
0101
1101
0111
1111
0110
1110
0010
1010
0011
1011
0001
1001
0000
1000
0
0
Gray Code
0
0
1
1
1
sensors
1
1
1
1
0
0
0
0
0
0
1
1
0
0
0
0
1
1
1
1
mis-aligned
sensors
mis-aligned
sensors
Binary-to-Gray Code
Conversion
Retain most significant bit.
From left to right, add each adjacent pair of binary code bits to
Binary
1
1
Gray
1
1
0
1
1
1
Binary
Gray
(10110)2 = (11101)Gray
Binary
Gray
1
1
0
1
1
1
1
0
0
1
Binary
Gray
Binary
Gray
Gray-to-Binary Conversion
Retain most significant bit.
From left to right, add each binary code bit generated to the
Gray
1
+
Binary
1
1
+
Gray
Gray
(11011)Gray = (10010)2
0
+
Binary
1
+
Binary
Gray
Binary
Gray
Binary
Outline
Binary Coded Decimal (BCD)
Gray Code
Binary-to-Gray Conversion
Gray-to-Binary Conversion
BCD
8421
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
Excess-3
84-2-1
2*421
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
0000
0111
0110
0101
0100
1011
1010
1001
1000
1111
0000
0001
0010
0011
0100
1011
1100
1101
1110
1111
Biquinary
5043210
0100001
0100010
0100100
0101000
0110000
1000001
1000010
1000100
1001000
1010000
Outline
Binary Coded Decimal (BCD)
Gray Code
Binary-to-Gray Conversion
Gray-to-Binary Conversion
Self-Complementing Codes
Examples: excess-3, 84-2-1, 2*421 codes.
The codes that represent the pair of complementary digits are
complementary of each other.
Excess-3 code
0:
1:
2:
3:
4:
5:
6:
7:
8:
9:
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
Outline
Binary Coded Decimal (BCD)
Gray Code
Binary-to-Gray Conversion
Gray-to-Binary Conversion
Alphanumeric Codes
Apart from numbers, computers also handle textual data.
Character set frequently used includes:
alphabets:
digits:
special symbols:
non-printable:
A .. Z, and a .. z
0 .. 9
$, ., ,, @, *,
SOH, NULL, BELL,
Alphanumeric Codes
Two widely used standards:
ASCII (American Standard Code for Information Interchange)
EBCDIC (Extended BCD Interchange Code)
Character
0
1
...
9
:
A
B
...
Z
[
\
ASCII Code
0110000
0110001
...
0111001
0111010
1000001
1000010
...
1011010
1011011
1011100
Alphanumeric Codes
ASCII table:
LSBs
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
000
NUL
SOH
STX
ETX
EOT
ENQ
ACK
BEL
BS
HT
LF
VT
FF
CR
O
SI
001
DLE
DC1
DC2
DC3
DC4
NAK
SYN
ETB
CAN
EM
SUB
ESC
FS
GS
RS
US
010
SP
!
#
$
%
&
(
)
*
+
,
.
/
MSBs
011 100
0
@
1
A
2
B
3
C
4
D
5
E
6
F
7
G
8
H
9
I
:
J
;
K
<
L
=
M
>
N
?
O
101
P
Q
R
S
T
U
V
W
X
Y
Z
[
\
]
^
_
110
`
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
111
p
q
r
s
t
u
v
w
x
y
z
{
|
}
~
DEL
Outline
Binary Coded Decimal (BCD)
Gray Code
Binary-to-Gray Conversion
Gray-to-Binary Conversion
1s even.
Odd parity: additional bit supplied to make total number of 1s
odd.
Character
0
1
...
9
:
A
B
...
Z
[
\
ASCII Code
0110000 1
0110001 0
...
0111001 1
0111010 1
1000001 1
1000010 1
...
1011010 1
1011011 0
1011100 1
Parity bits
0110 1
0001 0
1011 0
1111 1
1001 1
0101 0
Column-wise parity
Row-wise parity