0% found this document useful (0 votes)
70 views96 pages

DLD - Chap1 - 2 (2nd Semester 2020-2021)

The document discusses a course in digital logic design. It provides details about the course such as the lecturer, textbook, grading breakdown, and chapter objectives. The course covers topics like number systems, logic gates, combinational and sequential logic circuits, counters, memory and more. Course policies require on-time assignment submissions and prohibit plagiarism.

Uploaded by

smuyet lê
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views96 pages

DLD - Chap1 - 2 (2nd Semester 2020-2021)

The document discusses a course in digital logic design. It provides details about the course such as the lecturer, textbook, grading breakdown, and chapter objectives. The course covers topics like number systems, logic gates, combinational and sequential logic circuits, counters, memory and more. Course policies require on-time assignment submissions and prohibit plagiarism.

Uploaded by

smuyet lê
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 96

Information

1
 Course: Digital Logic Design (EE053IU)
 Lecturer: Do Ngoc Hung
 Office: O2.206, School of EE, IU Campus, VNU-HCM
 Email: [email protected]
 Number of credits: 3
 Textbook:
1. Neal Widmer, Greg Moss, and Ron Tocci
“Digital Systems”, Pearson;
2. Moriss Mano, Michael D. Ciletti,
“Digital Design”, Prentice Hall,
 Lecture Note & Homework: Blackboard
 TA: Huynh Tran Minh Tri, email: [email protected]
Course Syllabus
2

Content
Introduction of Digital world and Number Systems

Basic math operations for digital systems and Binary codes


Binary Logic, Logic gates, and Boolean Algebra
Combinational Logic Circuit
Sequential Logic Circuit (part I): Latches and Flip-Flop Devices
Sequential Logic Circuit (part II): State Machines, Synchronous and Asynchronous
Counters Designs
Sequential Logic Circuit (part III): IC Counter and Register.
Memory and Storage in the Computer
Review
Grading
3

1. Midterm examination: 30%

2. Final examination + Project: 40%

3. Attendance + Quiz + Homework: 30%

(Software is used for circuit simulation: NI


Multisim)
Course Policy
4

1. All assignments need to be submitted on


the due date

2. Students are expected to do their own


work at all times. Any evidence of
plagiarism or cheating will be treated as
grounds for failure in the class.

3. Attendance: at least 80%


Chapter 1 Objectives
5

 Selected areas covered in this chapter:


 Analog & digital representations.
 How information is represented using two states.
 Advantages/drawbacks of digital/analog techniques.
 Analog-to-digital and digital-to-analog converters.
 Basic characteristics of the binary number system.
 Convert binary numbers to decimal equivalents.
 Identify typical digital signals & a timing diagram.
 Converting between number systems.
 Decimal, binary, hexadecimal.
Chapter 1 Objectives
6

Selected areas covered in this chapter:


 Advantages of the hexadecimal number system.
 Counting in hexadecimal.
 Representing decimal numbers using the BCD code.
 Pros and cons of using BCD.
 Differences between BCD and straight binary.

 Purpose of alphanumeric codes such as ASCII code.


 Parity method for error detection.
 Determine the parity bit to be attached to a digital data
string.
Chapter 1
7

Numerical Representations
• Physical systems use quantities which must be manipulated
arithmetically.
• Quantities may be represented numerically in either analog
or digital form.
Analog Representation: a continuously variable, proportional
indicator.
• Sound through a microphone causes voltage changes.
• Automobile speedometer changes with speed.
• Mercury thermometer varies over a range of values with
temperature.
Chapter 1
8

 In 1875, Alexander Graham Bell figured out how to change


his voice into a continuously variable electrical signal, send it
through a wire, and change it back to sound energy at the
other end.

 Today, the device that converts


sound energy to an analog
voltage signal is known as a
microphone.
Chapter 1
9

 Digital Representation—varies in discrete


(separate) steps.
 Passing time is shown as a change in the display
on a digital clock at one minute intervals.
 A change in temperature is shown on a digital
display only when the temperature changes
at least one degree.
Chapter 1
10

Most natural quantities that we see are analog and vary


continuously. Analog systems can generally handle higher
power than digital systems.
Temperature
(°F)

100
95
90
85
80
75
70
Time of day
1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12
A .M . P.M .

Digital systems can process, store, and transmit data more


efficiently but can only assign discrete values to each point.
Chapter 1
11

 Digital system:
A combination of devices that manipulate values
represented in digital form.
 Quantities can take on only discrete values.

 Analog system:
A combination of devices that manipulate values
represented in analog form.
 Quantities can vary over a continuous range
of values.
Chapter 1
12

Many systems use a mix of analog and digital electronics to


take advantage of each technology.
A typical CD player accepts digital data from the CD drive
and converts it to an analog signal for amplification.
CD drive

10110011101 Digital-to-analog Linear amplifier


Digital data converter Analog
reproduction
of music audio Speaker
signal
Sound
waves
Chapter 1
13

Temperature-regulation system
using an analog-to-digital converter.
Chapter 1
14

 Advantages of digital:
 Ease of design
 Well suited for storing information.

 Accuracy and precision are easier to maintain.

 Programmable operation.

 Less affected by noise.

 Ease of fabrication on IC chips.


Chapter 1
15

 There are limits to digital techniques:


 The analog nature of the world requires a time
consuming conversion process:
1. Convert the physical variable to an electrical signal
(analog).
2. Convert the analog signal to digital form.
3. Process (operate on) the digital information.
4. Convert the digital output back to real-world analog
form.
Chapter 1
16

 Understanding digital systems requires an


understanding of the decimal, binary, octal,
and hexadecimal numbering systems.
 Decimal – 10 symbols (base 10)
 Hexadecimal – 16 symbols (base 16)

 Octal – 8 symbols (base 8)

 Binary – 2 symbols (base 2)


Chapter 1: Digital Number Systems
17

 The Decimal (base 10) System


 10 symbols: 0, 1, 2, 3, 4, 5, 6 , 7, 8, 9.
 Each number is a digit (from Latin for finger).

Most significant digit (MSD) & least significant digit (LSD).


Positional value may be stated as a digit multiplied by a power of 10.
Chapter 1: Digital Number Systems
18

 The Binary (base 2) System


2 symbols: 0,1
 Lends itself to electronic circuit design since only
two different voltage levels are required.

Positional value may


be stated as a digit
multiplied by a
power of 2.
Chapter 1: Digital Number Systems
19

Binary
Counting
Chapter 1: Digital Number Systems
20

Counting range

Using N bits, we can represent decimal numbers ranging


from 0 to 𝟐𝑵 − 𝟏

A total of 𝟐𝑵 different numbers.


(a) What is the total range of decimal values that can be
represented in eight bits?
(b) How many bits are needed to represent decimal values
ranging from 0 to 12,500?
Chapter 1:Representing Binary Quantities
21

 Analog signals can be converted to digital by taking


measurements or “samples” of the continuously varying signal
at regular intervals.
 Appropriate time between samples depends on
the maximum rate of change of the analog signal.

Air temperature is an analog


quantity
Recorded samples are discrete
integer data
Chapter 1:Representing Binary Quantities
22

Typical representation of the


two states of a digital signal.
A higher range of voltages VH(max)
represent a valid 1 and
a lower range of voltages HIGH
VH(min)
represent a valid 0.
HIGH and LOW are often Invalid
used to describe the states VL(max)
of a digital system—instead LOW
of “1” and “0”
VL(min)
Chapter 1:Representing Binary Quantities
23

 The oscilloscope and logic analyzer


are used to produce timing diagrams.
 Timing diagrams show voltage versus time.

 Used to show how digital signals change with time,


or to compare two or more digital signals.

Horizontal scale
represents regular
intervals, starting
at time zero.
Chapter 1:Representing Binary Quantities
24

Digital waveforms change between the LOW and HIGH levels. A


positive going pulse is one that goes from a normally LOW logic
level to a HIGH level and then back again. Digital waveforms
are made up of a series of pulses.

HIGH HIGH
Rising or Falling or Falling or Rising or
leading edge trailing edge leading edge trailing edge

LOW LOW
t0 t1 t0 t1

(a) Positive–going pulse (b) Negative–going pulse


Chapter 1:Representing Binary Quantities
25

Pulse Definitions
Actual pulses are not ideal but are described by the rise time, fall
time, amplitude, and other characteristics.
Overshoot
Ringing
Droop
90%
Amplitude tW
50%
Pulse width

10%
Ringing

Base line Undershoot


tr tf
Rise time Fall time
Chapter 1:Representing Binary Quantities
26

Periodic Pulse Waveforms


Periodic pulse waveforms are composed of pulses that repeats
in a fixed interval called the period. The frequency is the rate it
repeats and is measured in hertz.
1 1
f  T
T f

The clock is a basic timing signal that is an example of a


periodic wave.
What is the period of a repetitive wave if f = 3.2 GHz?
1 1
T   313 ps
f 3.2 GHz
Chapter 1:Representing Binary Quantities
27

Pulse Definitions
In addition to frequency and period, repetitive pulse waveforms
are described by the amplitude (A), pulse width (tW) and duty
cycle. Duty cycle is the ratio of tW to T.
Volts

Pulse
width
Amplitude (A)
(tW)

Time
Period, T
Chapter 1:Digital Circuits/Logic Circuits
28

 Digital circuits - produce & respond to predefined


voltage ranges.
 The term logic circuits is used interchangeably.
 A digital circuit

responds to
an input’s binary
level of 0 or 1
not to its
actual voltage.
Chapter 1: Integrated Circuits
29

A monolithic integrated circuit (IC) is an electronic circuit that is


constructed entirely on a single small chip of silicon.
All the components that make up the circuit: transistors, diodes,
resistors, and capacitors
Plastic
Chip case

Pins

Cutaway view of one type of fixed-function IC package


Chapter 1: Integrated Circuits
30

Integrated circuit (IC) packages are classified according to the way


they are mounted on printed circuit boards (PCBs) as either through-
hole mounted or surface mounted
The through-hole type packages have pins (leads) that are inserted
through holes in the PCB and can be soldered to conductors on the
opposite side
DIP chips and surface mount chips
Pin 1

Dual in-line package Small outline IC (SOIC)


Chapter 1: Integrated Circuits
31

Surface-mount technology (SMT) is a space-saving alternative to


through-hole mounting. The holes through the PCB are unnecessary
for SMT. The pins of surface-mounted packages are soldered
directly to conductors, on one side of the board, leaving the other
side free for additional circuits.
• SOIC (small-outline integrated circuit)
• SSOP (shrink small-outline package)
• PLCC (plastic-leaded chip carrier)
• LCC (leadless ceramic chip)
• LQFP (low-profile quad flat package)
• FBGA (fine-pitch ball grid array)
Chapter 1: Integrated Circuits
32

Other surface mount packages:


Chapter 1: Integrated Circuits
33

Fixed-function digital ICs are classified according to their complexity.


• Small-scale integration (SSI) describes fixed-function ICs that have up
to ten equivalent gate circuits on a single chip, and they include basic
gates and flip-flops.
• Medium-scale integration (MSI) describes integrated circuits that have
from 10 to 100 equivalent gates on a chip. They include logic functions
such as encoders, decoders, counters, registers, multiplexers, arithmetic
circuits, small memories, and others.
• Large-scale integration (LSI) is a classification of ICs with complexities
of from more than 100 to 10,000 equivalent gates per chip, including
memories.
• Very large-scale integration (VLSI) describes integrated circuits with
complexities of from more than 10,000 to 100,000 equivalent gates per
chip.
• Ultra large-scale integration (ULSI) describes very large memories,
larger microprocessors. Complexities of more than 100,000 equivalent
gates per chip
Chapter 1:Serial and Parallel Data
34

Serial and Parallel Data


Data can be transmitted by either serial transfer or parallel
transfer.
1 0 1 1 0 0 1 0
t0 t1 t2 t3 t 4 t5 t6 t7
Computer Modem

1
Computer Printer
0

0
t0 t1
Chapter 1:Programmable Logic
35

Programmable logic devices (PLDs) are an alternative to fixed


function devices. The logic can be programmed for a specific
purpose. In general, they cost less and use less board space
that fixed function devices.
Two major categories of
user-programmable logic
are
• PLD (programmable
logic device)
• FPGA (field-
programmable gate
array)
Chapter 1:Programmable Logic
36

PLDs are either SPLDs (simple PLDs) or CPLDs (complex PLDs)


PAL device is a form of PLD that uses a combination of a
programmable AND array and a fixed OR array (can be
reprogrammed 1 time)
GAL device is a form of PLD that uses a combination of a
programmable AND array and a fixed OR array and
programmable output logic (can be reprogrammed many
times)
Chapter 1:Programmable Logic
37

The SPLD was the original PLD and is still available for small-
scale applications. Generally, an SPLD can replace up to ten
fixed-function ICs and their interconnections.
The CPLD is a device containing multiple SPLDs and can replace
many fixed-function ICs
An FPGA is generally more complex and has a much higher
density than a CPLD, although their applications can sometimes
overlap
Chapter 1:Binary to Decimal Conversion
38

 Convert binary to decimal by summing the positions


that contain a 1:

• An example with a greater number of bits:


Chapter 1:Decimal to Binary Conversion
39

Repeated Division-
by-2 Method

Divide the decimal


number by 2.
Write the remainder
after each division
until a quotient of
zero is obtained.
The first remainder
is the LSB.
The last is the MSB.
Chapter 1:Decimal to Binary Conversion
40

Repeated
Division
This flowchart
describes the
process and can
be used to convert
from decimal to
any other number
system.
Chapter 1:Decimal to Binary Conversion
41

 Convert 3710 to binary:


Chapter 1:Decimal to Binary Conversion
42

Converting Decimal Fractions to Binary

You can convert a decimal fraction to binary by repeatedly


multiplying the fractional results of successive multiplications by 2.
The carries form the binary number.
Convert the decimal fraction 0.188 to binary by repeatedly
multiplying the fractional results by 2.
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
Answer = .00110 (for five significant digits)
Chapter 1:Binary Addition
43

The rules for binary addition are


0 + 0 = 0 Sum = 0, carry = 0
0 + 1 = 1 Sum = 1, carry = 0
1 + 0 = 1 Sum = 1, carry = 0
1 + 1 = 0 Sum = 0, carry = 1
Add the binary numbers 00111 and 10101 and show the equivalent
decimal addition.
0111
00111 7
10101 21
11100 = 28
Chapter 1:Binary Subtraction
44

The rules for binary subtraction are


0-0=0
1-1=0
1-0=1
0 - 1 = 1 with a borrow of 1
Subtract the binary number 00111 from 10101 and
show the equivalent decimal subtraction.
111
10101
/ / / 21
00111 7
01110 = 14
Chapter 1:Binary Multiplication
45

The rules for binary multiplication are


0x0=0
0x1=0
1x0=0
1x1=1
Multiplication is performed with binary numbers in the same manner as
with decimal numbers.
Chapter 1: Binary Division
46

Division is performed with binary numbers in the same manner as with


decimal numbers.
Chapter 1:Hexadecimal Number System
47

 Hexadecimal allows convenient handling of long


binary strings, using groups of 4 bits—Base 16
 16 possible symbols: 0-9 and A,B,C,D,E,F
 The digit positions are weighted as powers of 16 as
shown below, rather than as powers of 10 as in the
decimal system.
Chapter 1:Hexadecimal Number System
48

Relationships between
hexadecimal, decimal, and
binary numbers.
Chapter 1:Hexadecimal Number System
49

 Convert from hex to decimal by multiplying each


hex digit by its positional weight.

• In a 2nd example, the value 10 was substituted


for A and 15 substituted for F.

For practice, verify that 1BC216 is equal to 710610


Chapter 1:Hexadecimal Number System
50

 Convert from decimal to hex by using the repeated division method


used for decimal to binary conversion.
 Divide the decimal number by 16
 The first remainder is the LSB—the last is the MSB.

Convert 42310 to hex:


Chapter 1:Hexadecimal Number System
51

Hex to Binary
 Leading zeros can be added to the left of the MSB to
fill out the last group.

For practice, verify that BA616 = 1011101001102


Chapter 1:Hexadecimal Number System
52

Hex to Binary
 Convert from binary to hex by grouping bits in four
starting with the LSB.
Each group is then converted to the hex equivalent
• The binary number is grouped into groups of four bits &
each is converted to its equivalent hex digit.

For practice, verify that 1010111112 = 15F16


Chapter 1:Hexadecimal Number System
53

Decimal to Hex to Binary


 Convert decimal 378 to a 16-bit binary number
by first converting to hexadecimal.
Chapter 1:Hexadecimal Number System
54

Counting in Hex
 When counting in hex, each digit position can
be incremented (increased by 1) from 0 to F.
 On reaching value F, it is reset to 0, and the
next digit position is incremented.

Example:
38,39,3A,3B,3C,3D,3E,3F,40,41,42
When there is a 9 in a digit position, it becomes an A when it is incremented.

With three hex digits, we can count from 00016 to FFF16


which is 010 to 409510 — a total of 4096 = 163 values.
Chapter 1:Hexadecimal Number System
55

Question

1. Convert 24CE16 to decimal.


2. Convert 311710 to hex, then from hex to binary.
3. Convert 10010111101101012 to hex.
4. Write the next four numbers in this hex counting sequence: E9A, E9B,
E9C, E9D, , , , .
5. Convert 352716 to binary.
6. What range of decimal values can be represented by a four-digit hex
number?
Chapter 1: Octal Number System
56

The octal number system is composed of eight digits: 0, 1, 2, 3, 4, 5, 6, 7


Counting in octal is similar to counting in decimal, except that the digits 8 and 9
are not used
Octal-to-Decimal Conversion
Similar to Hexadecimal – Decimal
Decimal-to-Octal Conversion
Octal-to-Binary Conversion
Similar to Hexadecimal – Binary
Binary-to-Octal Conversion (but 1 octal digit 3bits)
Chapter 1: Octal Number System
57
Chapter 1: BCD Code
58

 Binary Coded Decimal (BCD) is a widely used


way to present decimal numbers in binary form.
 Combines features of both decimal and binary systems.
 Each digit is converted to a binary equivalent.
 BCD is not a number system.
 Itis a decimal number with each digit encoded
to its binary equivalent.
 A BCD number is not the same as a straight binary
number.
 The primary advantage of BCD is the relative
ease of converting to and from decimal.
Chapter 1: BCD Code
59

 Convert the number 87410 to BCD:


 Each decimal digit is represented using 4 bits.
 Each 4-bit group can never be greater than 9.

• Reverse the process to convert BCD to decimal.


Chapter 1: BCD Code
60

 Convert 0110100000111001 (BCD) to its decimal


equivalent.

Divide the BCD number into four-bit


groups and convert each to decimal.

 Convert BCD 011111000001 to its decimal equivalent.

The forbidden group represents


an error in the BCD number.
Chapter 1: BCD Code
61

BCD Addition
Step 1: Add the two BCD numbers
Step 2: If a 4-bit sum is equal to or less than 9, it is a valid BCD number.
Step 3: If a 4-bit sum is greater than 9, or if a carry out of the 4-bit group is
generated, it is an invalid result. Add 6 (0110) to the 4-bit sum in order to skip the
six. If a carry results when 6 is added, simply add the carry to the next 4-bit group.
Chapter 1: Gray Code
62

 The Gray code is used in applications where numbers


change rapidly.
 Only one bit changes from each value to the next.
 Gray code is used to avoid problems in systems where an
error can occur if more than one bit changes at a time.

Three bit binary


and Gray code
equivalents.
Chapter 1: Gray Code
63

Binary to Gray Gray to Binary


Compare the MSB binary with the next binary bit (B1). If they are the same, then G1 = 0. If
they are different, then G1 = 1. G0 can be found by comparing B1 with B0.
Chapter 1: Gray Code
64

Decimal numbers 1 – 15 in binary, hex, BCD, Gray


Chapter 1: The Byte, Nibble, and Word
65

 Most microcomputers handle and store binary data and


information in groups of eight bits.
8 bits = 1 byte.
 A byte can represent numerous types of data/information.
 Binary numbers are often broken into groups of four bits.
 Because a group of four bits is half as big as a
byte, it was named a nibble.
 A word is a group of bits that represents a certain unit of
information.
 Word size can be defined as the number of bits in the binary
word a digital system operates on.
 PC word size is eight bytes (64 bits).
Chapter 1: ASCII
66

ASCII – American Standard Code for Information Interchange.


Seven bit code: 27 = 128 possible code groups
Examples of use: transfer information between computers;
computers & printers; internal storage.
Chapter 1: Parity Method For Error Detection
67

The movement of binary data and codes from one location to


another is the most frequent operation performed in digital systems.

There is a possibility that errors can occur such that the receiver does
not receive the identical information that was sent by the transmitter.

One of the simplest and most widely used schemes for error detection
is the parity method
Chapter 1: Parity Method For Error Detection
68

Parity bit
A parity bit is an extra bit that is attached to a code group that is
being transferred from one location to another.
The parity bit is made either 0 or 1, depending on the number of
1s that are contained in the code group.
The even-parity method, the value of the parity bit is chosen so
that the total number of 1s in the code group (including the parity
bit) is an even number.

The odd-parity method is used in exactly the same way except that
the parity bit is chosen so the total number of 1s (including the
parity bit) is an odd number.
The parity bit is issued to detect any single-bit errors
Chapter 1: 1’s complement
69

The 1’s complement of a binary number is just the inverse of the


digits. To form the 1’s complement, change all 0’s to 1’s and all
1’s to 0’s.
For example, the 1’s complement of 11001010 is
00110101
In digital circuits, the 1’s complement is formed by using inverters:
1 1 0 0 1 0 1 0

0 0 1 1 0 1 0 1
Chapter 1: 2’s complement
70

The 2’s complement of a binary number is found by adding 1


to the LSB of the 1’s complement.
Recall that the 1’s complement of 11001010 is
00110101 (1’s complement)
To form the 2’s complement, add 1: +1
1 1 0 0 1 0 1 0 00110110 (2’s complement)
1

0 0 1 1 0 1 0 1
Input bits
Carry
Adder
in (add 1)
Output bits (sum)

0 0 1 1 0 1 1 0
Chapter 1: 2’s complement
71

An alternative method of finding the 2’s complement of a binary


number is as follows:
1. Start at the right with the LSB and write the bits as they
are up to and including the first 1.
2. Take the 1’s complements of the remaining bits.
Chapter 1: Signed Binary Numbers
72

There are several ways to represent signed binary numbers. In all cases, the
MSB in a signed number is the sign bit, that tells you if the number is
positive or negative.
Sign-Magnitude Form
When a signed binary number is represented in sign-magnitude, the left-most
bit is the sign bit and the remaining bits are the magnitude bits.

In the sign-magnitude form, a negative number has the same magnitude


bits as the corresponding positive number but the sign bit is a 1 rather
than a zero.
Chapter 1: Signed Binary Numbers
73

1’s Complement Form


Positive numbers in 1’s complement form are represented the same
way as the positive sign-magnitude numbers.

Negative numbers, however, are the 1’s complements of the


corresponding Positive numbers.

In the 1’s complement form, a negative number is the 1’s complement


of the corresponding positive number.

For example, using eight bits, the decimal number -25 is expressed
as the 1’s complement of +25 (00011001) as 11100110
Chapter 1: Signed Binary Numbers
74

2’s Complement Form


Positive numbers in 2’s complement form are represented the same
way as in the sign magnitude and 1’s complement forms.
Negative numbers are the 2’s complements of the corresponding
Positive numbers.
In the 2’s complement form, a negative number is the 2’s complement
of the corresponding positive number.
Example: Using eight bits, let’s take decimal number -25 and express
it as the 2’s complement of +25 (00011001).
Inverting each bit and adding 1, you get -25 = 11100111
For 2’s complement signed numbers, the range of values for n-bit
numbers is
Chapter 1: Signed Binary Numbers
75
Chapter 1: Signed Binary Numbers
76

Negative numbers are written as the 2’s complement of the


corresponding positive number.
The negative number -58 is written as:
-58 = 11000110 (complement form)
Sign bit Magnitude bits
An easy way to read a signed number that uses this notation is to
assign the sign bit a column weight of -128 (for an 8-bit number).
Then add the column weights for the 1’s.
Assuming that the sign bit = -128, show that 11000110 = -58
as a 2’s complement signed number:
Column weights: -128 64 32 16 8 4 2 1.
1 1 0 0 0 1 1 0
-128 +64 +4 +2 = -58
Chapter 1: Signed Binary Numbers
77

Arithmetic Operations with Signed Numbers


Using the signed number notation with negative numbers in 2’s
complement form simplifies addition and subtraction of signed
numbers.
Rules for addition: Add the two signed numbers. Discard any
final carries. The result is in signed form.
Examples:
00011110 = +30 00001110 = +14 11111111 = -1
00001111 = +15 11101111 = -17 11111000 = -8
00101101 = +45 11111101 = -3 1 11110111 = -9
Discard carry
Chapter 1: Signed Binary Numbers
78
Chapter 1: Signed Binary Numbers
79

Arithmetic Operations with Signed Numbers


Note that if the number of bits required for the answer is exceeded,
overflow will occur.
This occurs only if both numbers have the same sign. The overflow
will be indicated by an incorrect sign bit.
Two examples are:

01000000 = +128 10000001 = -127


01000001 = +129 10000001 = -127
10000001 = -126 Discard carry 100000010 = +2

Wrong! The answer is incorrect


and the sign bit has changed.
Chapter 1: Signed Binary Numbers
80

Numbers added two at a time


Chapter 1: Signed Binary Numbers
81

Subtraction
Subtraction is a special case of addition. The subtraction operation
changes the sign of the subtrahend and adds it to the minuend.
The result of subtraction is called the difference.

Example: subtracting +6 (the subtrahend) from +9 (the minuend) is


equivalent to adding -6 to +9.

The sign of a positive or negative binary number is changed by taking its


2’s complement.

To subtract two signed numbers, take the 2’s complement of the subtrahend
and add. Discard any final carry bit.
Chapter 1: Signed Binary Numbers
82

Rules for subtraction: 2’s complement the subtrahend and add the
numbers. Discard any final carries. The result is in signed form.

Repeat the examples done previously, but subtract:


00011110 (+30) 00001110 (+14) 11111111 (-1)
- 00001111 –(+15) - 11101111 –(-17) - 11111000 –(-8)
2’s complement subtrahend and add:
00011110 = +30 00001110 = +14 11111111 = -1
11110001 = -15 00010001 = +17 00001000 = +8
1 00001111 = +15 00011111 = +31 1 00000111 = +7
Discard carry Discard carry
Chapter 1: Signed Binary Numbers
83
Chapter 1: Signed Binary Numbers
84
Chapter 1: Signed Binary Numbers
85

Multiplication
The numbers in a multiplication are the multiplicand, the multiplier, and the product

The sign of the product of a multiplication depends on the signs of the


multiplicand and the multiplier according to the following two rules:

• If the signs are the same, the product is positive.


• If the signs are different, the product is negative.

Two basic methods: Direct addition and partial products


Chapter 1: Signed Binary Numbers
86

Multiplication
In the direct addition method, you add the multiplicand a number of times equal
to the multiplier.
Chapter 1: Signed Binary Numbers
87

Multiplication
The partial products method is perhaps the more common one because it
reflects the way you multiply longhand. The multiplicand is multiplied by each
multiplier digit beginning with the least significant digit. The result of the
multiplication of the multiplicand by a multiplier digit is called a partial product.
Chapter 1: Signed Binary Numbers
88

The basic steps in the partial products method of binary multiplication:


Step 1: Determine if the signs of the multiplicand and multiplier are the
same or different. This determines what the sign of the product will be.
Step 2: Change any negative number to true (uncomplemented) form.
Because most computers store negative numbers in 2’s complement, a
2’s complement operation is required to get the negative number into
true form.
Step 3: Starting with the least significant multiplier bit, generate the
partial products. When the multiplier bit is 1, the partial product is the
same as the multiplicand. When the multiplier bit is 0, the partial
product is zero. Shift each successive partial product one bit to the left.
Step 4: Add each successive partial product to the sum of the previous
partial products to get the final product.
Step 5: If the sign bit that was determined in step 1 is negative, take
the 2’s complement of the product. If positive, leave the product in true
form. Attach the sign bit to the product.
Chapter 1: Signed Binary Numbers
89
Chapter 1: Signed Binary Numbers
90
Chapter 1: Signed Binary Numbers
91
Chapter 1: Signed Binary Numbers
92

Division
The numbers in a division are the dividend, the divisor, and the quotient. These
are illustrated in the following standard division format.

The sign of the quotient depends on the signs of the dividend and the divisor
according to the following two rules:

• If the signs are the same, the quotient is positive.


• If the signs are different, the quotient is negative.
Chapter 1: Signed Binary Numbers
93

Division
The basic steps in a division process are as follows:
Step 1: Determine if the signs of the dividend and divisor are the same or
different. This determines what the sign of the quotient will be. Initialize the
quotient to zero.
Step 2: Subtract the divisor from the dividend using 2’s complement addition to
get the first partial remainder and add 1 to the quotient. If this partial remainder
is positive, go to step 3. If the partial remainder is zero or negative, the division
is complete.
Step 3: Subtract the divisor from the partial remainder and add 1 to the quotient.
If the result is positive, repeat for the next partial remainder. If the result is zero
or negative, the division is complete.
Continue to subtract the divisor from the dividend and the partial remainders
until there is a zero or a negative result. Count the number of times that the
divisor is subtracted and you have the quotient.
Chapter 1: Signed Binary Numbers
94
Chapter 1: Signed Binary Numbers
95

You might also like