Lecture2 Data Rep
Lecture2 Data Rep
E1.2 Digital Electronics 1 2.1 16 October 2008 E1.2 Digital Electronics 1 2.2 16 October 2008
E1.2 Digital Electronics 1 2.3 16 October 2008 E1.2 Digital Electronics 1 2.4 16 October 2008
• We can represent information using voltage levels Number systems
• The simplest information is TRUE/FALSE
– This can be represented by two voltage levels:
Hexadecimal
• 5 Volts = TRUE
(base 16)
• 0 Volts = FALSE
• A unit of information that has only two possible values is
also called a BIT (short for Binary Digit)
Decimal Binary
• Why do we use binary data in electronics? (base 10) (base 2)
– Simple to implement in hardware: we only need
switches
– Good tolerance to noise Octal
(base 8)
E1.2 Digital Electronics 1 2.5 16 October 2008 E1.2 Digital Electronics 1 2.6 16 October 2008
d th
s
an
red
an
an
re
ths
us
us
nd
-
nd
es
us
ten
s
tho
ten
ten
hu
hu
on
tho
E1.2 Digital Electronics 1 2.9 16 October 2008 E1.2 Digital Electronics 1 2.10 16 October 2008
E1.2 Digital Electronics 1 2.11 16 October 2008 E1.2 Digital Electronics 1 2.12 16 October 2008
Conversion: binary to decimal Binary addition
1 1
A 1 2 5 4
• Determine the power of 2 for the position of each 1, and • Firstly, recall decimal addition:
+B 7 8 2
then sum Sum 2 0 3 6
E1.2 Digital Electronics 1 2.13 16 October 2008 E1.2 Digital Electronics 1 2.14 16 October 2008
Hexadecimal numbers
Binary addition
• Hexadeci = sixteen
• Note that to calculate each bit sn of the sum, we need to • Base 16 representation
consider the values of 3 input bits:
• Easy to convert to and
– The corresponding bits of A and B, (an and bn) from binary numbers
– The carry-out from the previous addition • More compact to write,
easier for us to read than
binary
• Each bit or column of the binary addition generates two
outputs
– sum sn and carry-out
E1.2 Digital Electronics 1 2.15 16 October 2008 E1.2 Digital Electronics 1 2.16 16 October 2008
Hexadecimal number conversions Binary Coded Decimal (BCD)
• Binary-to-hexadecimal
• Use 4-bit binary to represent one decimal digit
1. Separate the binary number into 4-bit groups
• Easy to convert between decimal ↔ binary
2. Replace each group with the hexadecimal equivalent
• Wastes bits (4 bits can represent 16 values, but only 10
• Hexadecimal-to-decimal values are used)
1. Re-write each hexadecimal digit as the 4-bit binary equivalent • Used extensively in financial calculations
2. Convert the binary number to decimal
• Decimal-to-hexadecimal
– Repeated division by 16
E1.2 Digital Electronics 1 2.17 16 October 2008 E1.2 Digital Electronics 1 2.18 16 October 2008
E1.2 Digital Electronics 1 2.19 16 October 2008 E1.2 Digital Electronics 1 2.20 16 October 2008
Gray Codes • Binary code results in glitches
• Gray code avoids glitches
E1.2 Digital Electronics 1 2.21 16 October 2008 E1.2 Digital Electronics 1 2.22 16 October 2008
ASCII code
• Codes representing letters
of the alphabet,
punctuation marks and
other special characters
are called
alphanumeric codes
• The most widely used
alphanumeric code is the
American Standard Code
for Information
Interchange, or ASCII
• ASCII is pronounced
“askee”
• It is a 7-bit code
E1.2 Digital Electronics 1 2.23 16 October 2008