Professional Documents
Culture Documents
Full Ebook of Digital Logic Design Devices and Circuits by Gamal El Sheikh 9ed 9Th Edition Gamal El Sheikh Online PDF All Chapter
Full Ebook of Digital Logic Design Devices and Circuits by Gamal El Sheikh 9ed 9Th Edition Gamal El Sheikh Online PDF All Chapter
https://ebookmeta.com/product/color-atlas-of-human-gross-
pathology-gamal-dawood/
https://ebookmeta.com/product/lectures-on-digital-design-
principles-river-publishers-electronic-materials-circuits-and-
devices-1st-edition-pinaki-mazumder/
https://ebookmeta.com/product/the-sheikh-ceo-1st-edition-yasar-
jarrar/
https://ebookmeta.com/product/text-constructs-1st-edition-omar-
sheikh-al-shabab/
Introduction to Logic Circuits Logic Design with
Verilog 3rd Edition Brock J. Lameres
https://ebookmeta.com/product/introduction-to-logic-circuits-
logic-design-with-verilog-3rd-edition-brock-j-lameres/
https://ebookmeta.com/product/partisan-universalism-essays-in-
honour-of-ato-sekyi-otu-gamal-abdel-shehid/
https://ebookmeta.com/product/programming-logic-and-design-
comprehensive-9th-edition-joyce-farrell/
https://ebookmeta.com/product/secret-documents-of-intelligence-
branch-on-father-of-the-nation-bangladesh-bangabandhu-sheikh-
mujibur-rahman-volume-8-1964-1st-edition-sheikh-hasina-editor/
https://ebookmeta.com/product/secret-documents-of-intelligence-
branch-on-father-of-the-nation-bangladesh-bangabandhu-sheikh-
mujibur-rahman-volume-10-1966-1st-edition-sheikh-hasina-editor/
Digital Logic Design-I:
Devices and Circuits
(9th Edition)
by
Gamal El-Sheikh
Cairo 2023
G.A. El-Sheikh Digital Logic Design I: Devices and Circuits i
G.A. El-Sheikh
Cairo 2023
Copyright, 2023
The copyright of this book belongs to the author under the terms of the international
copyrights acts. All rights reserved. No part of this publication may be reproduced, stored in a
retrieval system, or transmitted in any form or by any means, electronic, mechanical,
photocopying, recording, or otherwise, without written permission of the Author.
ISBN:
dlogic100a
i
G.A. El-Sheikh Digital Logic Design I: Devices and Circuits ii
Preface
The huge technological developments and ever-increasing human requirements motivated
many of the manufacturers to develop real world applications using digital systems and nao-
electronics. The digital systems are based on logical circuits and logical devices in addition to
pertinent application software. Thus, this book is devoted to provide both understanding of
the basic principles of digital logic design, and how these fundamental principles can be
applied in the building of digital and complex microprocessor circuits using current
technologies. Although the basic principles of digital logic design have not changed, the
design process and the implementation of the circuits are ever-changing. With the advances in
fully integrated modern computer aided design (CAD) tools for logic synthesis, simulation,
and implementation of circuits in programmable logic devices (PLDs) such as field
programmable gate arrays (FPGAs), it is now possible to design and implement complex
digital circuits very easily and quickly.
A traditional approach of introducing the basic principles and theories of logic design includes
the building of separate combinational and sequential components. These individual
components and the way of its utilization to build microprocessors are ultimate goals in
digital circuits. One primary goal of this book is to go beyond the logic principles, and the
building of individual components. In addition, these principles are utilized with the
individual components and combined together to create data paths and control units, and
finally the building of real dedicated custom microprocessors and general-purpose
microprocessors.
With any of the available CAD tools and the FPGA hardware development kits, students or
trainee can actually implement these circuits and justify its execution operation both in
software simulation and in hardware. The book contains many interesting examples with
complete circuit schematic diagrams that can be coded in any of the available simulation
software and implementation in hardware. With the hands-on exercises, the students or trainee
can learn not only the principles of digital logic design, but also in practice, how circuits are
implemented using current technologies. The book is divided into two parts; the first part is
devoted to basic principles and combinational networks while the second is devoted to
sequential circuits and pertinent applications.
The learning objectives of the first part of the book include the following:
Recognize the different numbers' systems and codes in addition to mathematical
operations that can be carried with each.
Describe the elements and characteristics that make up logic families; RTL, DTL, TTL,
CMOS.
Recognize the types of basic logic gates, universal logic gates and special logic gates in
addition to different logic circuits used in digital equipment.
Identify combined logic gates to build circuits and interpret their respective operation
via logic functions and Truth Tables.
Design and realize addition and subtraction circuits, comparators, and special purpose
circuits.
Design and realize combinational circuits including encoders, decoders, multiplexers,
demultiplexers in addition to real case studies.
Design and realize combinational circuits to achieve any of the real world operations;
starting from the verbal description, truth table, logic expressions and logic circuit.
Conduct experiments with any of the logic circuits (basic or designed) within the
laboratory and validate its performance with the help of laboratory instruments.
dlogic100a
ii
G.A. El-Sheikh Digital Logic Design I: Devices and Circuits iii
In this edition, many of the Figures had modified to be better in addition to some illustrating
examples and extra real applications for different combinational networks. In addition,
appendices are added to cover the digital principles of system design towards good
understanding and laboratory experiments.
dlogic100a
iii
G.A. El-Sheikh Digital Logic Design I: Devices and Circuits iv
Table of Contents
Preface
1- Introduction 1
1.1 History of Computational Fabrics 1
Evolution of Electronic Digital Devices
Basic Digital System Concepts
Digital System Design
Hierarchical System Design
1.2 Digital Systems 3
Levels of Integrated Circuits
Types of VLSI Chips
Digital Systems
Digital System Design Levels
Advantages of Digital Systems
Analog vs. Digital Systems
Building binary digital solutions to computational problems
Hardware Description Language (HDL)
Embedded Digital System
A Wireless Microsensor System
Temporal Representations of Electronic Signals:
Stored Program Digital Computer
Digital Computer Basic Operation
dlogic100a
iv
G.A. El-Sheikh Digital Logic Design I: Devices and Circuits v
Signed Magnitude
1’s Complement
2’s Complement
Arithmetic Operations with Signed Numbers
Operations with Negative Numbers 46
Two’s Complement Motivation
2.7.4 Octal Arithmetic 48
Octal Addition
Octal Subtraction
2.7.5 Hexadecimal Arithmetic 49
Hexadecimal Addition
Hexadecimal Subtraction
2.8 Binary Multiplication and Division 53
2.9 Codes 55
2.9.1 Numerical (Binary) Codes 55
Classifications of Binary Codes
2.9.2 Binary-Coded Decimal (BCD) 56
BCD in Electronics
Packed BCD
BCD Conversion
BCD Addition
BCD Subtraction
Comparison with pure binary
Disadvantages
2.9.3 Gray Code 63
Binary to gray code conversion
Gray code to binary conversion
2.9.4 Excess-3 Code 65
Addition of two numbers in Excess-3 Code
2.9.5 Bi-quinary coded decimal Code; Decoding 66
2.9.6 Character (Alphanumeric) Codes 68
2.9.6.1 EBCDIC Code
2.9.6.2 ASCII Code
Parity Method
Cyclic Redundancy Check
Background
2.9.7 Error Detection and Correction 71
2.10 Binary Number System Applications 74
2.10.1 Binary Numbers in Electronics
2.10.2 Binary Bits of Zeros and Ones
2.10.3 Analogue Voltage Output
2.10.4 Digital Voltage Output
2.10.5 Digital Logic Levels
2.11 Exercises: Numbers' Systems and Codes 77
3- Logic Gates 79
3.1 Binary Logic 80
3.2 Logic Operations 81
3.2.1 Inversion (NOT) operation
3.2.2 OR Operation
dlogic100a
v
G.A. El-Sheikh Digital Logic Design I: Devices and Circuits vi
dlogic100a
vi
G.A. El-Sheikh Digital Logic Design I: Devices and Circuits vii
dlogic100a
vii
G.A. El-Sheikh Digital Logic Design I: Devices and Circuits viii
References 205
Appendices 206
Appendix-A: Digital Principles of System Design Understanding 206
Appendix-B: Circuits' and Devices' Symbols 213
Appendix-C: Electronic Devices and Circuits: Significant Equations 220
Appendix-D: Laboratory Experiments and Assignments 228
Preface
Abstract: Logic Laboratories
Measuring Instruments
Lab-01: Basic Electronic Instruments and Measurements 234
Lab-02: Oscilloscope and Function Generator 239
Lab-03: Voltage, Current, Resistance and Power Measurements 243
Lab-04: Inverters 259
Lab-05: AND Gates 260
Lab-06: OR Gates 262
Lab-07: NAND and NOR Gates 264
Lab-08: XOR and XNOR Gates 266
Lab-09: Half- and Full-Adders 268
Lab-10: Half- and Full-Subtractors 269
Lab-11: 1’S Complement Adder /Subtractor 270
Lab-12: 2's Complement Adder/Subtractor 271
Lab-13: Multiplexers and Demultiplexers 272
Appendix-E: List of 7400 Series Integrated Circuits 274
E.1 Integrated Circuits Functioning
E.2 Integrated Circuits Pin Configuration
Appendix-F: List of 4000 Series Integrated Circuits 307
F.1 Integrated Circuits Functioning
F.2 Integrated Circuits Pin Configuration
dlogic100a
viii
G.A. El-Sheikh Digital Logic Design I: Devices and Circuits 1
1- Introduction
This book is devoted to provide both an understanding of the basic principles of digital logic
design, and how these fundamental principles can be applied in the building of complex
digital circuits using current technologies. Although the basic principles of digital logic
design have not changed the design process and the implementation of circuits are ever-
changing. With the advances in fully integrated modern computer aided design (CAD) tools
for logic synthesis, simulation, and the implementation of circuits in programmable logic
devices (PLDs) such as field programmable gate arrays (FPGAs), it is now possible to design
and implement complex digital circuits very easily and quickly. That is, the book has the
objective to enable readers grasping;
1- The concept and features of digital systems
2- Binary numbers and concepts analysis,
3- Number base conversion, complements and codes,
4- Digital logic gates, Integrated circuits and families,
5- The Boolean Algebra and Boolean functions with applications in logic circuits design,
6- The KMap method with different variables and applications in logic circuits design,
7- POS and SOP simplifications and applications in logic circuits design,
8- Design and realization of combinational logic circuits, including adders/subtractors
and code conversions, Decoders and Encoders, Comparators, Multiplexers and
Demultiplexers, and
9- Design and realization of sequential logic circuits starting by flip-flops towards
registers and counters with different applications.
The Evolution of Electronic Digital Devices can be described by the following stages;
Individual gates constructed from vacuum tubes and discrete passive components (e.g.,
resistors and capacitors).
Individual gates constructed from transistors and discrete passive components.
Integrated circuits (IC) consisting of several transistors, passive components fabricated
in a single package of semiconductors.
IC's are also called chips.
The hierarchy that clarifies the Basic Digital System Concepts including Embedded Systems
Technologies is shown in (Fig. 1.1), where;
• Levels of design abstraction and hierarchy
– System (behavioral) level; highest level
– Register level; widely used for design in industry today
– Gate level; level we will deal with most in this class
– Transistor level; lowest level
• Top-down design: Begins at system level and moves toward transistor level
• Typical way for complex digital systems to be designed in industry
– CAD tools can synthesize lower levels of design abstraction from higher level descriptions
• The point of logic design necessitates CAD tools with matured designer
SOC
Programmable Mixte
ASIC / Logic Device
Processor
Technology
ASSP (PLDs)
Analog signals are continuous and all possible values are represented (e.g. temperature
sensors, pressure sensors, …) while digital signals are used to represent a finite number of
discrete values. In addition, digital circuits and systems can be used to process both analog
and digital signals, but not vice versa.
Digital electronics involves circuits that have exactly two possible states either 0 or 1. That is,
the electronic circuit operation can be described in terms of its voltage levels; one level is
more positive than the other (corresponding to 1/H/T and zero/L/F, respectively)
Logic Conventions
The use of 0 (F) and 1(T) must be associated with the H and L voltages. It does not
matter which way it is done.
If 1(T) is assigned to H and 0(F) to L we say we are using the positive logic convention.
If 0(F) is assigned to H and 1(T) to L we say we are using the negative logic
convention.
Digital IC is constructed using numerous transistors and resistors to perform a given logic
operation, where the transistor is used as an electronic switch. Buffer is used to deliver the
necessary load current without affecting the control circuit.
Basic Characteristics
Signals can assume only a discrete number of values, usually two.
For two-valued systems, it is usual to designate the two signal voltages as L and H (for
Low and High) instead of referring to them by the actual voltages of the signals.
SSI and MSI devices are also called standard chips in textbooks.
Large and Very Large Integrated Circuits (LSI and VLSI): Millions of transistors
interconnected form complete systems (e.g., a microprocessor).
VLSI devices have hundreds to thousands of millions of transistors on a single chip.
The number of transistors that can be put on a single chip has been doubled every 1.5 to 2
years.
Digital Systems
Most general model of a digital system Fig. 1.4
‒ Often referred to as General Sequential Logic (Huffman
model)
‒ It consists of: Combinational logic that performs logical
operations and Memory elements that stores data
‒ Combinational Logic:
• Control Logic
• Arithmetic/Logic Unit (ALU)
• Multiplexers (MUX)
‒ Sequential Logic:
• Program Memory (MEM)
• Program Counter (PC)
• Address Register (AR)
• Data Register (DR)
• Input Register (IN)
• Output Register (OR)
• Accumulator (AC)
• ALU Carry Register (C)
• Instruction Register (IR)
• Timing Counter (TC)
Continuous time varying Discrete signals sampled in time has two possible values:
voltages and/or currents 0V, low, false (logic 0)
5V, high, true (logic 1)
i.e. it is represented by binary values; 1/0, True/False, Hot/Cold,
On/Off, etc.
Basic elements of analog Basic elements of digital circuits: Logic gates:
circuits: AND
• Resistors OR
• Capacitors NOT
• Inductors
• Transistors
Has ambiguity (different Has only one interpretation
interpretations)
Have additional data added to it to allow for detection and
correction of errors
Can be transmitted over a medium that introduces errors that are
corrected at receiving end
Can be used to process both analog and digital signals
Fig. 1.6
Fig. 1.7
VHDL has been at the heart of electronic design productivity since initial ratification by the
IEEE in 1987. For many years the electronic design automation industry has expanded the use
of VHDL from initial concept of design documentation, to design implementation and
functional verification. It can be said that VHDL initiated modern synthesis technology and
enabled the development of ASIC semiconductor companies.
The use of VHDL has evolved and its importance increased as semiconductor devices
dimensions have shrunk. In the near past it was common to mix designs described with
schematics and VHDL. But as design complexity grew, the industry abandoned schematics in
favor of the hardware description language only. The industry has seen the use of VHDL’s
package structure to allow designers, electronic design automation companies and the
semiconductor industry to experiment with new language concepts to ensure good design tool
and data interoperability.
The Verilog HDL and VHDL industry standards teams collaborated on the use of a common
timing data such as IEEE 1497 SDF, register transfer level (RTL) standards and more to
improve design methodologies and the external connections provided to the hardware
description languages. The design community continues to see benefits as the electronic
design automation community continues to find new algorithms to work from VHDL design
descriptions and related standards to again push designer productivity. In addition, as a new
generation of designers of programmable logic devices move to the use of hardware
description languages as the basis of their design methodology, there will be substantial
growth in the number of VHDL users. In addition to the VHDL packages (Modelsim,
Multisim, etc.) the MATLAB with SIMULINK can be used to model and simulate the
operation of logic circuits. Moreover, the MATLAB with SIMULINK has the capability to
transfer circuits into VHDL code towards the intended chip.
Fig. 1.8
Fig. 1.9
Temporal Representations of Electronic Signals;
Fig. 1.11a: Low Frequency Sinusoidal Signal Fig. 1.11b: High Frequency Sinusoidal Signal
Fig. 1.12a: Amplitude Modulated (Analog) Signal Fig. 1.12b: Frequency Modulated (Analog) Signal
Objectives
Review the decimal number system
Count in the binary, octal and hexadecimal numbers' systems
Convert from decimal to binary, octal and hexadecimal and from binary, octal and
hexadecimal to decimal
Convert between the binary, octal and hexadecimal number systems
Apply arithmetic operations to binary, octal and hexadecimal numbers
Determine the 1’s and 2’s complements of a binary number
Express signed binary numbers in sign-magnitude, 1’s complement, 2’s complement, and
floating-point format
Carry out arithmetic operations with signed binary numbers
Express decimal numbers in binary coded decimal (BCD) form Add BCD numbers
Convert between the binary system, BCD, excess-3 and the Gray codes.
Interpret the American Standard Code for Information Interchange (ASCII)
Explain how to detect code errors, and discuss the cyclic redundancy check (CRC)
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. Early digital computers
were used for numeric computations. In this case, the discrete elements were the digits. From
this application, the term digital computer emerged. Discrete elements of information are
represented in a digital system by physical quantities called signals. Electrical signals such as
voltages and currents are the most common. Electronic devices called transistors predominate
in the circuitry that implements these signals. 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. For example, the decimal digits 0 through 9 are
represented in a digital system with a code of four bits (e.g., the number 7 is represented by
0111). How a pattern of bits is interpreted as a number depends on the code system in which
it resides. To make this distinction, we could write (0111)2 to indicate that the pattern 0111 is
to be interpreted in a binary system, and (0111)10 to indicate that the reference system is
decimal. Then 01112 = 710, which is not the same as 011110, or one hundred eleven. The
subscript indicating the base for interpreting a pattern of bits will be used only when
clarification is needed. Through various techniques, groups of bits can be made to represent
discrete symbols, not necessarily numbers, which are then used to develop the system in a
digital format. Thus, a digital system is a system that manipulates discrete elements of
information represented internally in binary form. In today’s technology, binary systems are
most practical because, as we will see, they can be implemented with electronic components.
Discrete quantities of information either emerge from the nature of the data being processed
or may be quantized from a continuous process. On the one hand, a payroll schedule is an
inherently discrete process that contains employee names, social security numbers, weekly
salaries, income taxes, and so on. An employee’s paycheck is processed by means of discrete
data values such as letters of the alphabet (names), digits (salary), 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 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 analog (continuous) quantity.
The general-purpose digital computer is the best-known example of a digital system. The
major parts of a computer are a memory unit, a central processing unit, and input–output
units. The memory unit stores programs as well as input, output, and intermediate data. The
central processing unit performs arithmetic and other data-processing operations as specified
by the program. The program and data prepared by a user are transferred into memory by
means of an input device such as a keyboard. An output device, such as a printer, receives the
results of the computations, and the printed results are presented to the user. A digital
computer can accommodate many input and output devices. One very useful device is a
communication unit that provides interaction with other users through the Internet. A digital
computer is a powerful instrument that can perform not only arithmetic computations, but also
logical operations. In addition, it can be programmed to make decisions based on internal and
external conditions.
There are fundamental reasons that commercial products are made with digital circuits. 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. 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. Equipment built with digital integrated
circuits can perform at a speed of hundreds of millions of operations per second. Digital
systems can be made to operate with extreme reliability by using error-correcting codes. An
example of this strategy is the digital versatile disk (DVD), in which digital information
representing video, audio, and other data is recorded without the loss of a single item. Digital
information on a DVD is recorded in such a way that, by examining the code in each digital
sample before it is played back, any error can be automatically identified and corrected. 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. The first seven chapters of this book present the basic tools of digital design, such as
logic gate structures, combinational and sequential circuits, and programmable logic devices.
As man began to build machines to perform computations, it seemed both natural and logical
to emulate the human way of counting as well as doing arithmetic. When Sir Charles Babbage
built his analytic engine, he devised a series of gears that would mesh with a series of wheels;
each wheel represented a numeric position (units, tens, hundreds, thousands, and so forth),
and each position was engineered to represent any of ten possible digits. This was truly a 10-
state machine. The problem was that the machine’s excessive complexity required a science
of machined parts that was far beyond the capability of extant technology. Nevertheless,
Babbage’s ideas found their way into 20th century adding machines and electric calculators;
definitely NOT the hand held kind though.
Electrically, it was possible to represent each digit by a different voltage level, and some
analog computers successfully used this ploy though serious accuracy was a challenge never
readily solvable. When John Atanasoff created the first electronic digital computer in 1933,
he devised computational circuits around a different concept. His circuits would represent
only two possible states: on and off. This suggested a bivalent system in which only two
values could exist: a value of 1 was assigned to the on state and a value of 0 was used to
represent the off state. What Atanasoff did was make use of what had been previously an
academic concept; performing arithmetic in a numeric base other than ten. In Atanasoff’s
system, arithmetic had to be performed using only two digits (0 and 1). He gave us a practical
use for the binary number system also referred to as the base 2 system.
It turns out that there are an infinite number of number systems, each with its own base. But
before we investigate specific number systems that are used in various aspects of computing,
it will prove worthwhile to discuss the general attributes ascribed to all number systems.
Every number system consists of a group size for counting purposes. This group size is called
the base of the number system. For example, the decimal number system with which we are
most familiar has a base of 10. The binary system described earlier has a base of two. Each
number system consists of a set of digits. Digits are numbered consecutively with zero (0)
always being the first digit in sequence. Each remaining digit is generated by adding one to
the previous digit until the cardinality of the set of digits equals the size of the base. The
cardinality of a set is the number of elements contained in the set. The base number itself is
never a digit. With all number systems, when one is added to the largest digit in the system,
the resulting number consists of a sum of zero and a carry of one. This phenomenon is
represented in the base-ten system as follows:
9
+1
10
In the binary system, we would have 1 + 1 = 10. Note that we have the same two digits for
our summation in each case but in the decimal system, our sum represents the value ten
whereas in binary system, the sum has an equivalent value of two.
One final notion about number systems concerns positional value. Consider the base 10
number 33,333; where each ‘3’ represents a different quantity. The left most ‘3’; also known
as the most significant digit (MSD), represents the value thirty thousand, whereas the ‘3’ on
the right; also known as the least significant digit (LSD), represents the value of three. Note
that in base ten, it appears that the positional values are associated with successive powers of
the base. In fact, every number system has a unit's position, the position located immediately
to the left of the fraction point. The corresponding power of the base is zero for the units
position and any number raised to the zero power, does yield one from whence the units
position takes its name. As we proceed in the direction of increasing significance (moving left
from the fraction point), the powers increase so that we have a tens position, hundreds
position, thousands position and so forth. The following diagram, Fig. 2.1, illustrates this
idea;
Numbers' Systems:
Base Digits Radix Examples
Binary (2) 0,1 b or B 10100111B (10100111)2
Octal (8) 0,1,2,3,4,5,6,7 o,O 451057O (451057)8
Decimal (10) 0,1,2,3,4,5,6,7,8,9 d , D , no radix 910456D (910456)10
Hexadecimal (16) 0,1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F h or H A1079CH (A1079C)16
Number system consists of an ordered set of digits, with relations defined for +, -, * and /.
The radix (r) or base of a number system indicates the total number of digits allowed in the
number system; common number system includes:
- decimal
- binary
- octal
- hexadecimal
For fractional decimal numbers, the column weights are negative powers of ten that decrease
from left to right: e.g.
102 101 100. 10-1 10-2 10-3 10-4 …
The value of a decimal number can be calculated by multiplying the digit by the value of each
place and adding the results for each digit. The value of each place is determined by the
powers of 10 starting at 0 (10 to the 0th power is 1) and increasing from right to left.
Thus, decimal numbers can be expressed as the sum of the products of each digit times the
column value for that digit as follows;
(9240) = (9 x 103) + (2 x 102) + (4 x 101) + (0 x 100)
or
(9240) = 9 x 1000 + 2 x 100 + 4 x 10 + 0 x 1
321 = 1 * 1 (10 to the power 0) + 2 * 10 (10 to the 1st power) + 3 * 100 (10 to the 2nd power)
= 1 + 20 + 300 = 321.
100’s place 10’s place 1’s place
3 2 1
321 = 300 + 20 + 1 = 321.
Example-2.2.2:
Consider the number 257.56, where each digit has a value of 0 through 9 and has a place
value; Express the number as the sum of values of each digit.
Solution:
257.76 2 10 2 5 101 7 10 0 7 10 1 6 10 2
200 50 7 0.7 0.06
Example-2.2.3:
Multiplier x100000 x10000 x1000 x100 x10 x1
Digits 2 3 1 4 6 7
Most Significant Bit Least Significant Bit
(MSB) (LSB)
In the decimal system (base 10), you should be able to see that each part of the number
increases in multiples of ten. The least significant part is that which has the lowest value in
this case 7 units, and the most significant part is the value of the highest multiple, in this case
200000.
For digital systems, the binary number system is used which has a radix of two and uses the
digits 0 and 1 to represent quantities. The column weights of binary numbers are powers of
two that increase from right to left beginning with 20 =1; e.g.
…25 24 23 22 21 20
For fractional binary numbers, the column weights are negative powers of two that decrease
from left to right:
22 21 20. 2-1 2-2 2-3 2-4… Dec Binary Number
0 0 0 0 0 0
A binary counting sequence for numbers from zero to 1 0 0 0 0 1
fifteen contains pattern of zeros and ones in each column 2 0 0 0 1 0
3 0 0 0 1 1
as shown in the following table:
4 0 0 1 0 0
5 0 0 1 0 1
The decimal value of a binary number can be calculated by 6 0 0 1 1 0
multiplying the digit by the value of each place and adding 7 0 0 1 1 1
the results for each digit. 8 0 1 0 0 0
9 0 1 0 0 1
The value of each place is determined by the powers of 2 10 0 1 0 1 0
11 0 1 0 1 1
starting at 0 (2 to the 0th power is 1) and increasing from
12 0 1 1 0 0
right to left. 13 0 1 1 0 1
14 0 1 1 1 0
15 0 1 1 1 1
16 1 0 0 0 0
For example;
111 = 1 * 1 (2 to the power 0) + 1 * 2 (2 to the power 1) + 1 * 4 (2 to the power 2).
4’s place 2’s place 1’s place
1 1 1
(111)2 = 4 + 2 + 1 = (7)10
As the above table indicates, we can count in binary just as readily as we can count in decimal
but simply needs more digits to represent the
same quantities. Digital counters frequently have
this same pattern of digits. Binary Numbers has;
Base or radix 2 number system,
Binary digit is called a bit, and
Numbers are 0 and 1 only.
Thus, numbers can be expressed in powers of 2
as follows:
213 212 211 210 29 28 27 26 25 24 23 22 21 20
8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1
Bits in computer memory are organized into bytes; each byte has 8 bits. The first 8 values in
powers of 2 are 1, 2, 4, 8, 16, 32, 64, 128. So you can store the values 0 to 255 in 1 byte (8
bits).
Example-2.3.1:
128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1
(1111 1111)2 = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = (255)10.
128 64 32 16 8 4 2 1
0 1 0 0 1 0 1 1
(0100 1011)2 = 64 + 8 + 2 + 1 = (75)10
Example-2.3.2:
Consider the number (1011.0011) in base-2, show its representation as a decimal number.
Solution:
(1011.0011) 2 (1 2 3 0 2 2 1 21 1 2 0 ) (0 2 1 0 2 2 1 2 3 1 2 4 ) 10
(11.1875)10
To convert from decimal to binary use the greedy algorithm: Start with the first power of two
less than or equal to the decimal number and turn that bit to 1. Then subtract the power of two
from the decimal number and continue until done. To convert 9 to binary start by using 1 for
the 8’s place and then (9 – 8) is 1 so use the 1 in the 1’s place, i.e.
(9)10 = (1001)2
Example-2.4.1:
(32)8 = 2 * 1 + 3 * 8 = 2 + 24 = (26)10
64’s place 8’s place 1’s place
0 3 2
Example-2.4.2:
Express the number (1526.76)8 as the sum of values of each digit.
Solution:
Start by writing the column weights:
Prior to 1963, every computer that was programmed to manipulate characters used a special
6-bit code called BCD (Binary Coded Decimal) to represent numeric digits, upper case letters
of the alphabet, and a variety of grammatical and arithmetic punctuation marks and symbols.
This set of codes representing sixty-four characters could not be expanded to handle lower
case letters. IBM engineers solved the problem by creating the framework for an 8-bit code
called EBCDIC (Extended Binary Coded Decimal Interchange Code). It was a
straightforward conversion to describe these 8-bit binary strings by two hexadecimal digits.
Thus, for example, the bit pattern 1001 1100 translated directly into 9C in which the ‘9’
represented ‘1001’ and ‘C’ corresponded to the string ‘1100’; a simple substitution. IBM
unveiled this new system for its System 360 (later 370) family of computers and the use of
“hex” codes became fairly common.
For reasons too lengthy to discuss here, the Number of 1’s or units
Federal Government chose not to adopt IBM’s Number of 16’s
character code as a national standard, despite Number of 256’s
the fact that most computers in use at that Number of 4096’s
time followed the EBCDIC de facto standard. Number of 65536’s
Instead, the American National Standards Fig. 2.4
Institute (then known as ANSI but later
renamed as the National Institute of Standards and Technology (NIST)), part of the Bureau of
Hexadecimal
Base or radix 16 number system
1 hex digit is equivalent to 4 bits.
Numbers are 0-9, A, B, C, D, E, and F.
(A)16 = (10)10, (B)16 = (11)10, (C)16 = (12)10, (D)16 = (13)10, (E)16 = (14)10, (F)16 = (15)10
Numbers are expressed as powers of 16.
160 = 1, 161 = 16, 162 = 256, 163 = 4096, 164 = 65536, …
Hexadecimal uses sixteen characters to represent numbers: the numbers 0 through 9 and the
alphabetic characters A through F. Hexadecimal is a weighted number system where the
column weights are powers of 16, which increase from right to left beginning with 16 0 =1;
e.g.; 163 162 161 160
For fractional hexadecimal numbers, the column weights are negative powers of 16 that
decrease from left to right: 162 161 160. 16-1 16-2 16-3 16-4…
Example-2.5.1:
(A7)16 = A * 16 + 7 * 1 = 10 * 16 + 7 * 1 = 160 + 7 = (167)10
Example-2.5.2:
Express the number (1A2F.B6)16 as the sum of values of each digit.
Solution:
Start by writing the column weights:
Colors are made up of red, green, and blue values from 0 – 255 (8 bits). You can specify the
amount of red, green, and blue using 2 digit hexadecimal numbers (00 is 0 and FF is 255).
An unsigned or a positive integer in base b with n digits: (d n - 1dn -2 . . . d2d1d0) has the
decimal (base 10) value:
n 1
d n 1 * b n 1 d n 1 * b n 1 d n 2 * b n 2 ...... d 2 * b 2 d 1 * b1 d 0 * b 0 d i * b i
i 0 10
where all the arithmetic is done in base 10.
To convert an unsigned or a positive decimal number to base b; repeatedly divide the number
and then each succeeding quotient by b until a quotient of zero is obtained. The remainders
from the last to the first; but converted to base b, form the required number. An appropriate
number of leading zeroes is prefixed to obtain the required number of bits.
Conversion between Bases: In general, conversion between bases can be done via the
following diagram: Base-2
Base-2
Base-3 Base-3
Base r Decimal Decimal
. .
‒ Weighted position notation for integer . .
and fraction
Decimal Base r Base-r Base-r
- Integer number: repeated division by r Fig. 2.5: Numbers' Conversion
- fractions: repeated multiplication by r
Example-2.6.1:
Convert the decimal number (49.188) into binary.
Solution:
The decimal number 49: the column weights double in each position to the right, thus
write down column weights until the last number is larger than the one you want to
convert;
26 25 24 23 22 21 20.
64 32 16 8 4 2 1.
0 1 1 0 0 0 1.
Convert the decimal fraction (.188) to binary by repeatedly multiplying the fractional
results of successive multiplications by 2 as follows;
0.188 x 2 = 0.376 carry = 0 (MSB)
0.376 x 2 = 0.752 carry = 0
0.752 x 2 = 1.504 carry = 1
0.504 x 2 = 1.008 carry = 1
0.008 x 2 = 0.016 carry = 0 (LSB)
Answer = .00110 (for five significant digits)
Converting from decimal to binary is carried out using a simple paper and pencil method
where the decimal number is taken and repeatedly divide it by 2, keeping track of the integer
remainder.
Example-2.6.2: let's convert the decimal value (57) to binary using this method;
____
2 ) 57
28 with a remainder of 1 (now divide 28 by 2)
14 with a remainder of 0
7 with a remainder of 0
3 with a remainder of 1
1 with a remainder of 1
0 with a remainder of 1.
Now take all the remainders starting with the last one and write your binary number:
(1 1 1 0 0 1)2
Converting from Decimal (base 10) to Binary (base 2) begins by dividing the decimal number
by the binary base number (2) using the division algorithm. This division will produce an
integer quotient and an integer remainder of either 1 or 0. Note that the use of integer
remainders is frequently called modulo division. If the quotient is evenly divisible by the base
number, use 0 as the remainder. Otherwise, the remainder will be the digit 1. The next step
will require dividing the new quotient by the base number again to find yet another quotient
and a remainder. Continue with this process, recording the remainders in order, and writing
them from right to left order until you produce a zero with a corresponding remainder of one.
This is the last remainder to record. The equivalent number in the new base is the string of
integer remainders recorded.
Example-2.6.3:
Convert the number (6)10 into binary,
LSB MSB Shorthand Method
3 1 0 6 ÷ 2 = 3 R 0 LSD
2 6 2 3 2 1 3÷2=1R1
1 ÷ 2 = 0 R 1 MSD
6 2 2
0 1 1
(6)10 = (110)2
The shorthand method is presented because many find it convenient to express divisions by
two in this manner. If the method makes you uncomfortable, then by all means follow
standard long division practices. Now let’s try a more complicated problem. For example;
convert (274)10 to its binary (base 2) equivalent;
Shorthand Method
274 ÷ 2 = 137 R 0 LSD
137 ÷ 2 = 68 R 1 8÷2=4R0
68 ÷ 2 = 34 R 0 4÷2=2R0
34 ÷ 2 = 17 R 0 2÷2=1R0
17 ÷ 2 = 8 R 1 1 ÷ 2 = 0 R 1 MSD
continue
(274)10 = (100010010)2
Example-2.6.4:
Convert (51)10 to binary
51 2 = 25 remainder is 1
25 2 = 12 remainder is 1
12 2 = 6 remainder is 0
6 2 = 3 remainder is 0
3 2 = 1 remainder is 1
1 2 = 0 remainder is 1
Answer = 1 1 0 0 1 1
Example-2.6.5:
Convert a decimal number (11.1875) into a binary number.
Hence
(0.1875)10 (a1a 2 a3a 4 ) 2
(0.0011) 2
The algorithm for any fraction is given in a flowchart shown in Fig. 2.7b.
Having calculated
(11)10 (1011) 2
and
(0.1875)10 (0.0011) 2 ,
we have
(11.1875)10 (1011.0011) 2 .
Start
Integer N to be
Input (N)10 converted to
binary format
i=0
i = i+1 ai = R
No
is Q = 0?
Yes
n=i
(N)10 = (an. . .a0)2
STOP
Start
Fraction F to
Input (F)10
be converted to
binary format
i 1
i i 1 ai = R
No
is T = 0?
Yes
n=i
(F)10 = (a-1. . .a-n)2
STOP
In the above example, when we were converting the fractional part of the number, we were
left with 0 after the decimal number and used that as a place to stop. In many cases, we are
never left with a 0 after the decimal number. For example, finding the binary equivalent of 0.3
is summarized in Table 3.
The mathematics behinds this process of converting a decimal number to binary format can
be illustrated as follows:
Let z be the decimal number written as
z x. y
where
x is the integer part and y is the fractional part.
Example-2.6.6
Convert (11.1875)10 to base 2.
Solution
To convert (11)10 to base 2, what is the highest power of 2 that is part of 11. That power is 3,
as 2 3 8 to give
11 2 3 3
What is the highest power of 2 that is part of 3. That power is 1, as 21 2 to give
3 21 1
So
11 2 3 3 2 3 21 1
What is the highest power of 2 that is part of 1. That power is 0, as 2 0 1 to give
1 20
Hence
(11)10 2 3 21 1 2 3 21 2 0 1 2 3 0 2 2 1 21 1 2 0 (1011) 2
To convert (0.1875)10 to the base 2, we proceed as follows. What is the smallest negative
power of 2 that is less than or equal to 0.1875. That power is 3 as 23 0.125 .
So
0.1875 23 0.0625
What is the next smallest negative power of 2 that is less than or equal to 0.0625. That power
is 4 as 2 4 0.0625 .
So
0.1875 23 24
Hence
Example-2.6.7
Convert (13.875)10 to base 2.
Solution
For (13)10 , conversion to binary format is shown in Table 4.
You can also convert decimal to hexadecimal in a similar fashion (repeatedly divide by 16
and keep track of the integer remainders) but it might be easier to convert the decimal number
to binary first, then simply convert the binary number to hexadecimal.
Example-2.6.8:
Convert (77)10 to hex
77 16 = 4 remainder is D
4 16 = 0 remainder is 4
The answer is read from bottom to top as (4D) 16, the same as with the binary case.
2 123 62 remainder 1
2 62 31 remainder 0
2 31 15 remainder 1
2 15 7 remainder 1
2 7 3 remainder 1
2 3 1 remainder 1
2 1 0 remainder 1
Then the required binary number is taken from the remainder values written down at the end
of each division as;
Binary number = 1 1 1 1 1 0 1
Therefore 12310 = 11111012
Another method of conversion is the successive subtraction of the powers of 2, which sounds
very grand but in reality is just about subtracting the largest multiple of 2 away from the
number to convert, and then continuing to subtract the next highest multiple until you reach 0.
Starting with the highest multiple of 256; the number to be converted is less than this so we cannot
subtract 256 from it, so we enter a 0 in this column.
256 128 64 32 16 8 4 2 1
0
The next multiplier is 128 which we can subtract, so we put a 1 in this column.
256 128 64 32 16 8 4 2 1
0 1
We now have 201-128 = 73 left, our next multiple is 64 which we can again subtract so we place a 1
in this column.
256 128 64 32 16 8 4 2 1
0 1 1
We now have 73-64 = 9 left, so we cannot subtract 32, or 16, but we can subtract 8, so the table now
looks like:
256 128 64 32 16 8 4 2 1
0 1 1 0 0 1
We are left with 9 – 8 = 1, and so it is not possible to subtract 4 or 2 but we need to subtract the last 1,
so the full table becomes:
256 128 64 32 16 8 4 2 1
0 1 1 0 0 1 0 0 1
Example-2.6.11
Convert the binary number (100101.01)2 to decimal.
Solution:
Start by writing the column weights; then add the weights that correspond to each 1 in the
number.
25 24 23 22 21 20 . 2-1 2-2
32 16 8 4 2 1 . ½ ¼
1 0 0 1 0 1.0 1
32 + 4 + 1 + ¼ = 37¼
Example-2.6.12
The binary number (10010)2 is equal to (starting from the left) 16 + 0 + 0 + 2 + 0, or 18
in decimal.
The binary number (1011101)2 is equal to 64 + 0 + 16 + 8 + 4 + 0 + 1, or 93 in decimal.
Example-2.6.13
Consider the example below, (11101)2
1 1 1 0 1 Beginning Integers
4 3 2 1 0
2 2 2 2 2 Base to positional powers
16 8 4 2 1 Multiples of base number
1x16 1x8 1x4 0x2 1x1 Multiply position’s digit by the multiple of the base number
16 8 4 0 1 Add products to find base 10 Equivalent = 2910
Then, (11101)2 is equivalent to (29)10.
Example-2.6.14
A more complex example, convert (11000111010101)2 to its decimal equivalent;
In this case, working from right to left on the binary number, you will need to sum the
following: (1 + 0 + 4 + 0 + 16 + 0 + 64 + 128 + 256 + 0 + 0 + 0 + 4096 + 8192) to obtain the
correct decimal equivalent value of (12757)10.
Example-2.6.15
Convert the binary number (110011)2 to decimal.
1 1 0 0 1 1 Beginning Integers
25 24 23 22 21 20 Base to positional powers
32 16 8 4 2 1 Multiples of base number
1x32 1x16 0x8 0x4 1x2 1x1 Multiply position’s digit by the multiple of the base number
32 16 0 0 2 1 Add products to find base 10 Equivalent = 5110
Then, (110011)2 is equivalent to (51)10.
Alternatively, the successive process is reversed; for the binary number to be converted we
must add together all of the multipliers where there is a corresponding 1 in the binary.
You start with a simple grid as we used before, in this case only 8 cells are needed.
128 64 32 16 8 4 2 1
Example-2.6.17
Express (1 001 011 000 001 110)2 in octal:
Group the binary number by 3-bits starting from the right yields;
(1 001 011 000 001 110)2 = (001 001 011 000 001 110)2 = (113016)8
The conversion from octal to binary is a simple process reversal that begins by converting the
most significant octal digit (left most digit) to its binary equivalent. Repeat the conversion
with each octal number, working your way towards the least significant digit (right most
digit). After converting each octal number, concatenate all binary numbers together.
Example-2.6.18
Convert (6132)8 into binary
MSB LSB
6 = 110 1 = 001 3 = 011 2 = 010
Also,
(613.2)8 = (110 001 011.010)2
Group the binary numbers into triplets beginning at the binary point and working outward in
both directions. If the number of binary digits is not divisible by three, leading or trailing
zeros may be added at either end without altering the value of the number to be converted.
Next, each triplet is replaced by its octal equivalent.
Example-2.6.19
Convert (1100110.10)2 into Octal;
(1100110.10)2 = (001 100 110.100)2 = (146.4)8
Group the binary numbers into fours beginning at the binary point and working outward in
both directions. If the number of binary digits is not divisible by four, leading or trailing zeros
may be added at either end. Next, each group of four binary digits is converted to its
corresponding hexadecimal digit that, as previously noted, ranges from 0 (0000) to F (1111).
Binary number can easily be converted to hexadecimal by grouping the binary number in
groups of 4-bits at a time and writing the equivalent hexadecimal character for each group;
Example-2.6.20
Express (1 001 011 000 001 110.011 11)2 in hexadecimal:
Group the binary number by 4-bits starting from the right yields;
(1 001 011 000 001 110.011 11)2 = (1001 0110 0000 1110 . 0111 1000)2 = (960E.78)16
Equals ( 7 8 A 9 3 5 C) 16
The conversion from hexadecimal to binary again is similar to the previously explained octal
to binary conversion. Simply replace each digit to the left and right of the fraction point with
its 4-bit binary equivalent. The process begins by converting the most significant hex digit to
its binary equivalent. We repeat the conversion with each successive digit, working our way
towards the least significant digit. After converting each hexadecimal digit to its 4-digit
binary counterpart, we merge all binary digits together to obtain our answer. That is, after
converting each hexadecimal digit, concatenate all the binary digits separated by a binary
point positioned appropriately.
Example-2.6.21
Convert (395F.4B)16 into binary
MSB LSB
3 = 0011 9 = 1001 5 = 0101 F = 1111 . 4 = 0100 B = 1011
Example-2.6.22:
Convert (161)10 into Octal
LSB MSB Shorthand Method
20 2 0 161 ÷ 8 = 20 R 1 LSD
8 161 8 20 8 2 20 ÷ 8 = 2 R4
2÷8=0 R 2 MSD
160 16 0
1 4 2
(161)10 = (241)8
Example-2.6.23:
Convert (177)10 into Octal
177 8 = 22 remainder is 1
22 8 = 2 remainder is 6
2 8 = 0 remainder is 2
The answer is read from bottom to top as (261) 8, the same as with the binary case.