Beruflich Dokumente
Kultur Dokumente
BINARY SYSTEMS
1.1 DIGITAL SYSTEMS
Digital systems have such a prominent role in everyday life that we refer to the
present technological period as the digital age. Digital systems are used in
communication, business transactions, traffic control, spacecraft guidance, medical
treatment, weather monitoring, the Internet, and many other commercial, industrial,
and scientific enterprises. The general-purpose digital computer is the best-known
example of a digital system.
The most striking property of the digital computer is its generality. It can
follow a sequence of instructions, called a program, that operates on given data. The
user can specify and change the program or the data according to the specific need.
Because of this flexibility, general-purpose digital computers can perform a variety of
information processing tasks that range over a wide spectrum of applications.
One characteristic of digital systems is their ability to represent and manipulate
discrete elements of information. Any set that is restricted to a finite number of
elements contains discrete information. Examples of discrete sets are the 10 decimal
digits, the 26 letters of the alphabet, the 52 playing cards, and the 64 squares of a
chessboard.
Discrete elements of information are represented in a digital system by
physical quantities called signals, such as voltages and currents. Electronic devices
called transistors predominate in the circuitry that implements these signals. The
transistors are generally found in only two stable states (on or off). So, the signals in
most present day electronic digital systems use just two discrete values and are
therefore said to be binary. A binary digit, called a bit, has two values: 0 and 1.
Discrete elements of information are represented with groups of bits called binary
codes. Thus, a digital system is a system that manipulates discrete elements of
information represented internally in binary form. Discrete quantities of information
either emerge from the nature of the data being processed or may be quantized from a
continuous process. For example, students‟s result analysis is processed by means of
discrete data values such as letters of the alphabet (names), digits (marks, roll no.),
and special symbols (such as %). On the other hand, a research scientist may observe
a continuous process, but record only specific quantities in tabular form. The scientist
1
is thus quantizing continuous data, making each number in his or her table a discrete
quantity. In many cases, the quantization of a process can be performed automatically
by an analog-to -digital converter, a device that forms a digital (discrete)
representation of an analog (continuous) quantity.
There are fundamental reasons that commercial products are made with digital
circuits.
Programmable: Like a digital computer, most digital devices are
programmable. By changing the program in a programmable device, the same
underlying hardware can be used for many different applications, thereby
allowing its cost of development to be spread across a wider customer base.
Low Cost: Dramatic cost reductions in digital devices have come
about because of advances in digital integrated circuit technology. As the number
of transistors that can be put on a piece of silicon increases to produce complex
functions, the cost per unit decreases and digital devices can be bought at an
increasingly reduced price.
Speed: Equipment built with digital integrated circuits can perform at a
speed of hundreds of millions of operations per second.
Reliability: Digital systems can be made to operate with extreme
reliability by using error‐correcting codes.
A digital system is an interconnection of digital modules. To understand the
operation of each digital module, it is necessary to have a basic knowledge of digital
circuits and their logical function.
2
The most familiar number system for human beings is the decimal number
system, but this system is not convenient for digital system which operates on only
two values (on („1‟) or off („0‟)).
The base or radix of a number system („r‟) is defined as the number of distinct
symbols (digits or characters) used in that number system. The range of values for a
digit in a number system with base „r‟ is from 0 to (r-1).
For example, the Base „5‟ number system has 5 digits whose value ranges from 0 to 4.
Number System Radix Digits or characters available in that number system
(„r‟)
Binary 2 "0", "1"
Octal 8 "0", "1", "2", "3", "4", "5", "6", "7"
Decimal 10 "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
Hexa Decimal 16 "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B",
"C", "D", "E", and "F".
Where “A” stands for 10, “B” for 11 and so on.
3
1.2.2.1 Conversion of numbers in any base to Decimal
The conversion of a number in base r to decimal is done by expanding the
number in a power series and adding all the terms. The conversion from any base to
base 10 can be obtained using the formulae
( ) ∑
Where r is the base, aj is the digit at position j, m is the number of digits after the
decimal point, n is the number of digits of the integer part and (N)10 is the obtained
number in decimal. Representations of a number in a different radix are said to be
equivalent if they have the same decimal representation. For example, (0011) 8 =
(1001)2 = (9)10.
Conversion of numbers from Binary to Decimal:
4
(314)8 = (204)10
2. Convert (12.56)8 to decimal.
(12.56)8 = 1 X 81 + 2 X 80 + 5 X 8 -1 + 6 X 8 -2
= 1 X 8 + 2 X 1 + 5 X 0.125 + 6 X 0.015625
= 8 + 2 + 0.625 + 0.09375 = (10.71875)10
(12.56)8 = (10.71875)10
Conversion of numbers from Hexa Decimal to Decimal:
5
The conversion of a decimal fraction to a number in base r is done by
multiplying that fraction and all successive fractions by r and accumulating
the integers. The process is continued until the fraction becomes 0 or until the
number of digits has sufficient accuracy.
The conversion of decimal numbers with both integer and fractional parts is
done by converting the integer and the fraction separately and then combining
the two answers.
This procedure is best illustrated by the following examples.
Decimal to Binary Conversion
1. (41)10 = (?)2
Representation I or Representation II
Stop the process when quotient becomes zero. By accumulating the remainders from
bottom to top we get the equivalent binary number of the given decimal number.
(41)10 = (101001)2
2. (0.685)10 = (?)2
6
The process is continued until the fraction becomes 0 or until the number of digits has
sufficient accuracy. By accumulating the integer values only from top to bottom we
get the equivalent binary number of the given decimal fraction.
(0.685)10 = (0.101011…..)2
3. (49.75)10 = (?)2
As the given decimal number has both integer and fractional part, there is a
need to separate the integer and fractional part and each part is to be converted
separately. Finally, the obtained results are to be combined.
(49.75)10 = (110001.11)2
Decimal to Octal Conversion:
1. (143)10 = (?)8
Successive division of Quotients Remainders
8 143 number and its
quotients by base value
8 17 - 7 143/8 17 7
8 2 - 1 17/8 2 1
0 - 2 2/8 0 2
(143)10 = (217)8
7
2. (0.7685)10 = (?)8
: : :
: : :
(0.7685)10 = (0.611361…..)8
3. (18.76)10 = (?)8
(18)10 = (22)8 : : :
: : :
(0.76)10 = (0.605……)2
(18.76)10 = (22.605……)8
Decimal to Hexadecimal Conversion:
1. (1459)10 = (?)16
Successive division of Quotients Remainders
16 1459 number and its
quotients by base value
16 91 - 3 1459/16 91 3
16 5 - 11 (B) 91/16 5 11 (B)
0 - 5 5/16 0 5
(1459)10 = (5B3)8
8
2. (0.85)10 = (?)16
: : :
: : :
(0.85)10 = (0.D99…..)8
3. (18.76)10 = (?)16
: : :
(18)10 = (12)8 : :
:
(0.76)10 = (0.C28)16
(18.76)10 = (12.C28….)16
9
(10 110 001 101 011 . 111 100 000 110)2 = (26153.7406)8
2 6 1 5 3 . 7 4 0 6
10
Numbers with different bases
Decimal Binary Octal Hexadecimal
(base 10) (base 2) (base 8 (base 16)
00 0000 00 00
01 0001 01 01
02 0010 02 02
03 0011 03 03
04 0100 04 04
05 0101 05 05
06 0110 06 06
07 0111 07 07
08 1000 10 08
09 1001 11 09
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
11
in an operation of changing bits from 0 to 1 or from 1 to 0. The 1‟s complement of a
binary number is formed by changing 1‟s to 0‟s and 0‟s to 1‟s.
The 1‟s complement of 1011000 is 0100111.
The 1‟s complement of 0101101 is 1010010.
The (r - 1)‟s complement of octal or hexadecimal numbers is obtained by
subtracting each digit from 7 or F (decimal 15), respectively.
The radix complement: Let a number N in base r having n digits, the radix
complement, r‟s complement of N, is defined as r n – N for N ≠ 0 and 0 for N = 0.
The r’s complement is obtained by adding 1 to the (r - 1)‟s complement, since
r n - N = [(r n - 1) - N] + 1.
Ex: The 10‟s complement of decimal 2389 is (9999 - 2389) + 1 = 7610 + 1 = 7611.
The 2‟s complement of binary 101100 is (111111 – 101100) + 1
= 010011 + 1 = 010100
The 10‟s complement of N, can be formed also by leaving all least significant
0‟s unchanged, subtracting the first nonzero least significant digit from 10, and
subtracting all higher significant digits from 9.
Ex: The 10‟s complement of 012398 is 987602
The 10‟s complement of 246700 is 753300
The 2‟s complement can be formed by leaving all least significant 0‟s and the
first 1 unchanged and replacing 1‟s with 0‟s and 0‟s with 1‟s in all other
higher significant digits.
Ex: The 2‟s complement of 1101100 is 0010100
The 2‟s complement of 0110111 is 1001001
If the original number N contains a radix point, the point should be removed
temporarily in order to form the r‟s or (r - 1)‟s complement. The radix point is
then restored to the complemented number in the same relative position.
Ex: The 9‟s complement of 54.67 is 45.32, and the 10‟s complement is 45.33
The 1‟s complement of 10101.1010 is 01010.0101, and the 2‟s complement is
01010.0110
The complement of the complement restores the number to its original value.
The r‟s complement of N is r n - N, so that the complement of the complement
is r n - (r n - N) = N and is equal to the original number.
12
1.3.1 SUBTRACTION WITH COMPLEMENTS
Subtraction of two unsigned numbers using r’s complement:
The subtraction of two n‐digit unsigned numbers M - N in base r can be done
as follows, provided both numbers should contain equal number of digits otherwise
pad with zeros.
1. Add the minuend M to the r‟s complement of the subtrahend N. Mathematically,
M + (r n - N) = M - N + r n.
2. If M ≥ N, the sum will produce an end carry r n, which can be discarded; what is
left is the result M - N.
3. If M < N, the sum does not produce an end carry and is equal to r n - (N - M), which
is the r‟s complement of (N - M). To obtain the answer in a familiar form, take the r‟s
complement of the sum and place a negative sign in front.
1. Using 10‟s complement, subtract 72532 - 3250.
M = 72532, N = 3250
M has 5 digits and N has 4 digits. As both numbers do not contain equal number of
digits, pad with zero for N, then N = 03250.
M = 72532
10‟s complement of N = + 96750
Sum = 169282
Discard end carry 105 = - 100000
Answer= 69282
The occurrence of the end carry signifies that M ≥ N and that the result is therefore
positive.
2. Using 10‟s complement, subtract 3250 - 72532.
M = 3250, N = 72532
M has 4 digits and N has 5 digits. As both numbers do not contain equal number of
digits, pad with zero for M, then M = 03250.
M = 03250
10‟s complement of N = + 27468
Sum = 30718
Answer = - (10‟s complement of 30718) = - 69282
As there is no end carry, it signifies that M < N and that the result is therefore
negative. So, to represent the result in familiar form 10‟s complement of the result is
obtained.
13
3. Using 2‟s complement, subtract 11010 - 01011.
M = 11010, N = 01011
M = 11010
2‟s complement of N = + 10101
Sum = 101111
Discard end carry 105 = - 100000
Answer = 01111
The occurrence of the end carry signifies that M ≥ N and that the result is therefore
positive.
4. Using 2‟s complement, subtract 1011 - 11010.
M = 1011, N = 11010
M has 4 digits and N has 5 digits. As both numbers do not contain equal number of
digits, pad with zero for M, then M = 01011.
M = 01011
2‟s complement of N = + 00110
Sum = 10001
Answer = - (2‟s complement of 10001) = - 01111
As there is no end carry, it signifies that M < N and that the result is therefore
negative. So, to represent the result in familiar form 2‟s complement of the result is
obtained.
Subtraction of two unsigned numbers using (r-1)’s complement:
The (r - 1)‟s complement is one less than the r‟s complement. So, the result of
adding the minuend to the complement of the subtrahend produces a sum that is one
less than the correct difference when an end carry occurs. Removing the end carry and
adding 1 to the sum is referred to as an end‐around carry.
1. Using 9‟s complement, subtract 72532 - 3250.
M = 72532, N = 3250
M has 5 digits and N has 4 digits. As both numbers do not contain equal number of
digits, pad with zero for N, then N = 03250.
M = 72532
9‟s complement of N = + 96749
Sum = 169281
Add end around carry = + 1
Answer= 69282
14
The occurrence of the end carry signifies that M ≥ N and that the result is therefore
positive.
2. Using 9‟s complement, subtract 3250 - 72532.
M = 3250, N = 72532
M has 4 digits and N has 5 digits. As both numbers do not contain equal number of
digits, pad with zero for M, then M = 03250.
M = 03250
9‟s complement of N = + 27467
Sum = 30717
Answer = - (9‟s complement of 30717) = - 69282
As there is no end carry, it signifies that M < N and that the result is therefore
negative. So, to represent the result in familiar form 9‟s complement of the result is
obtained.
3. Using 1‟s complement, subtract 11010 - 01011.
M = 11010, N = 01011
M = 11010
1‟s complement of N = + 10100
Sum = 101110
Add end around carry = + 1
Answer = 01111
The occurrence of the end carry signifies that M ≥ N and that the result is therefore
positive.
4. Using 1‟s complement, subtract 1011 - 11010.
M = 1011, N = 11010
M has 4 digits and N has 5 digits. As both numbers do not contain equal number of
digits, pad with zero for M, then M = 01011.
M = 01011
1‟s complement of N = + 00101
Sum = 10000
Answer = - (1‟s complement of 10001) = - 01111
As there is no end carry, it signifies that M < N and that the result is therefore
negative. So, to represent the result in familiar form 1‟s complement of the result is
obtained.
15
1.4 SIGNED BINARY NUMBERS
Positive integers (including zero) can be represented as unsigned numbers.
The signed numbers represent either positive or negative values. Different notations
used to represent negative numbers are -
Signed‐magnitude representation
Signed‐complement representation
Signed-1‟s‐complement representation
Signed‐2‟s‐complement representation
Signed‐magnitude representation: In signed magnitude representation the left most
bit is used to represent sign of the number. The sign bit is 0 for positive and 1 for
negative. For example the signed binary numbers are represented in signed magnitude
method as follows:
Sign bit Magnitude Value
1 0 0 0 1 0 1 1 - 11
0 0 0 0 1 0 1 1 + 11
Signed‐complement representation:
In signed-complement representation a negative number is indicated by its
complement. The signed‐complement system can use either the 1‟s or the 2‟s
complement, but the 2‟s complement is the most commonly used for arithmetic
operations.
The following table lists all possible four‐bit signed binary numbers in the
three representations. The equivalent decimal number is also shown for reference.
Note that the positive numbers in all three representations are identical and have 0 in
the leftmost position. The signed‐2‟s‐complement system has only one representation
for 0, which is always positive. The other two systems have either a positive 0 or a
negative 0, something not encountered in ordinary arithmetic. So, they are not used
for arithmetic operations. Note that all negative numbers have a 1 in the leftmost bit
position; that is the way we distinguish them from the positive numbers.
16
All signed and unsigned binary numbers are represented with string of bits.
The value of the number depends on the way it is interpreted. For example, the string
of bits 01001 can be considered as 9 (unsigned binary) or as +9 (signed binary)
because the leftmost bit is 0. The string of bits 11001 represents the binary equivalent
of 25 when considered as an unsigned number and the binary equivalent of -9 when
considered as a signed number.
17
quantities is n, there is no limit on the maximum number of bits may be used for a
binary code, for example 10 decimal digits can be coded with 10 bits also.
Binary codes are mainly classified into 5 groups –
Weighted binary codes
Non-weighted binary codes
Error detecting codes
Error correcting codes
Alpha Numeric codes
Based on the properties, binary codes can be classified as –
Sequential Codes
Self-Complementing / Reflective Codes
1.5.1 Weighted Binary Codes:
In a weighted binary code, each bit position is assigned a weighting factor in
such a way that each digit can be evaluated by adding the weights of all the 1‟s in the
coded combination. The commonly used weighted codes are-
8 4 2 1 Code (Binary Coded Decimal)
2 4 2 1 Code
5 4 2 1 Code
5 2 1 1 Code
8 4 -2 -1 Code
For example, In 8 4 2 1 code the value of 0110 is evaluated as
8 x 0 + 4 x 1 + 2 x 1 + 1 x 0 = 4 + 2 = 6.
In 2 4 2 1 code 1101 can be evaluated as
2 x 1 + 4 x 1 + 2 x 0 + 1 x 1 = 2 + 4 + 1 = 7.
Note: Some digits can be coded in two possible ways in the 2 4 2 1 code. (For
example, the digit 4 can be assigned with 0100 or 1010).
Binary coded Decimal
Even though the most natural system for a computer is binary number system, people
are more accustomed to the decimal system. So, a decimal number is need to be
converted to binary, and then after processing using the digital systems it is to be
converted to decimal.
The code most commonly used for the decimal digits is the straight binary
assignment, which is known as Binary Coded Decimal (BCD).
18
The BCD is weighted code with weights 8 4 2 1.
The 10 decimal digits form a set, which required minimum 4 bits to code a
single digit. Using 4 bits 16 bit combinations can be obtained, out of which 6
combinations are unused.
The binary numbers 0000 to 1001 are similar to BCD, but 1010 to 1111 are
unused in BCD, and have no meaning in BCD.
A number with k decimal digits require 4k bits in BCD representation.
Even though, BCD representation occupies more space than a pure binary
representation, it has an advantage that the input and output data are generated
by people who use decimal system.
19
Other weighted codes:
Decimal BCD
5421 2421 5211 8 4 -2 -1
Symbol 8421
0 0000 0000 0000 0000 0000
1 0001 0001 0001 0001 0111
2 0010 0010 0010 0011 0110
3 0011 0011 0011 0101 0101
4 0100 0100 0100 0111 0100
5 0101 1000 1011 1000 1011
6 0110 1001 1100 1010 1010
7 0111 1010 1101 1100 1001
8 1000 1011 1110 1110 1000
9 1001 1100 1111 1111 1111
20
Decimal BCD digit
Excess 3 code
Symbol 8421
0 0000 0011
1 0001 0100
2 0010 0101
3 0011 0110
4 0100 0111
5 0101 1000
6 0110 1001
7 0111 1010
8 1000 1011
9 1001 1100
Gray Code:
The gray code is a non-weighted code and it has advantage over straight
binary number sequence is that, successive code words differ by only one bit from
one number to the next. Hence it is also called Unit Distance Code. Since gray code
is a non-weighted code it is seldom used in arithmetic applications, but it is used in
analog to digital converters. It is an example for cyclic code.
Decimal
Binary Number Gray Code
Symbol
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
21
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000
1 1 1 0
1.5.3 Error-Detecting Codes:
During the process of binary data transmission errors may occur. Error detecting
codes are used to detect such type of errors. If a single error transforms a valid code
word into invalid one, it is said to be a single error detecting code.
A parity bit is an extra bit included with the n-bit binary message to make the total
number of 1‟s in the message (including the parity bit) either odd or even.
In the even parity method, parity bit (0 or 1) is added such that the total number of 1‟s
in the coded group must be even (including parity bit). Similarly, odd in odd parity
method.
22
Three bit Even Parity Odd Parity
message Method Method
xyz P xyz P xyz
000 0 000 1 000
001 1 001 0 010
010 1 010 0 010
011 0 011 1 011
100 1 100 0 100
101 0 101 1 101
110 0 110 1 110
111 1 111 0 111
Parity check is commonly used for error detection. Even though parity code is meant
for single error detection, it can detect any odd number of errors, but it is not possible
to correct. Even number of errors cannot be detectable using parity method.
2 out of 5 code:
The 2 out of 5 code consists of all 10 possible combinations of two 1‟s in a 5-
bit code word. With the exception of the code word for decimal 0, the 2 out of 5 code
is a weighted code with weights 0 1 2 4 7. If a single error occurs, it transforms a
valid code word into an invalid one, and making error detection straight forward.
2 out of 5 code
Decimal digit
0 1 2 4 7
0 0 0 0 1 1
1 1 1 0 0 0
2 1 0 1 0 0
3 0 1 1 0 0
4 1 0 0 1 0
5 0 1 0 1 0
6 0 0 1 1 0
7 1 0 0 0 1
8 0 1 0 0 1
9 0 0 1 0 1
23
1.5.4 Error Correcting Codes:
A code is said to be an error correcting code, if the correct code word can always be
deduced from the erroneous word. The minimum distance must be 3 for error
correcting codes, which can correct single error and detect double errors. The distance
between two code words is defined as the number of bits that must change in one code
word so that another code word results. For example, the distance between 1001 and
1010 is 2, since two bits are to be changed. The minimum distance of a code is the
smallest number of bits in which any two code words differ.
Hamming Code:
R.W. Hamming developed a system that provides a methodical way to add
parity bits to the data bits in order to detect and correct errors, which is familiar as
Hamming Code.
The basic principles in constructing a Hamming error correcting code are as follows:
To each group of „m‟ information or message bits. „k‟ parity bits are added to
form an (m+k) bit code.
The location of each of the (m+k) bits within a code word is assigned a
decimal value, starting by assigning a 1 to the Most Significant Bit (MSB) and
(m+k) to the Least Significant Bit (LSB).
The value of k is selected such that it must satisfy the inequality
2k ≥m+k+1
The parity bits are included in the positions 1, 2, 4, …….. 2 k-1.
k parity bits are added for the selected bits of each code word so as to get
either even or odd parity.
The process of constructing a Hamming code for message 0100 is explained as
follows:
The given message is 0100.
Number of message bits m=4.
Number of parity bits required is determined by trial and error method, which
satisfies the inequality 2k ≥m+k+1
k = 3 satisfies the inequality for the given 4-bit message. (23 ≥ 4+3+1)
The total number of bits in hamming code is
4 message bits + 3 parity bits = 7 bits.
The bit positions are from 1 to 7, and 3 parity bits are included in positions
1, 2, 4
24
Bit Positions 1 2 3 4 5 6 7
Bit Designations P1 P2 M1 P4 M2 M3 M4
Original message 0 1 0 0
P1 is to set even parity in the bit 1 0 1 0
positions 1, 3, 5, 7
P2 is to set even parity in the bit 0 0 0 0
positions 2, 3, 6, 7
P4 is to set even parity in the bit 1 1 0 0
positions 4, 5, 6, 7
Coded Message 1 0 0 1 1 0 0
25
The process of correcting the error in the received Hamming code 1011100 with
even parity:
Parity check
Bit Positions 1 2 3 4 5 6 7
results
Bit Designations P1 P2 M1 P4 M2 M3 M4
Message Received 1 0 0 1 1 1 0
Even parity check C1 in 1 0 1 0 0, no error
the bit positions 1, 3, 5, 7
Even parity check C2 in 0 0 1 0 1, error occurred
the bit positions 2, 3, 6, 7
Even parity check C4 in 1 1 1 0 1, error occured
the bit positions 4, 5, 6, 7
Corrected Message 1 0 0 1 1 0 0
The parity check results C4 C2 C1 represents the bit position with error ie.,
110. So the bit in the 6th position is completed to get the correct message.
Hamming codes with even parity for BCD
26
the 26 letters of the alphabet, and a number of special characters. The commonly used
alphanumeric codes are:
ASCII
EBCDIC
Hollerith
ASCII:
ASCII stands for American Standard Code for Information Interchange.
It is a standard binary code with 7 bits used for representing alphanumeric
character set of 128 symbols.
It is generally represented using 8 bits, with one bit unused, which is reserved
for future extension by setting MSB to 0, or can be used as parity bit.
The ASCII code contains – 94 graphic characters, which can be printed and 34
non printable characters.
The 94 graphic characters include –
26 upper case letters (A to Z)
26 lower case letters (a to z)
10 decimal digits (0 to 9)
32 special printable characters, such as %, &, etc.
The 34 control characters are designated in the ASCII table with abbreviated
names, which is used as control functions.
Three types of control characters are
Format effectors – controls the layout of printing – Back space,
enter, tab, etc.
Information separators – to separate the data into divisions –
paragraphs, page breaks, etc.
Communication control characters – used in Transmission of text
between remote devices – start of text, end of text, etc.
EBCDIC:
EBCDIC stands for Extended Binary Coded Decimal Information Code.
It is especially used in IBM computers.
It is 8 bit code with 256 possible symbols.
Hollerith Code:
It is a 12 bit code.
Used in punched card readers of large computers.
27
Represent ECE in ASCII code by using even parity.
Given Symbols E C E
28
1.5.6 Sequential Codes
In Sequential codes each binary code is one binary number greater than its
preceding code. The 8,4,2,1 code, excess-3 code are examples for sequential codes.
29
Register Transfer:
In digital systems, a register transfer operation is a basic operation that
consists of a transfer of binary information from one set of registers into another set of
registers. The transfer may be direct, from one register to another, or may pass
through data processing circuits to perform an operation.
1.7 BINARY LOGIC:
Binary logic deals with variables that take on two discrete values (0 or 1) and with
operators that assume logical meaning. The binary logic consists or binary variables
and a set of logical operations. The variables are designated by letters of the alphabet,
such as A, B, C, x, y, z, etc., with each variable having two and only two distinct
possible values 0 and 1. There are 3 basic logic operations: AND, OR, and NOT.
Binary arithmetic and binary logic are different, for example, in binary arithmetic,
1+1=10 while in binary logic 1+1=1.
The AND function can have any number of inputs. However, for practical
reasons, commercial AND gates are most commonly manufactured with 2, 3, or 4
inputs.
30
The OR Gate:
The OR gate implements the OR function, z = x+y. The output of the gate is at logic 1
when either of the inputs is at logic 1, otherwise results in logic 0.
Logic Symbol Truth Table
Inputs Output
x y z = x+y
0 0 0
0 1 1
1 0 1
1 1 1
The OR function can have any number of inputs. However, for practical
reasons, commercial OR gates are most commonly manufactured with 2, 3, or 4
inputs.
The NOT Gate or Inverter:
The NOT gate has only one input and one output. The output is complement of the
input i.e., y=x‟.
Logic Symbol Truth Table
Input Output
x y= x’
0 1
1 0
31
BOOLEAN ALGEBRA AND LOGIC GATES
1.8 BOOLEAN ALGEBRA
Boolean algebra was an algebraic system developed by George Boole in 1854. The
two valued Boolean algebra is also known as Switching Algebra. Boolean algebra is
an algebraic structure defined on a set of elements B, together with two binary
operators (+, .) provided the following Huntington postulates are satisfied.
1. (a) The structure is closed with respect to the operator +.
(b) The structure is closed with respect to the operator . .
2. (a) The element 0 is an identity element with respect to +;
that is, x + 0 =0 + x = x.
(b) The element 1 is an identity element with respect to . ;
that is, x . 1 = 1 . x = x.
3. (a) The structure is commutative with respect to +; that is, x + y = y + x.
(b) The structure is commutative with respect to . ; that is, x . y = y . x.
4. (a) The operator . is distributive over +; that is, x . (y + z) = (x . y) + (x . z).
(b) The operator + is distributive over . ; that is, x + (y . z) = (x + y) . (x + z).
5. For every element x Є B, there exists an element x’ Є B (called the
complement of x) such that (a) x + x‟ = 1 and (b) x . x’ = 0.
6. There exist at least two elements x, y Є B such that x ≠ y.
The two valued Boolean algebra:
The two valued Boolean algebra is defined on a set B = {0,1} with two binary
operators + and., whose rules are defined as below:
x y x+y
x y x.y
0 0 0
0 0 0 0 1 0
0 1 0 1 0 0
1 0 0 1 1 1
1 1 1
x x’
0 1
1 0
32
1. That the structure is closed with respect to the two operators is obvious from the
tables, since the result of each operation is either 1 or 0 and 1, 0 Є B.
2. From the tables, we see that
(a) 0 + 0 =0; 0+ 1 = 1 + 0 = 1;
(b) 1 .1 = 1; 1.0 = 0.1 = 0.
This establishes the two identity elements, 0 for + and 1 for . as defined by postulate 2.
3. The commutative laws are obvious from the symmetry of the binary operator tables.
4. (a) The distributive law x . (y + z) = (x . y) + (x . z) can be shown to hold from the
operator tables by forming a truth table of all possible values of x, y, and z. For each
combination, we derive x . (y + z) and show that the value is the same as the value of
(x . y) + (x . z):
(b) The distributive law of + over . can be shown to hold by means of a truth table
similar to the one in part (a).
5. From the complement table, it is easily shown that
(a) x + x’ = 1, since 0 + 0‟ = 0 + 1 = 1 and 1 + 1‟ = 1 + 0 = 1.
(b) x . x’ = 0, since 0 . 0‟ = 0 . 1 = 0 and 1 . 1‟ = 1 . 0 = 0.
Thus, postulate 5 is verified.
6. Postulate 6 is satisfied because the two‐valued Boolean algebra has two elements, 1
and 0, with 1 ≠ 0.
1.8.1 Basic Theorems and Properties and Boolean algebra:
Duality: The important property of Boolean algebra is duality principle and states
that every algebraic expression deducible from the postulates of Boolean algebra
remains valid if the operators and identity elements are interchanged. The dual of an
algebraic expression can be obtained by simply interchanging OR and AND operators
and replacing 1‟s by 0‟s and 0‟s by 1‟s.
33
Postulate 2 (a) x+0=x (b) x.1=x
Postulate 3, Commutative (a) x+y=y+x (b) x.y=y.x
Postulate 4, Distributive (a) x.(y+z) = x.y + x.z (b) x+yz=(x+y).(x+z)
Postulate 5 (a) x + x’ = 1 (b) x . x’=0
Theorem 1 (a) x+x=x (b) x . x=x
Theorem 2 (a) x+1=1 (b) x . 0=0
Theorem 3, Involution (x’)’=x
Theorem 4, Associative (a) x+(y+z)=(x+y)+z (b) x(yz)=(xy)z
Theorem 5, DeMorgan (a) (x+y)’ = x’y’ (b) (xy)’=x’+y’
Theorem 6, Absorption (a) x+xy=x (b) x(x+y)=x
Theorem Proofs:
THEOREM 1(a): x + x = x.
Statement Justification
x + x = (x + x) . 1 x . 1 = x , postulate 2(b)
= (x + x)(x + x’) x + x’ = 1, postulate 5(a)
= x + xx’ (x+y).(x+z)=x+yz, postulate 4(b)
=x+0 x . x’=0, postulate 5(b)
=x x + 0 = x, postulate 2(a)
THEOREM 1(b): x . x = x.
Statement Justification
x . x = xx + 0 x + 0 = x , postulate 2(a)
= xx + xx’ x . x’=0, postulate 5(b)
= x(x + x‟) x.y + x.z=x.(y+z), postulate 4(a)
=x.1 x + x’ = 1, postulate 5(a)
=x x . 1 = x, postulate 2(b)
Note that theorem 1(b) is the dual of theorem 1(a) and that each step of the proof in
part (b) is the dual of its counterpart in part (a). Any dual theorem can be similarly
derived from the proof of its corresponding theorem.
THEOREM 2(a): x + 1 = 1.
Statement Justification
x + 1 = (x +1) . 1 x . 1 = x, postulate 2(b)
= (x + 1)(x + x’) x + x’ = 1, postulate 5(a)
= x + 1.x’ (x+y).(x+z)=x+yz, postulate 4(b)
34
= x + x‟ x . 1 = x, postulate 2(b)
=1 x + x’ = 1, postulate 5(a)
THEOREM 2(b): x . 0 = 0. (Can be proved by duality)
Operator Precedence
The operator precedence for evaluating Boolean expressions is
(1) Parentheses,
(2) NOT,
(3) AND, and
(4) OR.
In other words, expressions inside parentheses must be evaluated before all other
operations. The next operation that holds precedence is the complement, and then
follows the AND and, finally, the OR.
THEOREM 4(a):
The validity of the associative law and DeMorgan‟s theorem can be easily
verified with truth tables. The truth table for the Associative law, x+(y+z)=(x+y)+z,
is as follows:
x y z (y+z) x+ (y+z) (x+ y) (x+y)+z
0 0 0 0 0 0 0
0 0 1 1 1 0 1
0 1 0 1 1 1 1
0 1 1 1 1 1 1
1 0 0 0 1 1 1
1 0 1 1 1 1 1
1 1 0 1 1 1 1
1 1 1 1 1 1 1
THEOREM 5(a):
The validity of the associative law and DeMorgan‟s theorem can be easily
verified with truth tables. The truth table for the DeMorgan‟s theorem, (x + y)‟ = x’y’,
is as follows:
x y x+ y (x+ y)’ x’ y’ x’ . y’
0 0 0 1 1 1 1
0 1 1 0 1 0 0
1 0 1 0 0 1 0
1 1 1 0 0 0 0
35
THEOREM 6(a): x + xy = x.
Statement Justification
x + xy = x . 1 + xy x.1=x
= x(1 + y) xy+xz=x(y+z)
= x(y + 1) x+y=y+x
=x.1 x+1=1
=x x.1=x
THEOREM 6(b): x(x + y) = x by duality.
1.9 BOOLEAN FUNCTIONS
A Boolean function described by an algebraic expression consists of binary
variables, the constants 0 and 1, and the logic operation symbols. For a given value of
the binary variables, the function can be equal to either 1 or 0.
Ex: F = x + y’z
A Boolean function can be represented in a truth table. The number of rows in
the truth table is 2n, where n is the number of variables in the function. The binary
combinations for the truth table are obtained from the binary numbers by counting
from 0 through 2n - 1. Following Table shows the truth table for the function F.
x y z y’ y’z F = x + y’z
0 0 0 1 0 0
0 0 1 1 1 1
0 1 0 0 0 0
0 1 1 0 0 0
1 0 0 1 0 1
1 0 1 1 1 1
1 1 0 0 0 1
1 1 1 0 0 1
36
Now consider the possible simplification of the function by applying some of the
identities of Boolean algebra:
F = x’y’z + x’yz + xy’ = x’z (y’+ y) + xy’ = x’z + xy’.
The function is reduced to only two terms.
1.9.1 Complement of a Function
The complement of a function F is F‟ and is obtained from an interchange of
0‟s for 1‟s and 1‟s for 0‟s in the value of F.
x y z F = x + y’z F‟= (x + y’z)’
0 0 0 0 1
0 0 1 1 0
0 1 0 0 1
0 1 1 0 1
1 0 0 1 0
1 0 1 1 0
1 1 0 1 0
1 1 1 1 0
37
1.10 CANONICAL AND STANDARD FORMS
A Boolean function can be expressed in two forms:
Canonical form
Sum of minterms
Product of Maxterms
Standard form
Sum of Products (SOP)
Product of Sums (POS)
1.10.1 CANONICAL FORM:
A Boolean function expressed in sum of minterms or product of maxterms
form is said to be in canonical form. With n variables, 2n minterms / maxterms can be
formed; 22n functions can be formed by using 2n minterms / maxterms.
Minterm: A minterm is a product term (AND term), where each term consists of all
variables of the function in either complemented (if value is 0) or un-complemented
( if value is 1) form. It is also known as Standard Product Term.
Maxterm: A maxterm is a sum term (OR term), where each term consists of all
variables of the function in either complemented (if value is 1) or un-complemented
( if value is 0) form. It is also known as Standard Sum Term.
Minters and Maxterms formed by 3-binary variables
Minterm Maxterm
x y z
term Designation term Designation
0 0 0 x’y’z’ m0 x+y+z M0
0 0 1 x’y’z m1 x+y+z’ M1
0 1 0 x’yz’ m2 x+y’+z M2
0 1 1 x’yz m3 x+y’+z’ M3
1 0 0 xy’z’ m4 x’+y+z M4
1 0 1 xy’z m5 x’+y+z’ M5
1 1 0 xyz’ m6 x’+y’+z M6
1 1 1 xyz m7 x’+y’+z’ M7
38
Let us consider the function F = x + y’z represented in canonical form as follows:
x Y z F = x + y’z F‟= (x + y’z)’
0 0 0 0 1
0 0 1 1 0
0 1 0 0 1
0 1 1 0 1
1 0 0 1 0
1 0 1 1 0
1 1 0 1 0
1 1 1 1 0
39
F = M0 . M2 . M3
or
F= Π(0, 2, 3)
or
F = (x+y+z)( x+y’+z)(x+y’+z’)
The Complement of the function can be represented in canonical sum of
minterms form by the minterms for which the value of F is 0.
F‟ = M1 . M4 . M5 . M6 . M7
or
F= Π(1, 4, 5, 6, 7)
or
F = (x+y+z’)(x’+y+z)(x’+y+z’)(x’+y’+z)(x’+y’+z’)
40
The gate structure of the product‐of‐sums expression consists of a group of
OR gates for the sum terms (except for a single literal), followed by an AND gate,
which is also called two-level OR – A ND implementation.
NON STANDARD FORM:
A Boolean function may be expressed in a nonstandard form which is neither
in sum‐of‐products nor in product‐of‐sums form. For example, the function in non-
standard form is represented as:
F3 = AB + C(D + E)
A function in non-standard form can be changed to a standard form by using
the distributive law, so that it can be implemented using two-level gate networks.
F3 = AB + C(D + E) = AB + CD + CE
1.10.3 Conversion from standard form to canonical form
1. Express the Boolean function F(A, B, C) = A + B’C as a sum of minterms.
Solution: The function has three variables: A, B, and C. In canonical form each term
should contain all variables of the function. The first term A is missing two variables;
therefore,
A = A(B + B’) = AB + AB’
This function is still missing one variable, so
A = AB(C + C’) + AB’(C + C’) = ABC + ABC’ + AB’C + AB’C‟
The second term B’C is missing one variable; hence,
B’C = B’C(A + A’) = AB’C + A’B’C
Combining all terms, we have
F = A + B’C= ABC + ABC’ + AB’C + AB’C’ + A’B’C
But AB’C appears twice, and according to theorem 1 (x + x = x), it is possible to
remove one of those occurrences. Rearranging the minterms in ascending order, we
finally obtain
F = A’B’C + AB’C’ + AB’C + ABC’ + ABC
= m1 + m4 + m5 + m6 + m7 = Σ(1, 4, 5, 6, 7)
2. Express the Boolean function F = xy + x’z as a product of maxterms.
Solution: First, convert the function into OR terms by using the distributive law:
F = xy + x‟z = (xy + x’)(xy + z)
= (x + x’)(y + x’)(x + z)(y + z)
= (x’ + y)(x + z)(y + z)
41
The function has three variables: x, y, and z. Each OR term is missing one variable;
therefore,
x’ + y = x’ + y + zz’ = (x’ + y + z)(x’ + y + z’)
x + z = x + z + yy’ = (x + y + z)(x + y’ + z)
y + z = y + z + xx’ = (x + y + z)(x’ + y + z)
Combining all the terms and removing those which appear more than once, we finally
obtain
F = (x + y + z)(x + y’ + z)(x’ + y + z)(x’ + y + z’)
= M0M2M4M5 = Π(0, 2, 4, 5)
1.11 OTHER LOGIC OPERATIONS
22n functions can be formed using n binary variables. Thus, for two variables,
n = 2, and the number of possible Boolean functions is 16. The truth tables for the 16
functions formed with two binary variables are listed in following Table. Each of the
16 columns, F0 to F15, represents a truth table of one possible function for the two
variables, x and y which are determined from the 16 binary combinations that can be
assigned to F. The 16 functions listed can be subdivided into three categories:
1. Two functions that produce a constant 0 or 1.
2. Four functions with unary operations: complement and transfer.
3. Ten functions with binary operators that define eight different operations: AND,
OR, NAND, NOR, exclusive‐OR, equivalence, inhibition, and implication.
Constants for binary functions can be equal to only 1 or 0.
The complement function produces the complement of each of the binary
variables.
A function that is equal to an input variable has been given the name transfer,
because the variable x or y is transferred through the gate that forms the
function without changing its value.
Out of ten functions, four functions (inhibition and implication) are used by
logicians, but are seldom used in computer logic.
In the remaining 6 functions, the AND and OR operators have been mentioned
in conjunction with Boolean algebra. The other four functions (NAND, NOR,
XOR, X-NOR) are used extensively in the design of digital systems.
42
1.12 DIGITAL LOGIC GATES
Logic Gate is a digital circuit which performs some logic functions. The logic
gates can be broadly classified in three categories:
Basic Gates – AND, OR, NOT
Universal Gates – NAND, NOR
Exclusive Gates - XOR, XNOR
Factors to be weighed in considering the construction of other types of logic gates are:
(1) The feasibility and economy of producing the gate with physical components,
(2) The possibility of extending the gate to more than two inputs,
(3)The basic properties of the binary operator, such as commutativity and
associativity, and
(4) The ability of the gate to implement Boolean functions alone or in conjunction
with other gates.
Extension of gates to multiple inputs:
The AND, OR gates can be extended to multiple inputs as they satisfy both
commutative and associative property. The NAND and NOR functions are
commutative, but they are not associative (i.e., (x ↓ y) ↓ z ≠ x ↓ (y ↓ z)), hence the
definition of the operation is to be modified slightly to extend the gate to have more
than two inputs. To overcome this difficulty, we define the multiple NOR (or NAND)
gate as a complemented OR (or AND) gate. Thus, by definition, we have
x ↓ y ↓ z = (x + y + z)‟
x ↑ y ↑ z = (xyz)‟
43
Positive and Negative Logic
The binary signal at the inputs and outputs of any gate has one of two values,
except during transition. One signal value represents logic 1 and the other logic 0.
Since two signal values are assigned to two logic values, there exist two different
assignments of signal values to logic levels.
Positive Logic: Choosing the high‐level H to represent logic 1 defines a positive
logic system.
Negative Logic: Choosing the low‐level L to represent logic 1 defines a negative
logic system.
44
Simplification of Boolean functions using algebraic method:
1. A+A‟B = (A+A‟)(A+B)
= 1. (A+B)
= (A+B)
2. AB+A‟B = B(A+A‟)
=B
3. AB+ABC = AB(1+C)
= AB
45