1
Chapter outline
Analog versus Digital
Introduction to number systems
Decimal, binary, octal & hexadecimal number systems
Conversion between bases
Number representation in binary(Signed number representation)
Sign-bit magnitude
1s complement
2s complement
Radix complement & Diminished Radix complement Arithmetic
Codes
2
Analog versus Digital
Analog systems process time-varying signals that can take on any
value across a continuous range of voltages (in electrical or
electronics systems).
For example, the reading of a moving coil or moving iron voltmeter
and ammeter, dynamometer wattmeter etc., are all analog
quantities.
3
Analog versus Digital
Digital systems process time-varying signals that can take on only
one of two discrete values of voltages (in electrical/electronics
systems).
Discrete values are called 1 and 0 (ON and OFF, HIGH and LOW,
TRUE and FALSE, etc.)
Analog electronics deals with non-discrete values
Digital electronics deals with discrete values
4
Analog versus Digital
The term digital is derived from digits. Any device or system which
works on digits is a digital device or system.
A digital voltmeter indicates the value of voltage in the form of
digits, e.g., 230.25.
Reading an analog instrument introduces human error and also
requires more time.
A digital reading is more accurate, eliminates human error and can
be read quickly.
The initial signal waveform is always analog. To use digital
transmission, the signal waveform is sampled and the digital
representation transmitted.
The process of converting analog signal to digital form is also known
as digitizing. For multiple channels of transmission, Multiplexing is
used. 5
Analog versus Digital
A DSP (digital signal processing) chip is the core of digital
system used in cellular phones, modems, disk drives, digital
automotive systems etc.
It was invented only about 15 ago but its applications have
grown tremendously.
7
Introduction to number system
8
Introduction to number system
Positional Notation
9
Introduction to number system
R is the radix or base of the number system
Must be a positive number
R digits in the number system: [0 .. R-1]
Important number systems for digital systems:
Base 2 (binary): [0, 1]
Base 8 (octal): [0 ... 7]
Base 10 (Decimal): [0 ... 9]
Base 16 (hexadecimal): [0 ... 9, A, B, C, D, E, F]
10
Introduction to number system
Decimal Number System
The decimal number system has ten digits: 0, 1, 2, 3,
4, 5, 6, 7, 8, and 9
The decimal numbering system has a base of 10 with
each position weighted by a factor of 10:
11
Introduction to number system
Binary Number System
The binary number system has two digits: 0 and 1
The binary numbering system has a base of 2 with
each position weighted by a factor of 2:
12
Introduction to number system
13
Conversion between Bases
Conversion of a mixed decimal number is implemented
as follows:
Convert the integer part of the number using
repeated division.
Convert the fractional part of the decimal
number using repeated multiplication.
Combine the integer and fractional
components in the new base.
14
Conversion between Bases
Conversion between any two bases, A and B, can be
carried out directly using repeated division and
repeated multiplication.
Base A Base B
However, it is generally easier to convert base A to
its decimal equivalent and then convert the decimal
value to base B.
Base A Decimal Base B
15
Conversion of Decimal Integer
Use repeated division to convert to any base
N = 57 (decimal)
Convert to binary (R = 2) and octal (R = 8)
57 / 2 = 28: rem = 1 = a0
57 / 8 = 7: rem = 1 = a0
28 / 2 = 14: rem = 0 = a1
7 / 8 = 0: rem = 7 = a1
14 / 2 = 7: rem = 0 = a2
5710 = 718
7 / 2 = 3: rem = 1 = a3
3 / 2 = 1: rem = 1 = a4
Use power series expansion to
1 / 2 = 0: rem = 1 = a5 confirm results.
5710 = 1110012
16
Conversion of Decimal Fraction
17
Conversion of Decimal Fraction
In some cases, conversion results in a repeating fraction
Convert 0.710 to binary
0.7 * 2 = 1.4: a-1 = 1
0.4 * 2 = 0.8: a-2 = 0
0.8 * 2 = 1.6: a-3 = 1
0.6 * 2 = 1.2: a-4 = 1
0.2 * 2 = 0.4: a-5 = 0
0.4 * 2 = 0.8: a-6 = 0
0.710 = 0.1 0110 0110 0110 ...2
Example:
Convert 48.562510 to binary.
Confirm the results using the Power
Series Expansion. 18
Conversion of Octal
Conversion between binary and octal can be
carried out by inspection.
Each octal digit corresponds to 3 bits
101 110 010 . 011 0012 = 5 6 2 . 3 18
010 011 100 . 101 0012 = 2 3 4 . 5 18
7 4 5 . 3 28 = 111 100 101 . 011 0102
3 0 6 . 0 58 = 011 000 110 . 000 1012
19
Conversion of Hexadecimal
Conversion between binary and hexadecimal
can be carried out by inspection.
Each hexadecimal digit corresponds to 4 bits
1001 1010 0110 . 1011 01012 = 9 A 6 . B 516
1100 1011 1000 . 1110 01112 = C B 8 . E 716
E 9 4 . D 216 = 1110 1001 0100 . 1101 00102
1 C 7 . 8 F16 = 0001 1100 0111 . 1000 11112
Note that the hexadecimal number system requires
additional characters to represent its 16 values.
20
Number Systems
21
Number representation in binary
Unsigned and Signed Numbers
bn 1 b1 b0
Magnitude
MSB
(a) Unsigned number- For an n-bit unsigned binary number,
all n bits are used to represent the magnitude of the number.
** Cannot represent negative numbers.
bn 1 bn 2 b1 b0
Magnitude
Sign
0 denotes +
1 denotes MSB
1. Sign-and-Magnitude
2. One's Complement
3. Two's Complement
25
Number representation in binary
Sign-and-Magnitude
26
Number representation in binary
Sign-and-Magnitude
N' = (2n 1) P
N* = (2n) P
N* = N' + 1
34
Number representation in binary
Two's Complement
The Two's Complement representation of N can also be
determined by adding 1 to the One's Complement
representation of N.
N = n-bit negative number
P = |N|
N' = One's Complement representation of N.
N' = bit-wise complement of P.
N* = N' + 1
37
1s and 2s complement
The 1s complement of a binary number is obtained by
complementing all its bits, i.e. by replacing 0s with 1s and 1s with
0s. For example, the 1s complement of (10010110)2 is
(01101001)2. The 2s complement of a binary number is obtained
by adding 1 to its 1s complement. The 2s complement of
(10010110)2 is (01101010)2.
01011011
+ 01110010 10110101 00111100
11001101 + 01101100 + 10101010
40
Binary Arithmetic
Binary Subtraction:
Borrow
0 10 1 1
- 0 - 1 - 0 - 1
0 1 1 0
Difference
Examples:
41
Binary Arithmetic
Binary Multiplication
0 0 1 1
x 0 x 1 x 0 x 1
0 0 0 1
Product
Examples:
10110001 00111100
x 01101101 x 10101100
42
Binary Arithmetic
43
Radix complement & Diminished Radix
complement Arithmetic
Complements
Complements are used in digital computers for simplifying the
subtraction operation and for logic manipulation.
There are two types of complements for each base r system: radix
complement and the diminished radix complement.
The first is referred to as the rs complement and the second as the
(r-1)s complement.
When the values of the base r is substituted in the name, the two
types are referred to as the 2s complement, and 1s complement for
binary numbers , and the 10s complement, and 9s complement for
decimal numbers.
44
Two's Complement Addition
Addition of n-bit signed numbers using Two's Complement
addition is straightforward.
Addition is carried out in the same way as the addition of n-bit
positive numbers.
Carry from the sign position (MSB) is ignored.
Overflow occurs if the correct result (including the sign) cannot
be represented in n bits.
Example: Implement the addition of the following signed numbers
using Two's Complement Addition:
32 + 45
-17 + 63
82 + (-29)
45
Two's Complement Subtraction
A B = A + (-B)
Subtraction can be implemented using addition.
Determine the Two's Complement representation for
the negative number -B.
Use Two's Complement Addition to add A and -B.
32 - 45
-17 - 63
82 - (-29)
46
One's Complement Addition
Similar to the addition of n-bit numbers using Two's
Complement Addition.
Instead of discarding the carry from the sign position (MSB),
it must be added to the least significant bit (LSB) of the n-bit
sum.
Referred to as an end-around carry.
32 + 45
-17 + 63
82 + (-29)
47
10's Complement Addition
48
Overflow
General rule for detecting overflow when adding two n-bit
numbers using either One's Complement or Two's
Complement Addition
An overflow occurs when the addition of two
positive numbers results in a negative value or the
addition of two negative numbers results in a
positive value.
Cannot occur when adding a positive number and a
negative number.
By using bit fields sufficiently large to handle the magnitude
of the sums, we arrive at the correct answers.
49
Binary codes
A computer is a digital system that stores and processes different
types of data in the form of 0s and 1s.
The different types of data handled by a computer system include
numbers, alphabets and some special characters.
Although, in every code used the information is represented in
binary form, the interpretation of this binary information is possible
only if the code in which this information is available is known.
Different types of codes have been developed and used to represent
the data entered by the users in the binary format.
Since these codes convert the data into the binary form, the
computer codes are also referred as binary codes.
50
Binary codes
Binary Coded Decimal(BCD)
The binary coded decimal (BCD) is a type of binary code used to
represent a given decimal number in an equivalent binary form.
51
Binary codes
BCD-to-Binary Conversion
A given BCD number can be converted into an equivalent binary
number by first writing its decimal equivalent and then converting
it into its binary equivalent.
Example:
Find the binary equivalent of the BCD number 000101001.0111 0101
Solution:
52
Binary codes
Binary-to-BCD Conversion
The process of binary-to-BCD conversion is the same as the
process of BCD-to-binary conversion executed in reverse order.
A given binary number can be converted into an equivalent
BCD number by first determining its decimal equivalent and
then writing the corresponding BCD equivalent.
Example:
Find the BCD equivalent of the binary number 10101011.101
Solution:
Corresponding decimal number: 171.625
the BCD equivalent of the binary number can be then written
as 000101110001.011000100101
53
Binary codes
Excess-3 BCD Code
54
Binary codes
Gray Codes
Code values for successive decimal digits differ in
exactly one bit.
Example: 2 - bit Gray Code
Decimal
0 00 00
1 01 01
2 10 11
3 11 10
55
Binary codes
Example: 3 - bit Gray Code
Decimal
0 000 000
1 001 001
2 010 011
3 011 010
4 100 110
5 101 111
6 110 101
7 111 100
56
Example: 4-bit Gray Code
Decimal Equivalent Binary Code Gray Code
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
57
15 1111 1000
Binary codes
Binary to Gray code conversion
We can convert a number represented in the binary form to Gray
code representation. For carrying out this conversion, we need to
remember the following two rules:
Binary Binary Gray
i. The Most Significant Bit (MSB) of Digit Addition Coded
Operation Digit
the binary number and the gray
coded number is always the same. 1 1
0 0+1 1
1 1+1 0
1 1+0 1
Binary codes
ASCII Code
American Standard Code for Information Interchange
Common code used for the storage and transfer of
alphanumeric characters.
7-bit Weighted Code
Can represent a total of 128 characters
Used to represent letters, numbers and other characters
(e.g. special control characters)
Any word or number can be represented (and stored or
transferred) using its ASCII Code.
60
Binary codes
Contd
The ASCII code is pronounced as ASKEE and is used for the
same purpose for which the EBCDIC code is used. However,
this code is more popular than EBCDIC code as unlike the
EBCDIC code this code can be implemented by most of the
non-IBM computer systems.
61
ASCII Code
62
Binary codes
EBCDIC Code
Extended Binary Coded Decimal Interchange Code
(EBCDIC)
The EBCDIC code is an 8-bit alphanumeric code that was
developed by IBM to represent alphabets, decimal digits and
special characters, including control characters.
The EBCDIC codes are generally the decimal and the
hexadecimal representation of different characters.
This code is rarely used by non IBM-compatible computer
systems.
63
Lab Experiments
EXPERIMENT 1: Realization of gates using discrete components and verification of
truth table of logic gates
Experiment 2: Sum of products and Products of sums circuits.
Experiment 3: Adders and Subtractor
Experiment 4: Addition/ Subtraction in 2`s Complement Representation
Experiment 5: BCD 7- segment decoder
Experiment 6: Design of code converters (binary to Gray and Gray to binary conversion
Experiment 7: Design combinational circuits using multiplexer
Experiment 8: Design combinational circuits using demultiplexer
Experiment 9: Flip Flops
Experiment 10:Modes of registers
Experiment 11: Application of registers: ring counter, twisted-ring counter
Experiment 12: Sequence generator
Experiment 13: Asynchronous counters
Experiment 14: Synchronous Counter Design
64