CH 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

DIGITAL LOGIC

DESIN

CHAPTER-ONE

BINARY SYSTEM

By: INS Luela G. 2019

1
1. Introduction
In today’s world, the term digital has become part of our everyday vocabulary because of the
dramatic way that digital circuit and digital techniques have become so widely used in almost
area of life. Digital Logic is the basis of electronic systems, such as computers and cell phones.
Digital Logic is rooted in binary code, a series of zeroes and ones each having an opposite value.
This system facilitates the design of electronic circuits that convey information, including logic
gates. Digital Logic gate functions include and, or and not. The value system translates input
signals into specific output. Digital Logic facilitates computing, robotics and other electronic
applications.

Digital Logic Design is foundational to the fields of electrical engineering and computer
engineering. Digital Logic designers build complex electronic components that use both
electrical and computational characteristics. These characteristics may involve power, current,
logical function, protocol and user input.

1.1 Digital computer and Digital system


A digital computer stores data in terms of digits (numbers) and proceeds in discrete steps from
one state to the next. The states of a digital computer typically involve binary digits which may
take the form of the presence or absence of magnetic markers in a storage medium, on-off
switches or relays. In digital computers, even letters, words and whole texts are represented
digitally.

A digital system is interconnections of digital modules.to understand the operation of each


digital module, it is necessary to have a basic knowledge of digital circuit and their logical
functions. We can take general purpose digital computer as best example of digital system.
Digital system also takes a set of discrete information inputs and discrete internal information
(system state) and generates a set of discrete information outputs.

Fig-1.Block diagram of digital system

2
1.1.1 Types of Digital Systems:
 No state present

• Combinational Logic System

• Output = Function(Input)

 State present

• State updated at discrete times

=> Synchronous Sequential System

• State updated at any time

=>Asynchronous Sequential System

• State = Function (State, Input)

• Output = Function (State)


or Function (State, Input)

1.1.2 Analog vs. Digital system:


Natural forces and signals are all analog (continuous), which means we hear, see and change
items in a continuous manner. Also analog system contains devices that manipulate physical
quantities that are represented in analog form. In analog system, the quantities can vary over a
continuous range of values.

On the other hand, we have digital system (also called non continuous) which is preferable to
process and communicate effectively than analog. This leads us to design systems that fit the
following block diagram architecture. Also digital system is combination of device designed to
manipulate logical information or physical quantities that are represented by digital form; that is
the quantities can take on only discrete value.

Process
Real world ADC DAC real world
Store
Signal Signal
Communicate

3
Example: Consider a faucet

 Digital

Water can be flowing or NOT flowing from the faucet

Two States: On or Off

 Analog

How much water is flowing from the faucet?

1.2.3 Advantage of digital over analog system:


 Error Correction/Detection: Small errors don’t propagate
 Easier to design
 Have ease information storage
 Accuracy and precision are easy to maintain throughout the system
 Miniaturization of Circuits
 Programmability; digital computers are programmable

2. Numbering system
A number system is a set of a digital use for mathematical operation such as: counting, adding,
subtracting, dividing and multiplying. The numeric system we use daily is the decimal system,
but this system is not convenient for machines since the information is handled codified in the
shape of on or off bits; this way of codifying takes us to the necessity of knowing the positional
calculation which will allow us to express a number in any base where we need it.

4
 A base of a number system or radix defines the range of values that a digit may have.

 Have Positive radix(base), positional number systems

 A number with radix or base r is represented by a string of digits:


in which 0 £ Ai < r and. is the radix point.

 The string of digits represents the power series:

• From the above expression the sequence of the coefficients from


left(MSB) to right(LSB) provides the r-number systems(i.e. an an-1….. a2 a1 a0.
a-1 a-2……… a-m)
We have four commonly used number systems depending on their radix (base) r: like decimal,
binary, octal and hexadecimal numbering system.

 In the decimal system or base 10, decimal numbers are made of decimal digits those are
ten different values for each digit of a number: "0", "1", "2", "3", "4", "5", "6", "7", "8",
and “9".

Example: 97654.35 = 9x104 + 7x103 + 6x102 + 5x101 + 4x100 + 3x10-1 + 5x10-2

In formal notation -> (97654.35)10

 In the binary system or base 2, binary numbers are made of binary digits (bits) those can
be only two values for each digit of a number, either a "0" or a "1".

Example: 110.10 = 1x22 + 1x21 + 0x20 + 1x2-1 + 0x2-2

In formal notation -> (110.10)2

 In the octal system or base 8, octal numbers are made of octal digits those can be eight
choices for each digit of a number: "0", "1", "2", "3", "4", "5", "6", and “7".

Example: 465.27= 4x82 + 6x81 + 5x80 + 2x8-1 + 7x8-2

In formal notation -> (465.27)8

5
 In the hexadecimal system, we allow 16 values for each digit of a number: "0", "1", "2",
"3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", and "F". Where “A” stands for
10, “B” for 11 and so on.
Example: 8A6.55=8x162 + 10x161 + 6x160 + 5x16-1 + 5x16-2
In formal notation -> (8A6.55)16

2.1 Number Base Conversions


The conversion methods can be used to convert a number from any base to any other base, so the
possible conversions are:

 Good idea to memorize! numbers in different bases

6
A) .Decimal to Binary
We begin by separating the number into its integer and fractional part. The integer
part is converted using the remainder method, by using a successive division of the
number by the base until a zero is obtained. At each division, the reminder is kept
and then the new number in the base r is obtained by reading the remainder from
the last remainder upwards.
Technique1 for integer part:
 Divide the number by the ‘Base’ (=2)
 Take the remainder (either 0 or 1) as a coefficient
 Take the quotient and repeat the division
 Write the result starting from the most to list (like: an an-1…… a3 a2 a1 a0 )

Technique .2 for fraction part:


 multiply the number by the ‘Base’ (=2)
 Take the integer (either 0 or 1) as a coefficient
 Take the fraction and repeat the multiplication
 Write the result starting from the list to most(like: a-1 a-2……… a-m)

7
B).Binary to Decimal
 Technique
• Multiply each bit by 2n, where n is the “weight” or coefficient of the bit
• The weight is the position of the bit, starting from 0 on the right
• Add the results
Example: Convert binary to decimal

C).Decimal to Octal
We begin by separating the number into its integer and fractional part. The integer
part is converted using the remainder method, by using a successive division of the
number by the base until a zero is obtained. At each division, the reminder is kept
and then the new number in the base r is obtained by reading the remainder from
the last remainder upwards.
Technique 1 for integer part:
 Divide the number by the ‘Base’ (=8)
 Take the remainder as a coefficient
 Take the quotient and repeat the division
 Write the result starting from the most to list (like: an an-1…… a3 a2 a1 a0 )

Technique .2 for fraction part:

 multiply the number by the ‘Base’ (=8)


 Take the integer as a coefficient
 Take the fraction and repeat the multiplication
 Write the result starting from the list to most(like: a-1 a-2……… a-m)

8
D).Octal to Decimal
Technique
• Multiply each bit by 8n, where n is the “weight” or coefficient of the bit
• The weight is the position of the bit, starting from 0 on the right
• Add the results

Example: convert (724)8 to ()10

E).Decimal to Hexadecimal
Technique:

 Divide the number by the ‘Base’ (=16)


 Take the remainder as a coefficient
 Take the quotient and repeat the division
 Write the result starting from the most to list (like: an an-1…… a3 a2 a1 a0)

9
Example:

F).Hexadecimal to Decimal
Technique
• Multiply each bit by 16 n, where n is the “weight” or coefficient of the bit
• The weight is the position of the bit, starting from 0 on the right
• Add the results

Example:

10
G).Binary to Octal (Hexadecimal)
 In order to convert a binary number to octal, we partition the base 2 number into groups
of three starting from the radix point, and pad the outermost groups with 0’s as needed to
form triples. Then, we convert each triple to the octal equivalent
 Group the binary digits into three (four) bit groups starting at the radix point and going
both ways, padding with zeros as needed in the fractional part.

Example 1: convert binary to hexadecimal

Result: 1010111011 2 =2BB16

Example 2:

11
H).Octal (Hexadecimal) to Binary
• Restate the octal (hexadecimal) as three (four) binary digits starting at the radix point and
going both ways.
Example .1:

Example2

I).Octal to Hexadecimal
Technique:

 Convert the given octal number to binary number after that covert the binary to
hexadecimal by grouping in three digits.

12
J).Hexadecimal to Octal
Technique:

 Convert the given octal number to binary number after that covert the binary to
hexadecimal by grouping in four digits.
Example:

2.2 Binary operations


 Binary addition
 Binary addition is very simple.

13
 This is best shown in an example of adding two binary numbers …

 Binary subtraction
 We can also perform subtraction (with borrows in place of carries).
 And let as consider:

A B A-B
0 0 0
1 0 1
1 1 0
10 1 1

Let’s subtract (10111)2 from (1001101)2…

 Binary multiplication
 Binary multiplication is much the same as decimal multiplication, except that the
multiplication operations are much simpler…

14
 Multiplication of two binary numbers is as following:

3. Complement Of number systems


Complements are used in digital computer: To simplify the subs traction operation, to represent
negative numbers and for logical manipulation. Those all importance of compliment leads us to
design simpler and less expensive circuit.

There are two types of compliments for each base-r number system. Those are:

1. Radix or r’s complement


2. Diminished radix or (r-1)’s complement

But also have another name in each number system: like

 In the decimal numbering system, the radix complement is called the ten's complement
and the diminished radix complement the nines' complement.

 In binary, the radix complement is called the two's complement and the diminished radix
complement the ones ‘complement.

15
 In the octal numbering system, the radix complement is called the eight’s complement
and the diminished radix complement the sevens' complement.

 In the hexadecimal numbering system, the radix complement is called the sixteen’s
complement and the diminished radix complement the fifteens' complement.

1).Diminished Radix or r-1’s Complement


For a given number N in base r having n-digits, its r-1’s complement is given by: (rn -1) -N

Example: a) find 9’s complement of 546700

Solution: n=6 9’s complement? r-1’s=(rn -1) -N

r=10 9’s= ( 106 -1) -546700

N=546700 =999999-546700

=453299

b).find 1’s complement of 1011000

Given: n=7 r-1’s=2-1=1’s?

r=2

N=1011000

Solution: r-1’s=(rn -1)-N

1’s= ( 27 -1)-101100

= ((12810) -1) -1011000

= ((100000002) -1) -1011000

=1111111-1011000 =0100111

But easily we can get one’s complement by inverting all 0’s to 1’s and vice versa.

So, 1’s complement of 1011000 become 0100111

Solution: r-1’s=(rn -1)-N

7’s= ( 85 -1)-42867

=77777-42867

=34910
16
c).find 15’s complement of E06CB

Given: n=5 r-1’s=18-1=15’s?

r=16

N= E06CB

Solution: r-1’s= (rn -1)-N

15’s= ( 165 -1)- E06CB

=FFFFF- E06CB

=1F934

2).Radix or r’s complement


For a given number N in base r having n-digits, its r’s complement is given by: rn –N

Example: a).find 10’s complement of 4568

Solution: n=4 10’s complement? r’s=rn -N

r=10 10’s= 104-4568

N=4568 =10000-4568

=5432

b).find 2’s complement of 101100

Given: n=6 r’s=2’s?

r=2

N=101100

Solution: r’s=rn -N

1’s= 26 -10110

= (6410)-1011000

= 10000002 -101100

=010100

17
But easily we can get 2’s complement from 1’s complement by adding 1.So, first find 1‘s
complement by inverting all 0’s to 1’s and vice versa =010011,after this 2’s complement
become=1’s complement +1

=010011+1

=010100

 Subtraction with complements


o The subtraction of two n-digit unsigned number M-N in base r can be done by means of
r’s complement as follows:
 Add M to the r’s complement of N……M+ ( rn -N)
 If M>N, the sum will be produce an end carry, so remove the end carry and what
is left is the answer one.
 If M<N, sum doesn’t produce an end carry; the answer becomes the r’s
complement of the sum and place negative sign in front of it.

Example: given numbers M=72532, N=3250, X=1010100 and y=1000011 perform the
subtractions by using r’s complement.

a).M-N

Solution: M=72532 10’s of N= r n -N

N=03250 =105 -03250

r=10 =96750

n=5 10’s complement of N +M

=96750+72532

=169282

o The sum produce an end carry so discard it. The result become 69282

b).N-M

Solution: M=72532 10’s of M= r n -M

N=03250 =105 -72532

r=10 =27468

n=5 10’s complement of M +N

=27468+03250

18
=30718

So, there is no ends carry; result becomes r’s complement of sum and placing negative sign in
front of it.

r’s complement of sum =rn-sum

=105 -30718

=69282

Answer= -69282

c).x-y

Solution: X=1010100 2’s of Y= rn -Y

Y=1000011 =27-1000011

r=2 =10000000-1000011

n=7 =0111101

10’s complement of Y+X

=0111101+1010100

=10010001

o The sum produce an end carry so discard it. The result become 0010001

d).y-x

Solution: X=1010100 2’s of x= r n -x


7
Y=1000011 =2 -1010100
r=2 =10000000-1010100
n=7 =0101100
10’s complement of X+Y
=0101100+1000011
=1101111

So, there is no ends carry; result becomes r’s complement of sum and placing negative sign in
front of it.

r’s complement of sum =rn-sum

19
=27 -1101111

=0010001

Answer= -0010001

o The subtraction of two n-digit unsigned number M-N in base r can be alsodone by means
of r-1’s complement as follows:
 Add M to the r-1’s complement of N……M+ (rn -1)-N
 If M>N, the sum will be produce an end carry, so remove the end carry and then
add the end carry to the sum in order to get the answer of M-N
 If M<N, sum doesn’t produce an end carry; the answer becomes the r-1’s
complement of the sum and place negative sign in front of it.

Example: given numbers M=72532, N=3250, X=1010100 and y=1000011 perform the
subtractions by using r-1’s complement.

a).M-N

Solution: M=72532 9’s of N= (rn -1) -N

N=03250 = (105-1)-03250

r=10 =96749

n=5 9’s complement of N +M

=96749+72532

=169281

o The sum produce an end carry so, discard the end carry and add to the sum. The result
become 69281+1= 69282

b).N-M

Solution: M=72532 r-1’s of M= (rn -1)-M

N=03250 = (105-1)-72532

r=10 =27467

n=5 9’s complement of M +N

=27467+03250

=30717

20
So, there is no ends carry; result becomes r’s complement of sum and placing negative sign in
front of it.

r’s complement of sum =rn-sum

=105 -30717

=69282

Answer= -69282

c).x-y

Solution: X=1010100 2’s of Y= (rn -1)-Y

Y=1000011 = (27-1)-1000011

r=2 = (10000000-1)-1000011

n=7 =0111100

10’s complement of Y+X

=0111100+1010100

=10010000

o The sum produce an end carry so discard it and add to the remain part . The result
become 0010000+1=0010001

d).y-x

Solution: X=1010100 2’s of X= (rn -1)-X

Y=1000011 =(27-1) -1010100

r=2 =(10000000-1)-1010100
n=7 =0101011
10’s complement of X+Y
=0101011+1000011
=1101110

So, there is no ends carry; result becomes r’s complement of sum and placing negative sign in
front of it.

r’s complement of sum =rn-sum

= (27-1) -1101110

21
=0010001

Answer= -0010001

 How To Represent Signed Numbers using complements


Positive numbers (including zero) can be represented as unsigned number. However to
represent negative integers we need a notation for negative values.

In binary number system it is conventional to represent sign with a bit placed in the left
most position (MSP) of the number.

o The convention is to make the sign bit 0 for positive and 1 for negative.
Example: +5=0101
-5=1101

We have two commonly used notations for signed number.

1.Signed magnitude system


2.Signed complement system
1. Signed magnitude system:
Sign bit magnitude

In signed magnitude system, a negative number has the same magnitude bits as the
corresponding positive numbers to the sign bit is 1 for negative rather than 0.

Example: +9=01001

-9=11001

2. Signed Complement System: are used for representing a negative number in either
1’s or 2’s complement, but the 2’s complement is the most common.

Sign bit 1’s or 2’s complement

Example: assuming the representation of number 9 in binary with 8 bits, we have the following
codes: +9 has signed magnitude representation: 00001001

-9 has signed magnitude representation: 10001001

22
-9 has signed 1’s complement representation: 11110110

-9 has signed 2’s complement representation: 11110111

4. Binary code
Internally, digital computers operate on binary numbers. When interfacing to humans, digital
processors, e.g. pocket calculators, communication is decimal-based. Input is done in decimal
then converted to binary for internal processing. For output, the result has to be converted
from its internal binary representation to a decimal form. Digital system represents and
manipulates not only binary number but also many other discrete elements of information.

Binary codes are used to translate human symbols to 1’s and 0’s.the most important of the
symbols is the alphabet used for human communications.so every key and character has to
have a uniquely binary code. The minimum number bit requires to uniquely identify all the
keys on the keyboard must be meet the following condition:

2number of bit >number of keys

There are different types of binary codes such as: BCD code, Gray code and ASCII code

4.1. Binary Coded Decimal (BCD)


 BCD is an encoding for decimal numbers in which each digit is represented by its own
binary sequence.
 Its main virtue is that
• It allows easy conversion to decimal digits for printing or display and faster
decimal calculations.
 Its drawbacks are
• The increased complexity of circuits needed to implement mathematical
operations
• Relatively inefficient encoding.
• It occupies more space than a pure binary representation
 The BCD code encodes the first ten values from 0 to 9 but it is not used for above nine.
 Each decimal digit is coded separately by 4 bits

23
Example:

(325)10 = (0011 0010 0101)BCD

• Exercise: (856)10 = ( ? )BCD

• Exercise: (127)10 = ( ? )BCD

• The position weights of the BCD code are 8, 4, 2, 1. Other codes (shown in Table below)
use position weights of 8, 4, -2, -1 and 2, 4, 2, 1.

• An example of a non-weighted code is the excess-3 code where digit codes are obtained
from their binary equivalent after adding 3. Thus the code of a decimal 0 is 0011, that of
6 is 1001, etc.

• It is very important to understand the difference between the conversion of a decimal


number to binary and the binary coding of a decimal number. In each case, the final result
is a series of bits. The bits obtained from conversion are binary digit. Bits obtained from
coding are combinations of 1’s and 0’s are arranged according to the rule of the code
used.

• e.g. the binary conversion of 13 is 1101; the BCD coding of 13 is 00010011

• Also there are over 8,000 ways that you can chose 10 elements from the 16 binary
numbers of 4 bits. A few are useful:

Generally BCD is:

 is not very efficient

 Used in early computers (40s, 50s)

24
 Used to encode numbers for seven-segment displays.

 Easier to read

4.2. Gray Code


 The output data of many physical systems are quantities that are continuous. These data
must be converted into digital form before they are applied to a digital system. And it is
convenient to use gray code to represent digital data that have been converted from
analog data.
 The Gray code consists of 16 4-bit code words to represent the decimal Numbers 0 to 15.
For Gray code, successive code words differ by only one bit from one to the next.
 The advantage of gray code over the straight binary numbers sequence is that only one bit
on the code groups changes in going from one number to next.
 For example, in going from 7 to 8 the gray code changes from 0100 to 1100 only the first
bit is changed from 0 to 1,the other 3 bits remain the same.

Generally Gray code is:

25
 Not a number system.

• It is an alternate way to represent four bit data

 Only one bit changes from one decimal digit to the next

 Useful for reducing errors in communication.

 Can be scaled to larger numbers.

 ALPHANUMERIC CODES - ASCII Character Codes


 American Standard Code for Information Interchange
 This code is a popular code used to represent t information sent as character-based data.
It uses 7or 8-bits to represent for error detection.
 Some non-printing characters are used for text format (e.g. BS = Backspace, CR =
carriage return)
 Other non-printing characters are used for record marking and flow control (e.g. STX and
ETX start and end text areas).
 The ASCII code table is show as below:
character ASCII(binary) ASCII(HEXA) ASCII(decimal) ASCII(OCTAL)
A 1000001 41 65 101
B 1000010 42 66 102
C 1000011 43 67 103
D . 44 . .
. . 45 . .
. . . . .
. . . . .
. . . . .
Z . . . .
A . . . .
B . . . .
C . . . .
. . . . .
. . . . .
1 . . . .
. . . . .
Generally ASCII codes have: a-z 26 codes

A-Z 26 codes

0-9 9 codes

Other (#, $, %,^,….)

26
5. Binary storage, registers and logic
 Binary Data Storage
 The discrete elements of information in digital computer must have a physical existence
in some information storage medium
 When discrete elements of information are represented in binary form, the information
storage must contain binary storage elements for storing individual bits.

 Binary cells is advices that passes 2 stable states and is capable of storing 1 bit
information store individual bits of data.

 Binary logic
 Deals with binary variables and logical operations.
 Binary variable are designed by letters such as A, B, C, X, Y, Z, etc. each variable
having only two possible values v1 or 0.
 There are also three basic logical operations.
1).AND: represented by dot (.) or the absence of operator.
Truth table of AND gate:
A B F=AB
0 0 0
0 1 0
1 0 0
1 1 1

2).OR: represented by plus (+).


Truth table of OR gate:
A B F=A+B
0 0 0
0 1 1
1 0 1
1 1 1

3). NOT: represented by pino (‘) or bar (-).


Truth table of NOT gate:

27
A F=A’
0 1
1 0

10

28

You might also like