0% found this document useful (0 votes)
9 views

Lecture 1 - Introduction to Logic Circuits

The document provides an introduction to logic circuits and switching theory, defining logic circuits as electric circuits with binary inputs and outputs, and discussing the role of gates like AND, OR, and NOT. It contrasts analog and digital representations, highlighting the advantages of digital systems such as ease of design and greater accuracy, while also noting the limitations of digital systems in handling real-world analog quantities. Additionally, it covers number systems, including decimal, binary, octal, and hexadecimal, along with their conversions and significance in digital computing.

Uploaded by

EMMANEM
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Lecture 1 - Introduction to Logic Circuits

The document provides an introduction to logic circuits and switching theory, defining logic circuits as electric circuits with binary inputs and outputs, and discussing the role of gates like AND, OR, and NOT. It contrasts analog and digital representations, highlighting the advantages of digital systems such as ease of design and greater accuracy, while also noting the limitations of digital systems in handling real-world analog quantities. Additionally, it covers number systems, including decimal, binary, octal, and hexadecimal, along with their conversions and significance in digital computing.

Uploaded by

EMMANEM
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Digital Principles and Logic

Design
Introduction to Logic Circuits
Introduction to Logic Circuits

1 Logic Circuits and Switching Theory Defined

1.1 Logic Circuits


A Logic Circuit is an electric circuit whose output depends upon the input in a way that can
be expressed as a function in symbolic logic, it has one or more binary inputs (capable of assuming
either of two states, e.g., "on" or "off') and a single binary output. Logic circuits that perform the
basic logical functions are called gates. Basic logic gates include the AND gate, the OR gate, and the
NOT gate, which perform the logical functions AND, OR, and NOT. Logic circuits can be built from
any binary electric or electronic devices, including relays, electron tubes, solid-state diodes, and
transistors; the choice depends upon the application and design requirements. Modern technology
has produced integrated logic circuits, modules that perform complex logical functions. A major use
of logic circuits is in electronic digital computers.

1.2 Switching Theory


Switching Theory is the theory of circuits made up of ideal digital devices, including their
structure, behavior and design. It incorporates Boolean logic, a basic component of modern digital
switching systems. Switching is essential to telephone, telegraph, data processing, and other
technologies in which it is necessary to make rapid decisions about routing information.

2 Analog and Digital Representations


Analog representation of a quantity is a value of voltages, currents or meter movements
that are proportional to a value of that quantity. An example is the common mercury thermometer,
where the level of mercury varies with the temperature. Analog quantities have the characteristic
that can vary on a continuous range of values over a continuous interval of time.
DjgHal representation of a quantity is not by proportion to a quantity but by use of a
symbol, or a much common symbol a digit. A prominent example is a digital clock, as we know time
varies continuously, but for a digital clock, the display does not change continuously, rather it
changes per unit step say once per second or once per minute. To make it clear, digital
representation changes in discrete steps or a step by step process.

2.1 Analog and Digital Systems


An Analog System consists of devices that manipulate physical quantities that are
represented in analog form. Common analog systems are amplifiers, magnetic recording and
playback and even a simple dimmer switch.
A WgHal System is a combination of devices designed to manipulate logical information or
physical quantities represented in digital form. These devices are often electronic but they can also
be magnetic, mechanical, pneumatic or hydraulic. Examples are calculators and computers.

2.2 Advantages of Digital Systems


An increasing majority of applications in electronics and other technologies use digital
systems to perform operations that were once performed using analog systems. The reasons for the
shift to digital technology are:
1. Digital systems are easier to design.

2
Lecture I

2. Information storage is easy.


3. Accuracy and precision is greater.
4. Operation can be programmed.
5. Digital circuits are less affected by noise.
6. More digital circuitry can be fabricated on an IC.

2.3 Limitations of Digital System


The real world is mainly analog.

The phrase implies that almost all quantities to be measured and manipulated or controlled
are all analog. Thus, any digital system cannot be implemented with such quantities. To make
analog quantities to be used on digital system or the other thing, conversion is necessary. An analog
quantity is converted to digital by means of an Analog-to-Digital Converter (ADC) or a digital
quantity can be made analog by using a Digital-to-Analog Converter (DAC). Conversion from analog
to digital or vice versa has different techniques and will be discussed in Signal Processing.

3 Number Systems
Since digital systems use discrete data, numbers and alphanumeric characters are common
symbols that can be easily understood. Numbers comes in patterns of small increment of symbols
and obviously changes in discrete intervals (e.g. 1, 2, 3, 4, etc ...) the alphabet changes in discrete
interval too. Thus, the alphanumeric codes are the best to be used to represent any digital quantity.

3.1 The Number Representation


The value of a number can be represented by the sum of its place values. A dot(.) is used as
a marker of the origin (e.g. 123.4). The number 3 is the starting position or the zero position and
the values at the left of the dot are the positive positions, whereas the values at the right are the
negative places. To represent the value of a number an equation is used.

Where:
N is the value of the number
n is the place value of a digit of the number
r is the radix of the number
D is the value of a coefficient of the number

The radix or base of a number system is the amount or number of symbol used for that
number system.
Numbers also come in subscript indicating their radix. An exemption to this is the decimal
system which may not use subscript.

3.2 Decimal Number System


The decimal number system is the most common number system to all of us. It uses ten
symbols which are; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Thus, it has a radix or base of 10. It came from the Latin
word 'deci' meaning ten. Let us take the number 723.4, even an elementary student can say that this

3
Introduction to Logic Circuits

number is 7 one hundreds, 2 tens, 3 ones and 4 one-tenths. Using the previous definition of a
number, the number 723.4 is equal to 7 x 10 2 + 2 x 101 + 3 x 10° + 4 x 10- 1 .

3.3 Binary Number System

It is now clear how the values of a decimal numbers are known; similar ways are used to
other number systems. A prominent number system used in computers is the binary system. It uses
two symbols; 0 and 1, thus it has a radix of 2. The use of two symbols make the binary system very
popular to computers since it can represent an on or off, a presence or absence of current, a high or
low voltage which are the primary phenomenon inside a computer. Take the number 1001.01 2,
3 2 1 1
which is defined as 1 x 2 + 0 x 2 + 0 x 2 + 1 x 2° +Ox 2- + 1 x 2- . 2

3.3.1 Advantages
Logic operations are the backbone of any digital computer, although solving a problem on
computer could involve an arithmetic operation too. The introduction of the mathematics of logic
by George Boole laid the foundation for the modern digital computer. He reduced the mathematics
of logic to a binary notation of 'O' and 'l'. As the mathematics of logic was well established and had
proved itself to be quite useful in solving all kinds of logical problem, and also as the mathematics of
logic (also known as Boolean algebra) had been reduced to a binary notation, the binary number
system had a clear edge over other number systems for use in computer systems.
Yet another significant advantage of this number system was that all kinds of data could be
conveniently represented in terms of Os and ls. Also, basic electronic devices used for hardware
implementation could be conveniently and efficiently operated in two distinctly different modes.
For example, a bipolar transistor could be operated either in cut-off or in saturation very efficiently.
Lastly, the circuits required for performing arithmetic operations such as addition,
subtraction, multiplication, division, etc., become a simple affair when the data involved are
represented in the form of O's and l's.

3.3.2 The Byte

The smallest unit of information in a binary system is called a 'bit', which is short for a
binary digit. A byte is a string of eight bits. The 'byte' is the basic unit of data operated upon as a
single unit in computers. A computer word is again a string of bits whose size, called the 'word
length' or 'word size', is fixed for a specified computer, although it may vary from computer to
computer. The word length may equal one byte, two bytes, four bytes or be even larger. Another
unit is a 'nibble' in which it is a string of four bits or half-byte long. Large memories are often in
Megabytes, Gigabytes or sometimes Terabytes, the conversion is 1 kilobyte (kB) = 1024 bytes,
l Gigabyte (GB) = 1024 Megabytes and so on.

3.4 Octal and Hexadecimal Number Systems

Similar to decimal and binary systems, the octal and the hexadecimal system follow the
same summation definitions only a different radix. The octal and the hexadecimal systems are also
employed in computers, for the reason that the binary system is not that strong.
The octal system uses eight symbols; 0, 1, 2, 3, 4, 5, 6 and 7. It has a radix of 8. Example is
456.38 is equal to 4 x 8 + 5 x 8 + 6 x 8° + 3 x s- . Hence the hexadecimal system uses sixteen
2 1 1

symbols; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F. The letters A-Fare numerically equal to 10-15,

4
Lecture I

since 10-15 will have two symbols the letters are chosen instead. FACE.OF 16 is equal to F x 16 3 +
AX 162 + C X 161 +EX 16° + 0 X 16- 1 + F X 16-2.

Table 1: Table of Number System


Decimal Binary Octal Hexadecimal
0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 8
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F

Example 1

Consider an arbitrary number system with independent digits as 0, X and Y. What is the radix of this
number system? List the first ten numbers in this number system.

Solution
• The radix is three since there are three independent symbols used.
• The first ten numbers would be 0, X, Y, XO, XX, XY, YO, YX, YY and XOO.

3.5 The Decimal Equivalent


The decimal equivalent of a given number in another number system is given by the sum of
all the digits multiplied by their respective place values. The integer and fractional parts of the
given number should be treated separately.

3.5.1 Binary-to-Decimal Conversion

1. llOlz
11012 = 1 X
3
2 +1X 2 1
2 + 0 X 2 + 1 X 20 = 13
2. lllOlz
111012 = 1 X 24 + 1 X 23 + 1 X 2 2 + 0 X 21 + 1 X 20 = 29

3. 1001.0lz
1001.01 2 = 1 X 23 + 0 X 2 2 + 0 X 21 + 1 X 20 + 0 X 2- 1 + 1 X 2- 2 = 9.25

5
Introduction to Logic Circuits

3.5.2 Octal-to-Decimal Conversion


1. 123s
123s = 1 X 82 + 2 X 81 + 3 X 8° = 83
2. 765s
765s =7X 2
8 +6 X
1
8 + 5 X 8° = 501
3. 456.3s
456.3s =4 X 2 1
8 + 5 X 8 + 6 X 8° + 3 X 8-l = 302.375
3.5.3 Hexadecimal-to-Decimal Conversion
1. 35616
35616 =3 X 2
16 + 5 X
1
16 + 6 X 16° = 854
2. BAD016
BAD0 16 = 11 X 16 3
+ 10 X 2
16 + 13 X
1
16 + 0 X 16° = 47824

3. FACE.F16
FACE. F16 = 15 X 16 3 + 10 X 16 2 + 12 X 161 + 14 X 16° + 15 X 16-1 = 64206.9375
3.6 Decimal to Other Base Conversion
To convert a decimal number to another number system, just do a continuous division on
the number and the succeeding quotients until the last quotient is zero. List all the remainders
employing the first remainder as the least significant digit and the last remainder as the most
significant bit. This is for decimal numbers greater than one. For decimal numbers less than one,
employ the reverse process which is multiplication.

3.6.1 Decimal-to-Binary Conversion


1. 12
Quotients Remainders

12 = 11002

6
Lecture I

2. 425
Quotients Remainders

0 1
2 1 1
2 3 0
2 6 1
2 13 0
2 26 1
2 53 0
2 106 0
2 212 1
2 425

425 = 1101010012
3. 9.3125
For 9
Quotients Remainders

9 = 10012
For 0.3125
Product
Product Excess
without Excess
2 0.3125
2 0.625 0.625 0
2 0.25 1.25 1
2 0.5 0.5 0
0.0 1.0 1

0.3125 = 0.0101 2
Thus, 9.3125 = 1001.01012
3.6.2 Decimal-to-Octal Conversion

1. 12
Quotients Remainders

12 = 148

7
Introduction to Logic Circuits

2. 425
Quotients Remainders

0 6

~~~
8~

425 = 651 8
3. 9.3125
For9
Quotients Remainders

9 = 118
For 0.3125
Product
Product Excess
without Excess
8 0.3125
8 0.5 2.5 2
0.0 4.0 4

0.3125 = 0.248
Thus, 9.3125 = 11.248
3.6.3 Decimal-to-Hexadecimal Conversion
1. 425
Quotients Remainders

0 1
16 ~ lO➔A
16 26 9
16 425

425 = 1A916
2. 2640
Quotients Remainders

0 lO ➔A
16 10 5
16 165 0
16 2640

2640 = A5016

8
Lecture I

3. 24.1640625
For 24
Quotients Remainders

0 1
16u:==s
16~

24 = 1816
For 0.1640625
Product
Product Excess
without Excess
16 0.1640625
16 0.625 2.625 2
0.0 10.0 lO ➔A

0.1640625 = 0.2A16
Thus, 24.1640625 = 18.2A 16

3.7 Conversion of Binary to Octal or Hexadecimal


Conversion of binary to octal to hexadecimal is quite simple; to demonstrate how let us see
first the relationships of their bases. It can be shown that 2 3 = 8 and 24 = 16, thus it is clear that
three binary digits is equivalent to one octal digit, also four binary digits is equivalent to one
hexadecimal digit.

1. 100101010101110b

Octal
10010101010111012 = 001001010101011101
..___, ..___, .___, .___, .___, = 1125358 '-...-'
1 1 2 5 3 5

Hexadecjmal
1001010101011101 2 = ..__.....__.......__.....__...
1001010101011101 = 955D 16
9 5 5 D

2. 11101010101011012

Octal
1110101010101101 2 = 001110101010101101
. _ _ _ , '-_,_.I . . _ _ , . . _ _ , ' - . . . - ' ..___,
= 165255 8
1 6 5 2 5 5

Hexadecjmal
1110101010101101 2 = ..__......___...__.......__.....
111010101010 1101 = EAAD 16
E A A D

3. 101011010.1011112

Octal
101011010.101111 2 = 101011010
,.,__., ..___, ,.___, . 101111
..___, ..___, = 532.578
5 3 2 5 7

9
Introduction to Logic Circuits

Hexadecimal
101011010.101111 2 = ---.--
000101011010 .10111100
---.-----.-- ---.------.-- = 15A. BC16
1 5 A B C

3.8 Conversion of Octal or Hexadecimal to Binary

It is the same as the previous, one octal digit is three binary digits and one hexadecimal digit
is four binary digits.

Octal
1. 1675a
1675 8 = y
1 y6 y7 y5 = 1110111101 2
001110 111101

2. 754a
7548 = 7 ....,
...., 5 ....,
4 = 111101100 2
111101100

3. 513.53a
513.53 8 = y5 y1 y3 . y5 y3 = 101001011.101011 2
101 001 011 101 011

Hexadecimal
1. 9AB16
9AB 16 = 9
...., A
...., B
...., = 100110101011 2
10011010 1011

2. FlA816
F1A8 16 = F
y y
1 y
A y
8 = 1111000110101000 2
1111000110101000

3. A73.ED16
A73 . ED16 = y 7 y
A y 3 . y D = 101001110011.11101101 2
E y
1010 0111 0011 1110 1101

3.9 Conversion from Octal to Hexadecimal or vice versa

The conversion of this number system is done by converting it first to binary and then the
binary equivalent is then converted.

Octal to Hexadecimal
1. 1675a
16758 = y1 y6 y7 y5 = 1110111101 2 = -001110111101
--.-----.-- ---.--
= 3BD16
001110111 101 3 B D

2. 754a
7548 = 7 5 4 = 111101100 2 = 00011110 1100 = 1EC16
'-,J 1...,-1 y ---.-----.-----.--
111101100 1 E C

ID
Lecture I

3. 513.53a
513.53 8 = 5 1 3 . 5 3
'-,,.I '-,,.I '-,,.I '-,,,J 1..,.,1
= 101001011.101011 2 = 00010100 1011.1010 1100 = 14B.AC16 ..__......__......__......__......__....
101 001 011 101 011 1 4 B A C

Hexadedmal to Octal
1. 38D16
3BD16 = 3
'-,,,.I
B
y
D
y
= 1110111101 2 = 001110 111101 = 16758 ..___, ..___, ,.___, ,.___,
0011 1011 1101 1 6 7 5

2. lEC16
1EC16 = 1
'-,,,J
E
'-,,,J
C
'-,,,J
= 111101100 2 = 111101100 = 7548 ,.___,,.___,.___.

00011110 1100 7 5 4

3. 14B.AC16
14B.AC16 = y
1 4
.._.,
B
'-,,.I
. A
1...,-1
C
'-,,,J
= 101001011.101011 2 = 101001 011. 101011 ,.___, \ _ , _ I ,.___, ,.___, ..___,

0001 0100 1011 1010 1100 5 1 3 5 3


= 513.53 8
Example2

Assume an arbitrary number system having a radix of 5 and 0, 1, 2, L and M as its independent
digits. Determine the decimal equivalent of 12LM.Ll

Solution:
12LM.Ll 5 =l X 53 +2 X 5 2 + (L = 3) X 51 + (M = 4) X 5o + (L = 3) X 5- 1 +l X 5- 2 = 194.64
Example3

Assume a radix-32 arbitrary number system with 0-9 and A-Vas its basic digits. Express the mixed
binary number 110101.001 2 in this arbitrary number system.

Solution:
32 =2 5
thus, 5 bit binary is one symbol in this number system
110101.001 2 = 0000110101.
----,.......... ----,.......... 00100
----,.......... = ll. 4 32
1 21=L 4

4 Complements
Complements are used in digital computers for simplifying the subtraction operation for
logical manipulation. There are two types of complements for each base-r system: the radix
complement and the diminished radix complement. The first is referred to as r's complement and
the second as (r-l}'s complement

4.1 Diminished Radix Complement

Given a number Nin base r having n digits, the (r-l}'s complement of N is defined as
( r n l) - N. For decimal numbers,
- = 10 and l = 9, so the 9's complement of is r r - N

(lOn - 1) - N. For example, if n = 6 and we have 10 6 = 1,000,000 and 10 6 - 1 = 999,999. It


follows that the 9's complement of a decimal number is obtained by subtracting each digit from 9.

II
Introduction to Logic Circuits

The 9's complement of 546,700 is 999,999 - 546,700 = 453,299.


The 9's complement of 45,689 is 99,999 - 45,689 = 54,310.

For binary numbers, r = 2 and r- 1 = 1, so the l's complement of N is (2n - 1) - N. For


example, if n = 6 and we have 26 = 1000000 2 and 26 - 1 = 111111 2 . Thus, the l's complement of
a binary number is obtained by subtracting each digit from 1. However, the subtraction of a binary
number from 1 will only cause a change in bits. Thus, to obtain the l's complement of a binary
number, just change all l"s to O's and all O's to l's.

The l's complement of 1110101012 is 0001010102.


The l's complement of 1111101z is 00000102.

The (r-l)'s complement of octal or hexadecimal numbers is obtained by subtracting each


digit from 7 or F (decimal 15), respectively.

The 7's complement of 56347 8 is 21430 8 .


The lS's complement of F23E51&is DClA1&-

4.2 Radix Complement


Given a number Nin base rhaving n digits, the r's complement of Nis defined as rn - N for
N * 0 and O for N = 0. It follows that the r's complement is 1 more than the {r-l}'s complement
Thus, to obtain the r's complementjust add 1 to the {r-l}'s complement

The lO's complement of 546,700 is 453,300.


The lO's complement of 45,689 is 54,311.
The 2's complement of 111010101z is 00010101h
The 2's complement of 1111101z is 000001h
The 8's complement of 56347 8 is 21431 8 .
The 16's complement of F23E51&is DC1B1&-

5 Signed Binary Numbers


Integers are mostly used in order to represent vector quantities (e.g.+ for right side things
and - for left side thing), to simply represent them a positive number may be added a"+" sign or
the number itself, as it is understood as positive while a negative number is represented by a "-"
symbol of negation. However, by hardware limitations, a computer data must always be
represented by binary digits, or bits. It is customary to represent a sign with a bit placed at its
leftmost position. The convention is to make the sign bit "O" for positive and "1" for negative.
There is only one way to represent a signed-positive number, because it will make no
change if we used the leftmost bit as sign bit, since the sign bit is "O" for positive. For a negative
number, there are three ways in representing them. They are the signed-magnitude system and the
signed-complement system. For example, +8 will be represented by an eight-bit signed binary
number by 00001000, while - 8 can be represented in three ways:
In signed-magnitude representation: 10001000
In signed-l's complement representation: 11110111
In signed-2's complement representation: 11111000
In the signed-magnitude representation only the sign bit is changed, while in the signed-
complement system all bits including the sign bit is complemented.

12
Lecture I

6 Binary Codes
Codes are used to represent data in a computer and it must be in binary so that the
computer can understand. To take note binary codes are used not to change the meaning of the
quantity it represents but only to change the symbol for the convenience of computing.

6.1 Binary Coded Decimal


The binary coded decimal (BCD) is a type of binary code used to represent a given decimal
number in an equivalent binary form. BCD-to-decimal and decimal-to-BCD conversions are very
easy and straightforward. It is also far less cumbersome an exercise to represent a given decimal
number in an equivalent BCD code than to represent it in the equivalent straight binary form
discussed in the previous sections. The BCD equivalent of a decimal number is written by replacing
each decimal digit in the integer and fractional parts with its binary equivalent.

6.1.1 8421 Code or Natural BCD


Natural BCD or the 8421 code is a 4-bit weighted code where the weights of the bits are 1, 2,
4 and 8 from the LSB (Least Significant Bit) to the MSB (Most Significant Bit). It is the simplest and
the most popular binary coded decimal. This is used whenever decimal information is transferred
in and out of a digital system.
Table 2: Decimal to NBCD Conversion
Decimal NBCD
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001

Unpacked and Packed BCD Numbers


In the case of unpacked BCD numbers, each four-bit BCD group corresponding to a decimal
digit is stored in a separate register inside the machine. If a register is 8-bits or wider, the register
space is wasted. In the case of packed BCD numbers, two BCD digits are stored in a single eight-bit
register. The process of combining two BCD digits so that they are stored in one eight-bit register
involves shifting the number in the upper register to the left 4 times and then adding the numbers
in the upper and lower registers. The process is illustrated by showing the storage of decimal digits
'5' and '7':
• Decimal digit 5 is initially stored in the eight-bit register as: 0000 0101.
• Decimal digit 7 is initially stored in the eight-bit register as: 00000111.
• After shifting to the left 4 times, the digit 5 register reads: 0101 0000.
• The addition of the contents of the digit 5 and digit 7 registers now reads: 0101 0111.

13
Introduction to Logic Circuits

Example4

Represent the number 154 into its corresponding BCD code. How many bytes of register are
required to store this number, if the system stores this number as packed BCD? How about if
unpacked?

Solution
For packed BCD, each digit is 1 nibble only

------------
154 = 0001 0101 0100
1 5 4
154 is a 12-bit data in packed BCD, thus 2 bytes are required to store 154

For unpacked BCD, each digit is 1 byte data


154 = 00000001 00000101 00000100
1 5 4
154 is a 24-bit data in unpacked BCD, thus 3 bytes are required to store 154

6.1.2 5421 Code


The 5421 code is a 4-bit weighted code where the weights of the bits are 5, 4, 2 and 1
starting from the MSB to the LSB. In the 5421 code, if a number has more than one representation,
choose the code that uses the lower binary weight.
Table 3: Decimal to 5421 Code Conversion
Decimal 5421 Code
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1011
9 1100

6.1.3 7421 Code


The 7421 code is a 4-bit weighted code where the weights of the bits are 7, 4, 2 and 1
starting from the MSB to the LSB. In the 7421 code, for the number 7 use the representation with
the least number of l's.
Table 4: Decimal to 7421 Code Conversion
Decimal 7421 Code
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110

14
Lecture I

7 1000
8 1001
9 1010

6.1.4 5311 Code


The 5311 code is a 4-bit weighted code where the weights of the bits are 5, 3, 1 and 1
starting from the MSB to the LSB. In the 5311 code, if a number has more than one representation
use the representation with the least number of l's and use first the 1 from the extreme right.
Table 5: Decimal to 5311 Code Conversion
Decimal 5311 Code
0 0000
1 0001
2 0011
3 0100
4 0101
5 1000
6 1001
7 1011
8 1100
9 1101

6.1.5 4221 Code


The 4221 code is a 4-bit weighted code where the weights of the bits are 4, 2, 2 and 1
starting from the MSB to the LSB. This is also a self-complementing code, wherein changing the
value of the bit will result to the 9's complement of the number.
Table 6: Decimal to 4221 Code Conversion
Decimal 4221 Code
0 0000
1 0001
2 0010
3 0011
4 1000
5 0111
6 1100
7 1101
8 1110
9 1111

6.1.6 2421 Code or Aiken Code


The 2421 code is a weighted code where the weights of the bits are 2, 4, 2 and 1 starting
from the MSB to the LSB. This is also a self-complementing code, wherein changing the value of the
bit will result to the 9's complement of the number. This is also a reflected code, wherein if the
frequencies of the number 0-9 are of the same frequency then the bits 0 and 1 will be equal in
frequency.

15
Introduction to Logic Circuits

Table 7: Decimal to 2421 Code Conversion


Decimal 2421 Code
0 0000
1 0001
2 0010
3 0011
4 0100
5 1011
6 1100
7 1101
8 1110
9 1111

6.1.7 84-2-1 Code

The 84-2-1 code is a weighted code where the weights of the bits are 8, 4, -2 and -1 starting
from the MSB to the LSB. This is also a self-complementing code, wherein changing the value of the
bit will result to the 9's complement of the number. This is also a reflected code, wherein if the
frequencies of the number 0-9 are of the same frequency then the bits 0 and 1 will be equal in
frequency.
Table 8: Decimal to 84-2-1 Code Conversion
Decimal 84-2-1 Code
0 0000
1 0111
2 0110
3 0101
4 0100
5 1011
6 1010
7 1001
8 1000
9 1111

6.1.8 Excess-3 Code (XS3 Code) or Stibitz Code


The Excess-3 code is an unweighted code directly obtained by adding 3 (binary 0011) to the
8421 code. The excess-3 code is another important BCD code. It is particularly significant for
arithmetic operations as it overcomes the shortcomings encountered while using the 8421 BCD
code to add two decimal digits whose sum exceeds 9. Another significant feature that makes this
code attractive for performing arithmetic operations is that the complement of the excess-3 code of
a given decimal number yields the excess-3 code for 9's complement of the decimal number. As
adding 9's complement of a decimal number B to a decimal number A achieves A - B, the excess-3
code can be used effectively for both addition and subtraction of decimal numbers.

Table 9: Decimal to XS3 Code Conversion


Decimal Excess-3 Code
0 0011
1 0100

16
Lecture I

2 0101
3 0110
4 0111
5 1000
6 1001
7 1010
8 1011
9 1100

6.1.9 Excess-11 (XS11 Code) Code


The Excess-11 code is an unweighted code directly obtained by adding 11 (binary 01011)
to the 5-bit binary equivalent of a decimal number. This is also a self-complementing code.

Table 10: Decimal to XS11 Code Conversion


Decimal Excess-11 Code
0 01011
1 01100
2 01101
3 01110
4 01111
5 10000
6 10001
7 10010
8 10011
9 10100

6.1.10 2-out-of-S Code


The 2-out-of-5 code is a 5-bit code which has an error detection property. The code has
exactly 2 l's and 3 O's in it.

Table 11: Decimal to 2-out-of-5 Code Conversion


Decimal 2-out-of-5 Code
0 00011
1 00101
2 00110
3 01001
4 01010
5 01100
6 10001
7 10010
8 10100
9 11000

17
Introduction to Logic Circuits

6.1.11 Biquinary Code


The biquinary code is a 7-bit weighted code with weights 5, 0, 4, 3, 2, 1 and O starting from
the MSB to the LSB. It has an error detection property for which only 2 bits contain l's and 5 others
0. The first two bits indicate whether it is in the 0~4 or 5 ~9 range.

Table 12 : Dec1m
• al to B"1c umary Cd
o e Convers1on
Decimal Biquinary Code
0 01 00001
1 01 00010
2 01 00100
3 01 01000
4 0110000
5 10 00001
6 10 00010
7 10 00100
8 10 01000
9 10 10000

6.1.12 Reverse Biquinary Code


The biquinary code is a 6-bit weighted code with weights 8, 6, 4, 2, 0 and 1 starting from the
MSB to the LSB. It has an error detection property for which only 1 bit contains l's and 4 others 0
for the first 5 MSB. The LSB indicate whether it is odd or even.

Table 13: Decimal to Reverse Biquinarv Code Conversion


Decimal Reverse Biquinary Code
0 00001 0
1 000011
2 00010 0
3 00010 1
4 00100 0
5 00100 1
6 01000 0
7 01000 1
8 10000 0
9 10000 1

6.1.13 1-out-of-10 Code


The 1-out-of-10 code is the sparsest encoding for the decimal digits; it uses 10 codes out of
the 1024 possible codes. It is a 10-bit code wherein 1 bit only has l's while the other 9 are O's. it is
also a weighted code with weights 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 starting from the MSB to LSB.
Table 14: Decimal to 1-out-of-10 Code Conversion
Decimal 1-out-of-10 Code
0 1000000000
1 0100000000
2 0010000000

18
Lecture I

3 0001000000
4 0000100000
5 0000010000
6 0000001000
7 0000000100
8 0000000010
9 0000000001

Examples

Find the BCD code representations of the decimal number 5921.

Solution
Form Table 2 to Table 14

5 9 2 1
NBCD 0101 1001 0010 0001
5421 code 0101 1100 0010 0001
7421 code 0101 1010 0010 0001
5311 code 1000 1101 0011 0001
4221 code 0111 1111 0010 0001
2421 code 1011 1111 0010 0001
84-2-1 code 1011 1111 0110 0111
XS3 code 1000 1100 0101 0100
XS11 code 10000 10100 01101 01100
2-out-of-5 code 01100 11000 00110 00101
Biquinary code 1000001 1010000 0100100 0100010
Rev. Biquinary
001001 100001 000100 000011
code
1-out-of-10 code 0000010000 0000000001 0010000000 0100000000

6.2 Gray Code

The Gray code was designed by Frank Gray at Bell Labs and patented in 1953 for the
application for an optical shaft encoder. It is an unweighted binary code in which two successive
values differ only by 1 bit. Owing to this feature, the maximum error that can creep into a system
using the binary Gray code to encode data is much less than the worst-case error encountered in
the case of straight binary encoding. Table 15 lists the binary and Gray code equivalents of decimal
numbers 0-15. An examination of the four-bit Gray code numbers, as listed in Table 15, shows that
the last entry rolls over to the first entry. That is, the last and the first entry also differ by only 1 bit.
This is known as the cyclk property of the Gray code. Although there can be more than one Gray
code for a given word length, the term was first applied to a specific binary code for non -negative
integers and called the binary-reflected Gray code or simply the Gray code.

19
Introduction to Logic Circuits

Table 15: The Gray Code


Decimal Binary 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
15 1111 1000

6.2.1 Binary-Gray Code Conversion


A given binary number can be converted into its Gray code equivalent by going through the
following steps:
1. Begin with the most significant bit (MSB) of the binary number. The MSB of the Gray code
equivalent is the same as the MSB of the given binary number.
2. The second most significant bit, adjacent to the MSB, in the Gray code number is obtained by
adding the MSB and the second MSB of the binary number and ignoring the carry, if any. That is,
if the MSB and the bit adjacent to it are both '1', then the corresponding Gray code bit would be
a 'O'.
3. The third most significant bit, adjacent to the second MSB, in the Gray code number is obtained
by adding the second MSB and the third MSB in the binary number and ignoring the carry, if
any.
4. The process continues until we obtain the LSB of the Gray code number by the addition of the
LSB and the next higher adjacent bit of the binary number.

6.2.2 Gray Code-Binary Conversion


A given Gray code number can be converted into its binary equivalent by going through the
following steps:
1. Begin with the most significant bit (MSB). The MSB of the binary number is the same as the MSB
of the Gray code number.
2. The bit next to the MSB (the second MSB) in the binary number is obtained by adding the MSB
in the binary number to the second MSB in the Gray code number and disregarding the carry, if
any.
3. The third MSB in the binary number is obtained by adding the second MSB in the binary
number to the third MSB in the Gray code number. Again, carry, if any, is to be ignored.
4. The process continues until we obtain the LSB of the binary number.

20
Lecture I

6.2.3 Applications

1. The Gray code is used in the transmission of digital signals as it minimizes the occurrence of
errors.
2. The Gray code is preferred over the straight binary code in angle-measuring devices. Use of the
Gray code almost eliminates the possibility of an angle misread, which is likely if the angle is
represented in straight binary. The cyclic property of the Gray code is a plus in this application.
3. The Gray code is used for labeling the axes of Karnaugh maps, a graphical technique used for
minimization of Boolean expressions.
4. The use of Gray codes to address program memory in computers minimizes power
consumption. This is due to fewer address lines changing state with advances in the program
counter.
5. Gray codes are also very useful in genetic algorithms since mutations in the code allow for
mostly incremental changes. However, occasionally a one-bit change can result in a big leap,
thus leading to new properties.

6.3 Seven-Segment Display Code

Seven-segment displays (Figure 1) are very common and are found almost everywhere,
from pocket calculators, digital clocks and electronic test equipment to petrol pumps. A single
seven-segment display or a stack of such displays invariably meets our display requirement. There
are both LED and LCD types of seven-segment display. Furthermore, there are common anode-type
LED displays where the arrangement of different diodes and pin assignments, designated a, b, c, d,
e, f and g, is as shown in Figure l(a), and common cathode-type displays where the individual
diodes are interconnected as shown in Figure l(b). Each display unit usually has a dot point (DP).
The DP could be located either towards the left (as shown) or towards the right of the figure '8'
display pattern. This type of display can be used to display numerals from Oto 9 and letters from A
to F. Table 16 gives the binary code for displaying different numeric and alphabetic characters for
both the common cathode and the common anode type displays. A '1' lights a segment in the
common cathode type display, and a 'O' lights a segment in the common anode type display. Figure
2 shows the different characters displayed given the codes from Table 16.

g f AN a b g f CA a b

D D

e d AN c DP e d CA c DP
(a) (b)

Figure 1: Seven-Segment Display

21
Introduction to Logic Circuits

Table 16: Seven-Se!!lllent Display Code


Common-Anode type Common-Cathode type
'O' means ON '1' means ON
a b C d e f g DP a b C d e f g DP
0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 0
1 1 0 0 1 1 1 1 1 0 1 1 0 0 0 0
2 0 0 1 0 0 1 0 2 1 1 0 1 1 0 1
3 0 0 0 0 1 1 0 3 1 1 1 1 0 0 1
4 1 0 0 1 1 0 0 4 0 1 1 0 0 1 1
s 0 1 0 0 1 0 0 s 1 0 1 1 0 1 1
6 0 1 0 0 0 0 0 6 1 0 1 1 1 1 1
7 0 0 0 1 1 1 1 7 1 1 1 0 0 0 0
8 0 0 0 0 0 0 0 8 1 1 1 1 1 1 1
9 0 0 0 0 1 0 0 9 1 1 1 1 0 1 1
A 0 0 0 1 0 0 0 A 1 1 1 0 1 1 1
B 1 1 0 0 0 0 0 B 0 0 1 1 1 1 1
C 0 1 1 0 0 0 1 C 1 0 0 1 1 1 0
D 1 0 0 0 0 1 0 D 0 1 1 1 1 0 1
E 0 1 1 0 0 0 0 E 1 0 0 1 1 1 1
F 0 1 1 1 0 0 0 F 1 0 0 0 1 1 1

-
I
c::::::::::::J
I D
c::::::::::::J

c::::::::::::J
I -- --
D I D I
DJ
0 -
I o.D
□ c::::::::::::J
I DJ
□ -
D o.D
□ -
I

- --
c::::::::::::J

I I I D I -- - D D c::::::::::::J
I
DP

D I DP D I DJ I D DP I
□ -
c::::::::::::J □ c::::::::::::J
□ -

-- --
I I I I I-- - I
c::::::::::::J

I D
DJ I DP D I DJ I DJ I
□ - □ -
□ c::::::::::::J
□ -

I- -
c::::::::::::J
D D
c::::::::::::J

I -- --
I D I D
DJ
□ -
D DJ

□ -
I DJ
□ -
DDJ □ c::::::::::::J
D
Figure 2: Coded Seven-Segment Display

22
Lecture I

6.4 Alphanumeric Codes


Alphanumeric codes, also called character codes, are binary codes used to represent
alphanumeric data. The codes write alphanumeric data, including letters of the alphabet, numbers,
mathematical symbols and punctuation marks, in a form that is understandable and processable by
a computer. These codes enable us to interface input-output devices such as keyboards, printers,
VDUs, etc., with the computer. One of the better-known alphanumeric codes in the early days of
evolution of computers, when punched cards used to be the medium of inputting and outputting
data, is the 12-bit Hollerith code. The Hollerith code was used in those days to encode alphanumeric
data on punched cards. The code has, however, been rendered obsolete, with the punched card
medium having completely vanished from the scene.

6.4.1 Baudot Code


One of the first binary codes was the Baudot code; pronounce as 'baw dough', used in the
early teletype machines. A teletype machine is a typewriter like device that is used to send and
receive coded signal over a communications link. Whenever a key on the typewriter keyboard is
pressed, a unique code is transmitted to the receiving machine which recognizes and then prints
the corresponding letter, number or symbol. The Baudot code is sometimes called Telex Code and is
developed by a French postal engineer named Thomas Murray in 1875; he named the code after
Emile Baudot, an early pioneer in telegraph printing.

Table 17: The Baudot Code


Character Shift Binary Code
Letter Figure b4b3b2b1bo
A - 11000
B ? 10011
C 01110
D $ 10010
E 3 10000
F I 10110
G & 01011
H # 00101
I 8 01100
J ' 11010
K ( 11110
L ) 01001
M 00111
N 00111
'
0 9 00011
p 0 01101
Q 1 11101
R 4 01010
s be! 10100
T 5 00001
u 7 11100
V 01111
'
w 2 11001

23
Introduction to Logic Circuits

X I 10111
y 6 10101
,,
z 10001
Figure Shift 11111
Letter Shift 11011
Space 00100
Line Feed (LF) 01000
Blank (Null) 00000

Example6

What is the Baudot code representation of the phrase '2 Birds'?

Solution
From Table 17
11111
___...
Figure Shift
-----
11001 00100
2
..__... 11011
___...
space Letter Shift
1001101100010101001010100
___... ___... ___... ___... ..___,,_.,
B I R D S

6.4.2 ASCII (American Standard Code for Information Interchange)

The ASCII (American Standard Code for Information Interchange), pronounced 'ask-ee', is
strictly a seven-bit code based on the English alphabet. ASCII codes are used to represent
alphanumeric data in computers, communications equipment and other related devices. The code
was first published as a standard in 196 7. It was subsequently updated and published as ANSI X3.4-
1968, then as ANSI X3.4-l 977 and finally as ANSI X3.4-l 986. Since it is a seven-bit code, it can at the
most represent 128 characters. It currently defines 95 printable characters including 26 upper-case
letters (A to Z), 26 lower-case letters (a to z), 10 numerals (0 to 9) and 33 special characters
including mathematical symbols, punctuation marks and space character. In addition, it defines
codes for 33 nonprinting, mostly obsolete control characters that affect how text is processed.

Table 18: ASCII or ANSI X3.4-1986


b6bsb4 (Column)
b3b2b1bo (Row) 000 001 010 011 100 101 110 111
0000 NUL DLE SP 0 @ p p
0001 SOH DCl ! 1 A Q a q
,,
0010 STX DC2 2 B R b r
0011 ETX DC3 # 3 C s C s
0100 EOT DC4 $ 4 D T d t
0101 ENQ NAK % s E u e u
0110 ACK SYN & 6 F V f V
0111 BEL ETB ' 7 G w g w
1000 BS CAN ( 8 H X h X
1001 HT EM ) 9 I y i y
1010 LF SUB * J z j z
1011 VT ESC + '
K r k f
1100 FF FS
'
< L \ I I
1101 CR GS - -- M l m 1
1110 so RS > N A
n ~
1111 SI us I ? 0 0 DEL

24
Lecture I

With widespread use of computer technology, many variants of the ASCII code have evolved
over the years to facilitate the expression of non-English languages that use a Roman-based
alphabet. In some of these variants, all ASCII printable characters are identical to their seven-bit
ASCII code representations. For example, the eight-bit standard ISO/IEC 8859 was developed as a
true extension of ASCII, leaving the original character mapping intact in the process of inclusion of
additional values. This made possible representation of a broader range of languages. In spite of the
standard suffering from incompatibilities and limitations, ISO-8859-1, its variant Windows-1252
and the original seven-bit ASCII continue to be the most common character encodings in use today.

6.4.3 EBCDIC (Extended Binary Coded Decimal Interchange Code)


The EBCDIC (Extended Binary Coded Decimal Interchange Code), pronounced 'eb-si-dik', is
another widely used alphanumeric code, mainly popular with larger systems. The code was created
by IBM to extend the binary coded decimal that existed at that time. All IBM mainframe computer
peripherals and operating systems use EBCDIC code, and their operating systems provide ASCII and
Unicode modes to allow translation between different encodings. It may be mentioned here that
EBCDIC offers no technical advantage over the ASCII code and its variant ISO-8859 or Unicode. Its
importance in the earlier days lay in the fact that it made it relatively easier to enter data into larger
machines with punch cards. Since, punch cards are not used on mainframes anymore; the code is
used in contemporary mainframe machines solely for backwards compatibility. It is an eight-bit
code and thus can accommodate up to 256 characters. A single byte in EBCDIC is divided into two
four-bit groups called nibbles. The first four-bit group, called the 'zone', represents the category of
the character, while the second group, called the 'digit', identifies the specific character.

Table 19: EBCDIC


b3b2b1bo Column)
0 .--< 0 .--< 0 .--< 0 .--< 0 .--< 0 .--< 0 .--< 0 .--<
b7b6bsb1 0 0 .--< .--< 0 0 .--< .--< 0 0 .--< .--< 0 0 .--< .--<
0 0 0 0 .--< .--< .--< .--< 0 0 0 0 .--< .--< .--< .--<
(Row) 0 0 0 0 0 0 0 0 .--< .--< .--< .--< .--< .--< .--< .--<

0000 NUL SOH STX ETX PF HT LC DEL SMM VT FF CR so SI


0001 OLE DCl DC2 DC3 RES NL BS IL CAN EM cc IFS !GS IRS !US
0010 OS sos FS BYP LF EOB PRE SM ENQ ACK BEL
0011 SYN PN RS UC EOT DC4 NAK SUB
0100 SP ¢ < ( + I
0101 & ! $ * ) ; A

0110 - I '
% - > ?
0111 : # @ ' = "
1000 a b C d e f g h i
1001 j K I m n 0 p q r
1010 ~ s t u V w X y z
1011
1100 { A B C D E F G H I
1101 } J K L M N 0 p Q R
1110 \ s T u V w X y z
1111 0 1 2 3 4 5 6 7 8 9

25
Introduction to Logic Circuits

Example7

Represent the phrase 'The Gnome' in 8-bit ASCII.

Solution
Since ASCII is a 7-bit code, just add another bit, in this example we use 'O'
From Table 18
01010100 01101000 0110010100100000 0100011101101110 011011110110110101100101
T h e Space(SP) G n 0 m e

Example8

Represent the phrase 'The Gnome' in EBCDIC.

Solution
From Table 19
1110001110001000 10000101010000001100011110010101100101101001010010000101
T h e Space (SP) G n 0 m e

6.4.4 Unicode
Unicode, developed jointly by the Unicode Consortium and the International Organization
for Standardization (ISO), is the most complete character encoding scheme that allows text of all
forms and languages to be encoded for use by computers. It not only enables the users to handle
practically any language and script but also supports a comprehensive set of mathematical and
technical symbols, greatly simplifying any scientific information exchange. The Unicode standard
has been adopted by such industry leaders as HP, IBM, Microsoft, Apple, Oracle, Unisys, Sun, Sybase,
SAP and many more.

6.5 Digital Signal Transmission


One of the most common operations that occur in any digital system is the transmission of
information from one place to another. The information can be transmitted over a distance as small
as a fraction of an inch on the same circuit board, or over a distance of many miles when an
operator at the computer terminal is communicating with a computer in another city. The
information that is transmitted is in binary and is generally represented as voltages at the outputs
of the sending circuit that are connected to the inputs of the receiving circuit.

6.5.1 Parallel Transmission


Parallel transmission which is also parallel-by-bit or serial-by-character is a simultanneous
transmission of digital codes in multiple number of channels. Figure 3 shows how the transmission
of the letter 'R' (ASCII 1010010) from the sender to the reciever where each bit is designated its
own channel.

26
Lecture I

__11[_
MSB Os Is MSB
0
Os __11[_
Is
04 0
l4
03 0 '3
02 12
__11[_
01 0
11
LSB Oo lo LSB

Station A Station B
Figure 3: Parallel Transmission

6.5.2 Serial Transmission


Serial transmission is the transmission of digital codes in a single channel. Each bit is sent
one at a time. Figure 4 show the sending of the letter 'R' (ASCII 1010010). The LSB is sent first
followed by the next LSB up to the MSB. There are two types of serial transmission, Synchronous
and Asynchronous which will be discussed in detail in Digital Communications.

0 0
Output i---..:...____:;;;;;;;;;;;;:_____:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:____,:;;;;;;;;;;;;;;;:-i In put

Station A Station B
Figure 4: Serial Transmission

6.6 Error Control


A digital communication channel may be a few centimeters or as long a several thousand
kilometers and a transmission medium may be as simple as a pair of wires or as complex as
microwaves, satellites or a fiber optic system. Therefore, it is inevitable that errors will occur and it

27
Introduction to Logic Circuits

is necessary to develop error-control procedures. Transmission errors are cause by electrical


disturbances whether it is natural or man-made.

6. 7 Error Detection
Error detection is the process of monitoring data transmission and determining when
errors have occurred. Error detection techniques neither correct nor identify which bit are in error
- they indicate only when an error has occurred. The purpose of error detection is not to prevent
errors from occurring but to prevent undetected errors from occurring.
The most common form of error detection is Redundancy Checking Duplicating each data
for the purpose of error detection is called Redundancy While, adding bits for the sole purpose of
error detection is called Redundancy Check

6.7.1 Vertical Redundancy Check (VRC)


It is the simplest error detection scheme generally referred to as character parity or simply
parity. A parity bit is added at the end of each character of the message. The parity bit indicates
whether the number of l's is odd or even. It is called odd parity and even parity respectively. Table
20 show the addition of the parity bit for the word 'LOGIC' (in ASCII) in the form of both odd and
even parity. For odd parity if the number of l 's is an odd number the parity bit is 0, while for even
parity if the number of l's is odd the parity bit is 1.

Table 20: Parity for the word LOGIC


Odd Parity Even Parity
Pa rity ASCII with Parity ASCII w ith
Character Original ASCII Character Original ASCII
Bit Parity Bit Bit Parity Bit
L 1001100 0 01001100 L 1001100 1 11001100
0 100 1111 0 0100 1111 0 100 1111 1 11001111
G 100 0111 1 1100 0111 G 100 0111 0 0100 0111
I 100 1001 0 0100 1001 I 100 1001 1 11001001
C 100 0011 0 0100 0011 C 100 0011 1 1100 0011

There are other forms of parity such as Marking Parity in which the parity bit is always '1', No
Parity in which the parity bit is not sent to the receiver and Ignored Parity in which the parity bit is
always 'O'.

6.7.2 Checksum
Checksum is another relatively simple form of redundancy error checking where each
character has a numerical value assigned to it. The characters within the message are combined
together to produce an error checking character (checksum), which can be as simple as the
arithmetic sum of the values of all characters in the message. The checksum is appended at the end
of the message. The receiver replicates this method and determines its own checksum. The receiver
compares this to the received checksum, if they are the same it is assumed that no error has
occurred.

28
Lecture I

6. 7.3 Longitudinal Redundancy Check (LRC)


Longitudinal Redundancy Check or sometimes called message parity, adds an additional
character, the Block Check Character (BCC) to the end of the message of data. The BCC uses parity
on each bit position for each character in the message. The group that comprises the message is
called the block or frame of the data. The bit sequence for the LRC is called frame check sequence
(FCS) or block check sequence (BCS). Table 21 shows the generation of the BCC for the word
'LOGIC' in ASCII, the VRC used even parity and LRC used odd parity.

Table 21: LRC of the word LOGIC


Character L 0 G I C LRC
bo 0 1 1 1 1 1
A b1 0 1 1 0 1 0
s b2 1 1 1 0 0 0
C b3 1 1 0 1 0 0
I b4 0 0 0 0 0 1
I bs 0 0 0 0 0 1
b6 1 1 1 1 1 0
Parity (VRC) 1 1 0 1 1 1

As seen from Table 21 the original frame/block for the word 'LOGIC' using even parity VRC
is 11001100 11001111 01000111 11001001 11000011 which is a 5-byte data, and
L O G I C
appending the block check character the block check sequence is now a 6-byte data
11001100 11001111 01000111 11001001 11000011 10110001
L 0 G C BCC

6.7.4 Cyclic Redundancy Check


The most reliable redundancy error detection is a convolutional convolution scheme called
cyclic redundancy check (CRC). The most common CRC code is the CRC-16 where the block check
sequence is 16 bits long. With CRC, the entire data stream is treated as a long continuous binary
number. Because the BCS is separate from the message but is transported within the same
transmission, CRC is considered a systematic code. A CRC block check character is the remainder of
a binary division process. A data message polynomial G(x) is divided by a unique generator
polynomial function P(x), the quotient is discarded, and the remainder is truncated to 16 bits and
appended to the message as a BCS. With CRC generation, modulo-2 division is used, where the
remainder is derived from exclusive OR operation (XOR). An XOR function gives '1' if the odd
numbers of input are high or '1', i.e. 0, 0, 1 or 0, 1, 0 etc., otherwise it gives 'O'.
Mathematically CRC is expressed as
G(x)
P(x) = Q(x) + R(x)
Where G(x) is the message polynomial, P(x) is the generator polynomial, Q(x) is the
quotient and R(x) is the remainder. For CRC-16 the generator polynomial is x + x + x + x .
16 15 2 0

The number of bits in the CRC code is equal to the highest exponent of the generator polynomial.

Example9

Determine the BCS for the following data and CRC generating polynomials:
Data G(x) = x + x + x + x + x + x = 10110111
7 5 4 2 1 0

29
Introduction to Logic Circuits

CRC P(x) =x 5 4
+x +x +x 1 0
= 110011
Solution
First, multiply G(x) by the number of bits in the CRC code, which is 5 from x 5. Or just simply add 5
bits at the end of the message. Then use modulo-2 division

1 1 0 1 0 1 1 1
1 1 0 0 1 1 1 0 1 1 0 1 1 1 0 0 0 0 0
1 1 0 0 1 1
1 1 1 1 0 1
1 1 0 0 1 1
0 1 1 1 00 1
1 1 0 10 1
0 10 10 0 0
10 01 1 1
0 11 1 1 0
1 01 0 1 1
1 1 1 0 1 0
1 1 0 0 1 1
0 1 0 0 1 --+CRC
Now, the CRC is appended to the data and give the following data stream
10110111 01001
BCS = ---..---
data CRC
At the receiver, the data stream is again divided by P(x) to check if there were any errors.

1 1 0 1 0 1 1 1
1 1 0 0 1 1 1 0 1 1 0 1 1 1 0 1 0 0 1
1 1 0 0 1 1
1 1 1 1 0 1
1 1 0 0 1 1
0 1 1 1 0 1 0
1 1 0 0 1 1
0 1 0 0 1 1 0
1 1 0 0 1 1
1 0 1 0 1 0
1 1 0 0 1 1
1 1 0 0 1 1
1 1 0 0 1 1
0 0 0 0 0
Remainder= 0, th en there were no
transmission error

30
Lecture I

Note: the sender and the receiver must have an agreement, that's why standards has been used, on
what generating polynomial shall they use for error detection

6.8 Error Correction

Error correction is the process of determining when an error has occurred and what to do
with it. In the modern data communications world two error correction methods are widely used:
Retransmission and Forward Error Correction.

6.8.1 Retransmission

Retransmission, as the name implies, is when a receive station requests the transmit station
to resend a message ( or a portion of a message) when the message is received in error.
Retransmission is often called ARQ, which is an old radio term that means automatk repeat request
or automatk retransmjssjon request ARQ is probably the most reliable error correction method
although it is not necessary the most efficient. There are two basic types of ARQ: discrete and
continuous. Discrete ARQ uses acknowledgements. There are two types of acknowledgements:
positive and negative. Positive acknowledgement (ACK) is the destinations response to an error-
free message while negative acknowledgement (NAK) for messages with error. Continuous ARQ on
the other hand allows the destination to asynchronously request the retransmission of a specific
frame (or frames) of data and still be able to reconstruct the entire message once all frames have
been successfully transported through the system.

6.8.2 Hamming Code

Forward Error Correction (FEC) is the only error correction scheme that actually detects
and corrects transmission errors when they are received without requiring a retransmission. The
most popular FEC is the Hamming code. The Hamming code was developed by Richard W.
Hamming. The Hamming code is an error-correcting transmission error in synchronous data
streams. However, Hamming code can only correct single bit errors. Hamming bits (or error bits)
are placed at random locations on the message. The sender and the receiver must agree on where
the Hamming bits are placed. Normally, Hamming bits are located on the 1, 2, 4, 8, and 16 ... bit
positions. To calculate how many Hamming bits are required for a code the expression to use is:
2n :2'. m + n + l
where n is the number of Hamming bits and m is the number of bits in a code.
To determine the state of each hamming bits, express all bit positions that contain a logic '1'
in their n-bit binary number and XOR them together.

Example 10

For a 16-bit string of 1100 0101 0011 0010, determine the number of Hamming bits required,
arbitrarily place the Hamming bits in the data string, determine the logic condition of each
Hamming bit, assume a single transmission error, and prove that the Hamming code will
successfully detect the error.

Solution
Substituting m = 16, for n = S
2 5
= 32 > 16 + S + 1 = 22
31
Introduction to Logic Circuits

Thus 5 Hamming bits are sufficient, and the total number of bits to be sent is 21 (16 + 5).

Arbitrarily placing the Hamming bits on positions 1, 2, 4, 8 and 16


21 20 19 18 17 16 15 14 1 3 12 11 10 9 8 7 6 5 4 3 2 1
l"'-'\l"'-'\l"'-'\l"'-'\l"'-'\l"'-'\l"'-'\l"'-'\l"'-'\l"'-'\l"'-'\l"'-'\l"'-'\l"'-'\l"'-'\l"'-'\l"'-'\l"'-'\r'-t.l"'-'\I"'-'\

11 0 0 0 H l 0 1 0 0 l lH00lH0HH

Logic conditions of each Hamming bit


Bit Position Binary number
5 00101
9 01001
10 01010
13 01101
15 01111
20 10100
21 10101
XOR 00101
Now, the 21-bit Hamming code is
H H H H H
I"'-'\ I"'-'\ I"'-'\ r'-1 I"'-'\
11000 0 10100110 00110 0 1

Assuming that during transmission an error occurred in position 10.


11000010100 0 100011001 '-,.J
error
At the receiver, to determine the bit position in error, extract the Hamming bits and XOR them with
the binary code for each data bit that contains logic '1'.

Bit Position Binary number


Hamming Bit 00101
5 00101
9 01001
13 01101
15 01111
20 10100
21 10101
XOR 01010
Therefore bit position 10 contains an error.

32

You might also like