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

chap1

The document outlines the ELEC 335 Digital Logic Design course at UAE University, covering topics such as numerical representations, digital and analog systems, and digital circuits. It details course learning outcomes, including manipulation of number systems and design of combinational logic circuits. Additionally, it introduces key concepts of digital systems, binary numbers, and their conversions.

Uploaded by

Ali Abdulhadi
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)
4 views

chap1

The document outlines the ELEC 335 Digital Logic Design course at UAE University, covering topics such as numerical representations, digital and analog systems, and digital circuits. It details course learning outcomes, including manipulation of number systems and design of combinational logic circuits. Additionally, it introduces key concepts of digital systems, binary numbers, and their conversions.

Uploaded by

Ali Abdulhadi
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/ 88

ELEC 335

Digital Logic Design


Dr. Abdul-Halim Jallad
Office 1162 – Building F1
a.Jallad@uaeu.ac.ae

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Chapter 1

Introduction to Digital Logic

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Outline
• Introduction
• Numerical representations
• Digital and analog systems
• Digital number systems
• Digital circuits/logic circuits
• Parallel and serial transmission
• Digital computers

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Introduction
• The term digital has become part of our
everyday vocabulary because of its use in:
– computers
– automation
– robots
– medical science and technology
– transportation
– entertainment
– space exploration

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Introduction
• In this course you will learn the fundamental
principles, concepts, and operations that are
common to all digital systems
• You will gain a deep understanding of how
digital systems work

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Course Learning Outcomes
1. Manipulate number system, binary codes, and computer arithmetic. [PLO-1]
2. Apply Boolean algebra and Karnaugh map minimization techniques to
simplify Boolean expressions. [PLO-1]
3. Design binary adders, decoders, encoders, multiplexers, and de-multiplexers
to implement combinational logic circuits. [PLO-1, 2]
4. Design with flip-flops, synchronous and asynchronous sequential circuits,
state diagrams, and state tables. [PLO-1, 2]
5. Design registers (serial, parallel, and shift) ripple counters, and synchronous
counters. [PLO-1, 2]
6. Design digital circuits with memory devices of ROMs, PLAs, & PALs. [PLO-2, 4]

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Course Textbook
Introduction to Logic Design

Alan B. Marcovitz

◦ Third Edition

◦ McGraw Hill

◦ 2010
Numerical Representations
• In science, technology, business and other
fields, we deal with quantities.
• Quantities are measured, monitored, recorded,
manipulated arithmetically and observed in
most physical systems
• It is important when dealing with various
quantities that we be able to represent their
values efficiently and accurately

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Analog Representations
• A quantity is represented by a voltage, current, or
meter movement that is proportional to the value
of that quantity
• Example 1: Analog automobile speedometer
• Example 2: Glass thermometer

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Digital Representations
• Quantities are represented not by proportional
quantities but by symbols called digits
• The quantity changes in discrete steps
• Example 1: Digital watch
• Example 2: Digital thermometer

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Analog and digital signals

40
30 Analog signal
20
10

40
30
20 Digital signal
10

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Analog Systems
• An analog system contains devices that
manipulate physical quantities that are
represented in analog form; the quantity
varies over a continuous range of values
• Examples: speaker, audio amplifiers, magnetic
tape recording and playback, simple light
dimmer switch
CD drive

10110011101 Digital-to-analog Linear amplifier


Digital data converter Analog
reproduction
of music audio Speaker
signal
Sound
ELEC 335, DIGITAL LOGIC DESIGN, UAE waves
UNIVERSITY
Recording of Audio CD
+V

-V
Human sound Voltage signal

Store Analog to
digital
0 1 0 1 1 0 converter

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Digital Systems
• A digital system is a combination of devices designed to
manipulate logical information or physical quantities that
are represented in digital form; the quantities take only
discrete values.

• Most often, it is electronic; however, it can also be


mechanical, magnetic, or pneumatic.

• Examples: digital computers, calculators, digital audio and


video equipment and the telephone system

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Digital Computers
• A Digital computer is a system of hardware that
performs arithmetic operations, manipulates data
(usually in binary form), and makes decisions

• A computer must be given a complete set of


instructions that tell it exactly what to do at each
step of its operation. The set of instructions is
called a program

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Major Parts of a Computer
Central Processing Unit (CPU)

Arithmetic/
Logic

Data Input Control Output Data,


information

Memory Control signals


Data or information

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Binary Digits and Logic Levels
Digital electronics uses circuits that have two states, which
are represented by two different voltage levels called HIGH
and LOW. The voltages represent numbers in the binary
system.
VH(max)
In binary, a single number is HIGH
called a bit (for binary digit). A VH(min)

bit can have the value of either Invalid


VL(max)
a 0 or a 1, depending on if the
voltage is HIGH or LOW. LOW
VL(min)

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Binary Digits and Logic Levels
• The two digits in the binary system, 1 and 0, are
called bits
• A 1 is represented by the higher (usually) voltage,
which we will refer to as a HIGH
• A 0 is represented by the lower voltage level,
which we will refer to as a LOW

HIGH = 1 and LOW = 0

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Typical Voltage Assignment in
Digital Systems
Digital waveforms are made of voltage levels that are HIGH AND
LOW and also they contain a series of pulses.

5V
Binary 1
2V 1 1
Not used 4V
0.8 V
Binary 0 0 0
0V 0V t
t1 t2 t3 t4 t5

Typical Voltage Assignments Typical Timing Diagram


(Transistor-Transistor-Logic (TTL) (Digital waveform)
ELEC 335, DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
Waveforms and Pulses
• A periodic pulse is a waveform that repeats pulses
at a fixed period
• Frequency in Hertz = 1/ period
• f = 1/ T
T = 200ns

f = 1/200x10-9 = 109/200
= 5x106 = 5 MHz

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Numbering Systems
and Conversions

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Number System & Codes
• In a decimal system (base-10), 10 symbols are used to
construct any number. The symbols are: 0, 1, 2, 3, 4, 5, 6,
7, 8, 9
• How do you read 1234.567?
– 1000 plus 200 plus 30 plus 4 plus 5 tenth plus 6 hundredth plus
7 thousandth
– That is: 1 x 103 + 2 x 102 + 3 x 101 + 4 x 100 + 5 x 10-1
+ 6 x 10-2 + 7 x 10-3
1234.567

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Binary number system
• It is very difficult to design electronic
equipment so that it can work with ten different
voltage levels

• on the other hand, it is very easy to design


simple, accurate electronic circuits that operate
with only two voltage levels

• In the binary system there are only two symbols


or possible digit values, 0 and 1
ELEC 335, DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
Binary Numbers
• Each binary digit (called a bit) is either 1 or 0

• Bits have no inherent meaning, they can represent …

 Unsigned and signed integers


Most Least
Significant Bit Significant Bit
 Fractions
7 6 5 4 3 2 1 0
 Characters 1 0 0 1 1 1 0 1
27 26 25 24 23 22 21 20
 Images, sound, etc.

• Bit Numbering

 Least significant bit (LSB) is rightmost (bit 0)

 Most significant bit (MSB) is leftmost (bit 7 in an 8-bit number)


ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY
Decimal Value of Binary Numbers
 Each bit represents a power of 2

 Every binary number is a sum of powers of 2

 Decimal Value = (dn-1 × 2n-1) + ... + (d1 × 21) + (d0 × 20)

 Binary (10011101)2 = 27 + 24 + 23 + 22 + 1 = 157

7 6 5 4 3 2 1 0
1 0 0 1 1 1 0 1
27 26 25 24 23 22 21 20

Some common
powers of 2
Binary number system Example
• 1011.1012 = 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20 +
1 x 2-1 + 0 x 2-2 + 1 x 2-3
= 8 + 0 + 2 + 1 + 0.5 + 0 + 0.125
= 11.62510

1 0 1 1 . 1 0 1

Binary
MSB LSB
point
ELEC 335, DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
Binary Counting
23 = 8 22 = 4 21 = 2 20 = 1
0 0 0 0
0 0 0 1
0 0 1 0
0 10 100 1000
0 0 1 1
1 11 101 1001
0 1 0 0
0 1 0 1
110 1010
0 1 1 0 111 1011
0 1 1 1 1100
1 0 0 0 1101
1 0 0 1 1110
1 0 1 0 1111
1 0 1 1

1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 ELEC 335,
1 DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
Decimal Binary
Number Number
Binary Numbers 0 0000
1 0001
A binary counting sequence for numbers from zero to 2 0010
fifteen is shown. 3 0011
4 0100
Notice the pattern of zeros and ones in each 5 0101
column.
6 0110
Digital counters frequently have this same pattern of 7 0111
digits: 8 1000
9 1001
Counter 0 1 0 1 0 1 0 1 0 1 Decoder
10 1010
0 0 1 1 0 0 1 1 0 0
11 1011
12 1100
0 0 0 0 1 1 1 1 0 0
13 1101
0 0 0 0 0 0 0 0 1 1
14 1110
15 1111

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Decimal Binary
Number Number
Binary Numbers 0 0000
1 0001
A binary counting sequence for numbers from zero to 2 0010
fifteen is shown. 3 0011
4 0100
Notice the pattern of zeros and ones in each 5 0101
column.
6 0110
Digital counters frequently have this same pattern of 7 0111
digits: 8 1000
9 1001
Counter 0 1 0 1 0 1 0 1 0 1 Decoder
10 1010
0 0 1 1 0 0 1 1 0 0
11 1011
12 1100
0 0 0 0 1 1 1 1 0 0
13 1101
0 0 0 0 0 0 0 0 1 1
14 1110
15 1111

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Binary Conversions

The decimal equivalent of a binary number can be determined by adding the


column values of all of the bits that are 1 and discarding all of the bits that are
0.

Convert the binary number 100101.01 to decimal.

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¼

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Binary Conversions

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)

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Base-b to decimal (base-10)
• To convert from base-b to decimal, simply
multiply each digit by b raised to the power
corresponding to the position of the digit
• Ex: convert 310.234 to decimal

3 x 42 + 1 x 41+ 0 x 40 + 2 x 4-1 + 3 x 4-2

= 48 + 4 + 0 + 2/4 + 3/16
= 52.6875
ELEC 335, DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
Hexadecimal numbers
• In a hexadecimal system there are 16 different
digits, namely, 0 to 9 and A, B, C, D, E, and F

Decimal Binary Hexadecimal


0 to 9 0000 to 1001 0 to 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Hexadecimal to decimal
• To convert from a hexadecimal number, simply
multiply each hex-digit by the corresponding
power of 16
• Ex: convert 1AB.CD to decimal
1AB.CD16 = 1 x 162 + 10 x 161 + 11 x 160
+ 12 x 16-1 + 13 x 16-2
= 256 + 160 + 11 + 0.75 + 0.05078
= 427.8007810

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Hexadecimal and binary numbers
• To convert a binary number to hexadecimal
number, simply group each 4 binary digits into
one hex-digit
• Ex: convert 110001101111.0101 to hex

C 6 F . 5
copy
To convert a hex number to binary
binary, perform the opposite point
operation
ELEC 335, DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
Octal number system
• The octal number system has a base of eight, that
means it has eight different digits, namely, 0, 1, 2,
3, 4, 5, 6, and 7
• To convert an octal number to decimal, simply
multiply each digit by the corresponding power of
eight
• Ex: 3728 = 3 x 82 + 7 x 81 + 2 x 80
= 3 x 64 + 7 x 8 + 2 x 1
= 25010
ELEC 335, DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
Converting Octal & Hex to Decimal
Octal to Decimal: N8 = (dn-1 × 8n-1) +... + (d1 × 8) + d0

Hex to Decimal: N16 = (dn-1 × 16n-1) +... + (d1 × 16) + d0

Examples:

(7204)8 = (7 × 83) + (2 × 82) + (0 × 8) + 4 = 3716

(3BA4)16 = (3 × 163) + (11 × 162) + (10 × 16) + 4 = 15268

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Converting from decimal to binary
• To convert a number from base-10 to base-2, you
successively divide the number by 2 and keep
track of the remainder
• Ex: convert 12 to binary

Number Result of division by 2 remainder


12 12/2 = 6 0
6 6/2 = 3 0
3 3/2 = 1 1
1 1/2 = 0 1

The final result is 1 1 0 0


ELEC 335, DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
Base-10 to base-b
• For non-fractional part, repeatedly divide the
number by b and keep track of remainders

• For fractions, repeatedly multiply the fraction


by b and keep track of whole number values

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Converting Decimal to Hexadecimal
 Repeatedly divide the decimal integer by 16

 Each remainder is a hex digit in the translated value

 Example: convert 422 to hexadecimal

least significant digit

most significant digit

422 = (1A6)16 stop when


quotient is zero

 To convert decimal to octal divide by 8 instead of 16


ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY
Base-10 to base-b
• Ex: convert the decimal number 325.512 to base_5

Number Result of division by 5 remainder


325 325/5 = 65 0
65 65/5 = 13 0
13 13/5 = 2 3
2 2/5 = 0 2

Fraction Fraction multiplied by 5 Whole number


0.512 0.512X5 = 2.56 2
0.56 0.56X5 = 2.8 2
0.8 0.8X5 = 4.0 4
The number is 2300.224
ELEC 335, DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
Octal numbers and binary numbers
• There is a simple way to convert a binary number
to octal (without converting to decimal first)
• Starting from the binary point, group each three
digits into one octal digit
• Ex: convert 101110111.100010 to octal

5 6 7 . 4 2
copy
binary
point
ELEC 335, DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
Octal number to binary number
• To convert from octal to binary, simply expand
each octal digit into 3 binary digits
• Ex: convert 436.57 to binary

100 011 110 . 101 111


copy
binary
point

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Binary Codes

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Binary Codes
How to represent characters, colors, etc?

Define the set of all represented elements

Assign a unique binary code to each element of the set

Given n bits, a binary code is a mapping from the set of elements to a


subset of the 2n binary numbers

Coding Numeric Data (example: coding decimal digits)

• Coding must simplify common arithmetic operations

• Tight relation to binary numbers

Coding Non-Numeric Data (example: coding colors)

• More flexible codes since arithmetic operations are not applied

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Example of Coding Non-Numeric Data
Suppose we want to code 7 colors of the rainbow

As a minimum, we need 3 bits to define 7 unique values

3 bits define 8 possible combinations Color 3-bit code


Red 000
Only 7 combinations are needed Orange 001
Yellow 010
Code 111 is not used
Green 011
Other assignments are also possible Blue 100
Indigo 101
Violet 110
Decimal Codes
Binary number system is most natural for computers

But people are used to the decimal number system

Must convert decimal numbers to binary, do arithmetic on binary numbers,


then convert back to decimal

To simplify conversions, decimal codes can be used

Define a binary code for each decimal digit

Since 10 decimal digits exit, a 4-bit code is used

But a 4-bit code gives 16 unique combinations

10 combinations are used and 6 will be unused


Binary codes
• When numbers, letters, or words represented by
a special group of symbols, we say that they are
being encoded, and the group of symbols are
called a code
• When a decimal number is represented by its
equivalent binary number, we call it straight
binary coding
• Conversion between decimal and binary can
become long and complicated, for this reason
some feature of both the decimal and the binary
system is used in certain situations
ELEC 335, DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
Decimal Binary BCD
BCD 0 0000 0000
1 0001 0001
Binary coded decimal (BCD) is a weighted 2 0010 0010
code that is commonly used in digital systems
3 0011 0011
when it is necessary to show decimal
4 0100 0100
numbers such as in clock displays.
5 0101 0101
The table illustrates the difference 6 0110 0110
between straight binary and BCD. BCD 7 0111 0111
represents each decimal digit with a 4-bit 8 1000 1000
code. Notice that the codes 1010 through 9 1001 1001
1111 are not used in BCD. 10 1010 0001 0000
11 1011 0001 0001
12 1100 0001 0010
13 1101 0001 0011
Example on BCD coding: 14 1110 0001 0100
15 1111 0001 0101
13 ⇔ (0001 0011)BCD
ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY
BCD conversions
• To convert a BCD to decimal, simply convert each
group of 4 bits into a decimal digit
• Ex: convert 100100010101 to decimal

9 1 5
• To convert a decimal number to BCD, simply take
each decimal digit and expand it to its binary
• Ex: convert 874 to BCD

1000 0111 0100


ELEC 335, DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
Warning: Conversion or Coding?
Do NOT mix up conversion of a decimal number to a binary number with
coding a decimal number with a binary code

1310 = (1101)2 This is conversion

13 ⇔ (0001 0011)BCD This is coding

In general, coding requires more bits than conversion

A number with n decimal digits is coded with 4n bits in BCD


Character Codes
Character sets
◦ Standard ASCII: 7-bit character codes (0 – 127)
◦ Extended ASCII: 8-bit character codes (0 – 255)
◦ Unicode: 16-bit character codes (0 – 65,535)
◦ Unicode standard represents a universal character set
◦ Defines codes for characters used in all major languages

◦ Each character is encoded as 16 bits

◦ UTF-8: variable-length encoding used in HTML


◦ Encodes all Unicode characters

◦ Uses 1 byte for ASCII, but multiple bytes for other characters

Null-terminated String
◦ Array of characters followed by a NULL character
Printable ASCII Codes
0 1 2 3 4 5 6 7 8 9 A B C D E F
2 space ! " # $ % & ' ( ) * + , - . /
3 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
4 @ A B C D E F G H I J K L M N O
5 P Q R S T U V W X Y Z [ \ ] ^ _
6 ` a b c d e f g h i j k l m n o
7 p q r s t u v w x y z { | } ~ DEL

 Examples:
 ASCII code for space character = 20 (hex) = 32 (decimal)
 ASCII code for 'L' = 4C (hex) = 76 (decimal)
 ASCII code for 'a' = 61 (hex) = 97 (decimal)
Gray code

A shaft encoder is a typical application. Three IR


emitter/detectors are used to encode the position of the shaft.
The encoder on the left uses binary and can have three bits
change together, creating a potential error. The encoder on the
right uses gray code and only 1-bit changes, eliminating
potential errors.

Binary sequence
Gray code sequence

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Binary Arithmetic

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Adding Bits
1 + 1 = 2, but 2 should be represented as (10)2 in binary

Adding two bits: the sum is S and the carry is C

X 0 0 1 1
+Y +0 +1 +0 +1
CS 00 01 01 10
Adding three bits: the sum is S and the carry is C

0 0 0 0 1 1 1 1
0 0 1 1 0 0 1 1
+0 +1 +0 +1 +0 +1 +0 +1
00 01 01 10 01 10 10 11
Binary Addition
Start with the least significant bit (rightmost bit)

Add each pair of bits

Include the carry in the addition, if present

carry 1 1 1 1

0 0 1 1 0 1 1 0 (54)

+ 0 0 0 1 1 1 0 1 (29)

0 1 0 1 0 0 1 1 (83)
bit position: 7 6 5 4 3 2 1 0
Addition in base-b
• The rules of addition remain the same for base-b
• Consider additions in base-2 (binary) and base-16(hex)

011 0 11
1001 A2CE
0011 + B963 +
1 10 0 15C3 1

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Subtracting Bits
Subtracting 2 bits (X – Y): we get the difference (D) and the borrow-out (B)
shown as 0 or -1

X 0 0 1 1
–Y –0 –1 –0 –1
BD 00 -1 1 01 00

Subtracting two bits (X – Y) with a borrow-in = -1: we get the difference (D)
and the borrow-out (B)
borrow-in -1 -1 -1 -1 -1
X 0 0 1 1
–Y –0 –1 –0 –1
BD -1 1 -1 0 00 -1 1
Binary Subtraction
Start with the least significant bit (rightmost bit)
Subtract each pair of bits
Include the borrow in the subtraction, if present

borrow -1 -1 -1

0 0 1 1 0 1 1 0 (54)

– 0 0 0 1 1 1 0 1 (29)

0 0 0 1 1 0 0 1 (25)
bit position: 7 6 5 4 3 2 1 0
Binary Multiplication
Binary Multiplication table is simple:
0×0=0, 0×1=0, 1×0=0, 1×1=1
Multiplicand 11002 = 12
Multiplier × 11012 = 13
Binary multiplication is easy
1100
0000 0 × multiplicand = 0
1100 1 × multiplicand = multiplicand
1100
Product 100111002 = 156
n-bit multiplicand × n-bit multiplier = 2n-bit product
Accomplished via shifting and addition
Hexadecimal Addition
Start with the least significant hexadecimal digits
Let Sum = summation of two hex digits
If Sum is greater than or equal to 16
◦ Sum = Sum – 16 and Carry = 1

Example:
carry 1 1 1
9 C 3 7 2 8 6 5
+ 5 + B = 5 + 11 = 16
1 3 9 5 E 8 4 B Since Sum ≥ 16
Sum = 16 – 16 = 0
A F C D 1 0 B 0 Carry = 1
Multiplication in base-b
• The rules of multiplication remain the same
• Consider multiplication in base-2 and base-16

1001
0101 x
1001
0000 Add
1001
0000
0101101
ELEC 335, DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
Multiplication in base-16
201
1C2A
12B 3 x
5 4 7E
135CE Add
3854
1C2A
20EA55E

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Representing negative numbers
• There are three common ways to represent
negative numbers, they are:
– Sign magnitude
– 1’s complement
– 2’s complement
• Sign magnitude
– The sign and the magnitude are separate
– There is one sign bit, zero more positive and one
for negative
– The magnitude is usually represented by more than
one bit
ELEC 335, DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
Sign magnitude
• Assume 9 bits are used for the sign and the
magnitude
• Positive 8 is represented as: 0 00001000
• Negative 8 is represented as: 1 00001000
• The only difference between the negative and
the positive number is in the sign bit
• It is not clear how adding negative 8 to positive 8
yields zero! It is much more complicated than
simply adding the bits

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
1’s Complement

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

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


2’s Complement

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
00110110 (2’s complement)
1 1 0 0 1 0 1 0

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

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Signed Binary Numbers

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.

Computers use a modified 2’s complement for signed numbers. Positive


numbers are stored in true form (with a 0 for the sign bit) and negative
numbers are stored in complement form (with a 1 for the sign bit).

For example, the positive number 58 is written using 8-bits


as 00111010 (true form).

Sign bit Magnitude bits

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Signed Binary Numbers

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

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY
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

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


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.

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Addition in BCD
• To add two BCD codes, perform addition digit
by digit starting from the right hand side (least
significant digits) and adjust as necessary
• When the result of adding two BCD digits is a
digit that is greater than 1001 (9) or there is a
carry from the most significant bit, then
correction is necessary
• The correction operation consists of adding the
number 0110 (6) to the result

ELEC 335, DIGITAL LOGIC DESIGN, UAE


UNIVERSITY
Addition in BCD
11 11 000
0111 1001
0101 1000 +

00 01 Carry into next digit,


must adjust by adding 6
0110 +
1 101 0 111
Digit is greater than 9,
0110 + must adjust by adding 6

0001 0011
0001 0011 0111 Final result
ELEC 335, DIGITAL LOGIC DESIGN, UAE
UNIVERSITY
BCD

A lab experiment in which BCD is


converted to decimal is shown.

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


Decimal Binary Gray code
Gray code 0 0000 0000
1 0001 0001
Gray code is an unweighted code that has a 2 0010 0011
single bit change between one code word and
3 0011 0010
the next in a sequence. Gray code is used to
4 0100 0110
avoid problems in systems where an error can
occur if more than one bit changes at a time. 5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000

ELEC 335, DIGITAL LOGIC DESIGN, UAE UNIVERSITY


1. Compared to analog systems, digital systems
a. are less prone to noise
b. can represent an infinite number of values
c. can handle much higher power
d. all of the above
2. The number of values that can be assigned to a bit are
a. one
b. two
c. three
d. ten
6. If the period of a clock signal is 500 ps, the frequency is
a. 20 MHz
b. 200 MHz
c. 2 GHz
d. 20 GHz
1. For the binary number 1000, the weight of the column with the 1 is
a. 4
b. 6
c. 8
d. 10

© 2008 Pearson Education


2. The 2’s complement of 1000 is
a. 0111
b. 1000
c. 1001
d. 1010
3. The fractional binary number 0.11 has a decimal value of
a. ¼
b. ½
c. ¾
d. none of the above
4. The hexadecimal number 2C has a decimal equivalent value of
a. 14
b. 44
c. 64
d. none of the above

© 2008 Pearson Education


6. When two positive signed numbers are added, the result may be larger that
the size of the original numbers, creating overflow. This condition is indicated
by
a. a change in the sign bit
b. a carry out of the sign position
c. a zero result
d. smoke
7. The number 1010 in BCD is
a. equal to decimal eight
b. equal to decimal ten
c. equal to decimal twelve
d. invalid
8. An example of an unweighted code is
a. binary
b. decimal
c. BCD
d. Gray code
9. An example of an alphanumeric code is
a. hexadecimal
b. ASCII
c. BCD
d. CRC

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy