Sie sind auf Seite 1von 101

Digital Design

Thursday, Mar. 13
Dr. Asmaa Farouk
Assiut University
Instructors
• Dr. Asmaa Farouk, Assiut University
(asmaaf@au.edu.eg).

• TA: Eng. Mohammad Morsi


Material

• Textbook:
M. Morris Mano & Michael
D. Ciletti:
Digital Design
Course Overview
• Topics will be covered in this course
– Digital Systems and Binary Numbers.
– Boolean Algebra and Logic Gates.
– Gate-Level Minimization.
– Combinational Logic.
– Synchronous Sequential Logic.
– Registers and Counters.
Lecture # 1, 2

• Reading:
Mano:
Chapter 1.
Topics of Today
• Digital Systems.
• Binary Numbers.
• Number-Base Conversions.
• Octal and Hexadecimal Numbers.
• Complements of Numbers.
• Signed Binary Numbers.
• Binary Codes.
• Binary Logic.
Digital Systems
• Why digital systems?
– They are everywhere and generic.
• Digital computers, smart phones, data communication,
digital recording, digital TV, many others…
Digital Systems
• What is a digital system?
– Characteristic:
• Has a special‐purpose digital computer (processor)
embedded within it, follow a sequence of instructions,
called a program, that operates on given data.
• Ability of manipulating discrete elements of information
(data).
– Examples for discrete sets:
• Decimal digits {0, 1, …, 9}.
• Alphabet {A, B, …, Y, Z}.
• Binary digits {0, 1}.
Digital Systems
• How to represent data?
– In electronic circuits, we have electrical signals:
• Voltage.
• Current.
– In digital circuits (systems), we have just two
discrete values (binary):
• Just two signal levels: 0 V and 5 V (on & off).
• Two elements {0, 1}.
Topics of Today
• Digital Systems.
• Binary Numbers.
• Number-Base Conversions.
• Octal and Hexadecimal Numbers.
• Complements of Numbers.
• Signed Binary Numbers.
• Binary Codes.
• Binary Logic.
Binary Numbers
• Humans use decimal arithmetic (base 10) while
computers use the binary (base 2) system.
• Numbering systems.
– Decimal.
– Binary.
– Hexadecimal.
– Octal.
• To distinguish between different bases, we
enclose the number in parentheses and write a
subscript equal to the base used.
Binary Numbers
• Digits:
– In base 10 (decimal) there are 10 distinct digits:
• 0, 1, 2, 3, 4, 5, 6, 7, 8 & 9.
– In base 2 (binary) there are only two digits:
• 0 & 1.
• Commonly referred to as bits.
• The binary system is used in computers because the two
digits represent the two voltage levels off & on.
– In base 16 (hexadecimal) there are 10 digits and 6
letters:
• 0, 1, 2, 3, 4, 5, 6, 7, 8 , 9, A, B, C, D, E & F.
Binary Numbers
• The Radix:
– The radix of any numbering system is its base:
• Decimal => radix = 10.
• Binary => radix = 2.
• Hexadecimal => radix = 16.
• Octal => radix = 8.
Binary Numbers
• Significant Digits:
Binary Numbers
• Decimal (base 10):
– Uses positional representation.
– Each digit corresponds to a power of 10 based on its
position in the number.
– The powers of 10 increment from 0, 1, 2, etc. as you
move right to left.
– Example:
Binary Numbers
• Binary (base 2):
– Two digits: 0, 1.
– To make the binary numbers more readable, the
digits are often put in groups of 4.
– The powers of 2 increment from 0, 1, 2, etc. as you
move right to left (to convert to decimal).
– Example:
Binary Numbers
• Binary (base 2):
Binary Numbers
• Hexadecimal (base 16):
– 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
– Shorter & easier to read than binary.
– The “H” letter is often follow hexadecimal numbers.
– The powers of 16 increment from 0, 1, 2, etc. as you
move right to left (to convert to decimal).
– Example:
Binary Numbers
• Octal (base 8):
– 8 digits: 0, 1, 2, 3, 4, 5, 6, 7.
– Shorter & easier to read than binary.
– The powers of 8 increment from 0, 1, 2, etc. as you
move right to left (to convert to decimal).
– Example:
Binary Numbers
• Fractional Numbers:
– Point:
• Decimal point, binary Point, hexadecimal point.
– Decimal:

– Binary:

– Hexadecimal:
Binary Numbers
• Arithmetic with Binary Numbers:
10101 21 augend 10101 21 minuend
+ 10011 19 addend - 10011 19 subtrahend
1 01000 40 sum 0 00010 2 difference

0 0 1 0 multiplicand (2)
 1 0 1 1 multiplier (11)
0 0 1 0
0 0 1 0
0 0 0 0
+ 0 0 1 0
0 0 1 0 1 1 0 product (22)
Topics of Today
• Digital Systems.
• Binary Numbers.
• Number-Base Conversions.
• Octal and Hexadecimal Numbers.
• Complements of Numbers.
• Signed Binary Numbers.
• Binary Codes.
• Binary Logic.
Number-Base Conversions
• Converting to and from Decimal:
Number-Base Conversions
• Decimal Binary (or any numbering system):
– To convert from decimal (whole number) to any
numbering system:
1. Divide the decimal number by the radix of the system
you want to convert to.
2. Save the remainder (first remainder is the least
significant digit).
3. Repeat steps 1 and 2 until the quotient is zero.
4. Remainders are written in reverse order to obtain the
converted number.
Number-Base Conversions
• Decimal Binary (or any numbering system):
– Example (1): convert the decimal number 10 to
binary.

– Example (2): convert the decimal number 109 to


hexadecimal.
Number-Base Conversions
• Decimal Binary (or any numbering system):
– Example (3): convert the decimal number 94 to
octal.
Number-Base Conversions
• Decimal Binary (or any numbering system):
– To convert from decimal (fraction) to any
numbering system:
1. Multiply the decimal fraction by the radix of the system
you want to convert to.
2. Save the whole number portion of the result (even if
zero) as a digit. The first result is written immediately to
the right of the radix point.
3. Repeat steps 1 and 2, using the fractional part of step 2
until the fractional part of step 2 is zero.
Number-Base Conversions
• Decimal Binary (or any numbering system):
– Example (1): convert the decimal fraction number
0.125 to binary.
Number-Base Conversions
• Decimal Binary (or any numbering system):
– Example (2): convert the decimal fraction number
0.046875 to hexadecimal.
Number-Base Conversions
• Decimal Binary (or any numbering system):
– Exercise (1): convert the hexadecimal number 5A to
octal.
• Solution: First convert the hexadecimal number into its
decimal equivalent then, convert the decimal number into
its octal equivalent.
Number-Base Conversions
• Decimal Binary (or any numbering system):
– Exercise (1): convert the hexadecimal number 5A to
octal.
• Solution: First convert the hexadecimal number into its
decimal equivalent then, convert the decimal number into
its octal equivalent.
Number-Base Conversions
• Decimal Binary (or any numbering system):
– Exercise (2): convert the octal number 132 to binary.
• Solution: First convert the octal number into its decimal
equivalent then, convert the decimal number into its
binary equivalent.
Topics of Today
• Digital Systems.
• Binary Numbers.
• Number-Base Conversions.
• Octal and Hexadecimal Numbers.
• Complements of Numbers.
• Signed Binary Numbers.
• Binary Codes.
• Binary Logic.
Octal and Hexadecimal Numbers
• Since 23 = 8 and 24 = 16, each octal digit
corresponds to three binary digits and each
hexadecimal digit corresponds to four binary
digits.
• The conversion from binary to octal is easily
accomplished by partitioning the binary number
into groups of three digits each, starting from
the binary point and proceeding to the left and
to the right.
Octal and Hexadecimal Numbers
• Example (1):
Octal and Hexadecimal Numbers
• Example (1):

• Example (2):
Octal and Hexadecimal Numbers
Octal and Hexadecimal Numbers
• Each octal digit is converted to its three‐digit
binary equivalent. Similarly, each hexadecimal
digit is converted to its four‐digit binary
equivalent.
• Example (3):

• Example (4):
Topics of Today
• Digital Systems.
• Binary Numbers.
• Number-Base Conversions.
• Octal and Hexadecimal Numbers.
• Complements of Numbers.
• Signed Binary Numbers.
• Binary Codes.
• Binary Logic.
Complements of Numbers
• Complementing is an operation to simplify
subtraction operation.
– Turn the subtraction operation into an addition
operation.
• Two types:
1. Diminished complement ((r-1)’s complement).
2. Radix complement (r’s complement).
• When r = 2 (binary), they are called:
1. One’s (1’s) complement.
2. Two’s (1’s) complement.
Complements of Numbers
• Diminished Complement (r -1)’s Complement:
– Each digit of the number is subtracted from the
radix -1 to represent a negative number.
– In binary system it is called one’s (1’s) complement
(since radix – 1 = 2 -1 = 1).
Complements of Numbers
• Diminished Complement (r -1)’s Complement:
– Example (1): compute the radix – 1 (one’s)
complement of the binary number 0100 1100.

• Equivalent to inverting the binary number (NOT


operation).
– Example (2): compute the radix – 1 complement of
the hexadecimal number 5CD.
Complements of Numbers
• Radix Complement (r’s Complement):
– First compute the radix -1 complement, and then
add a one to the result.
– In binary system it is called two’s (2’s) complement
(since the radix = 2).
Complements of Numbers
• Radix Complement (r’s Complement):
– Example (1): compute the radix (two’s)
complement of the binary number 0100 1000.

• Equivalent to inverting the binary number (NOT


operation) then adding 1.
Complements of Numbers
• Radix Complement (r’s Complement):
– Example (2): compute the radix complement of the
hexadecimal number 345.
Complements of Numbers
• Subtraction with Complements:
Complements of Numbers
• Subtraction with Complements:
– Example (1.7): X = 1010100 (84)10 and Y = 1000011
(67)10 , compute X-Y and Y-X using 2’s complement.
– Solution:
0111100
+ 1
--------------
0111101
17
Complements of Numbers
• Subtraction with Complements:
– Example (1.7): X = 1010100 (84)10 and Y = 1000011
(67)10 , compute X-Y and Y-X using 2’s complement.
– Solution:
0111100
+ 1
--------------
0111101
17
Complements of Numbers
• Subtraction with Complements:
– Example (1.7): X = 1010100 (84)10 and Y = 1000011
(67)10 , compute X-Y and Y-X using 2’s complement.
– Solution:
0111100
+ 1
--------------
0111101
17
Complements of Numbers
• Subtraction with Complements:
– Example (1.7): X = 1010100 (84)10 and Y = 1000011
(67)10 , compute X-Y and Y-X using 2’s complement.
– Solution:

There is no end
carry. Therefore, 17
the answer Y - X = -
(2’s complement of
sum) = - 0010001 =
(-17)10.
-17
Complements of Numbers
• Subtraction with Complements:
– Example (1.8): Repeat the previous example but
using 1’s complement.
– Solution:

There is no end
carry. Therefore, 17
the answer Y - X = -
(1’s complement of
sum) = - 0010001 =
(-17)10.
-17
Topics of Today
• Digital Systems.
• Binary Numbers.
• Number-Base Conversions.
• Octal and Hexadecimal Numbers.
• Complements of Numbers.
• Signed Binary Numbers.
• Binary Codes.
• Binary Logic.
Signed Binary Numbers
• Computers represent the sign with a bit placed
in the leftmost position of the number.
• The sign bit 0 for positive and 1 for negative.
• Two Conventions:
1. Signed-magnitude.
2. Signed-complement.
Signed Binary Numbers
• Signed-magnitude:
– The number consists of a magnitude bits and a bit (0
or 1) indicating the sign.
• In signed representation, bits to the right of sign bit is the
number.
• In unsigned representation, the leftmost bit (LSB) is a part
of the number (i.e. the most significant bit (MSB)).
– Example: the number +/- 9 in 8 bits:
• 00001001 = +9.
• 10001001 = -9.
Signed Binary Numbers
• Signed-complement:
– A negative number is indicated by its complement.
– Can use either the 1’s or the 2’s complement, but
the 2’s complement is the most common.
– Example: the number +/- 9 in 8 bits:
• 00001001 = +9.
• 11110110 = -9, using 1’s complement.
• 11110111 = -9, using 2’s complement.
Signed Binary Numbers
• Arithmetic Addition:
– Binary addition:
• One bit:

• Multi-bit: (consider carry):


Signed Binary Numbers
• Arithmetic Addition:
– The addition of two signed binary numbers with
negative numbers represented in signed‐
2’s‐complement form is obtained from the addition
of the two numbers, including their sign bits.
• A carry out of the sign‐bit position is discarded.
• negative results are automatically in 2’s‐complement
form.
Signed Binary Numbers
• Arithmetic Addition:
– Examples:
Signed Binary Numbers
• Arithmetic Addition:
2’s complement of +6
– Examples:

100000111
Discard last bit
Signed Binary Numbers
• Arithmetic Addition:
– Examples:

2’s complement of +13

There is no end carry. Therefore,


the answer = - (2’s complement of
11111001) = - 00000111 = (-7)10.
Signed Binary Numbers
• Arithmetic Addition:
– Examples:
Signed Binary Numbers
• Arithmetic Subtraction:
– Binary subtraction:
• Multi-bit: (consider carry):
Signed Binary Numbers
• Arithmetic Subtraction:
– Take the 2’s complement of the subtrahend
(including the sign bit) and add it to the minuend
(including the sign bit).
• A carry out of the sign‐bit position is discarded.
Signed Binary Numbers
• Arithmetic Subtraction:
– Binary subtraction:
• Multi-bit: (consider carry):

• Add the 2’s complement ( (1001)’+1= 0110+1 = 0111) and


discard carry.
Topics of Today
• Digital Systems.
• Binary Numbers.
• Number-Base Conversions.
• Octal and Hexadecimal Numbers.
• Complements of Numbers.
• Signed Binary Numbers.
• Binary Codes.
• Binary Logic.
Binary Codes
• An n‐bit binary code is a group of n bits.
– Up to 2n distinct combinations of 1’s and 0’s, with
each combination representing one element of the
set that is being coded.
– 4 elements (binary combinations) can be coded by 2
bits & 8 elements can be coded by 3 bits, etc…..
– The bit combination of an n‐bit code is determined
from the count in binary from 0 to 2n - 1.
Binary Codes
• Binary-Coded-Decimal (BCD) Code:
– This code is a group of 4 bits.
• Representing one decimal digit.
– Example:

– Each BCD digit does not exceed 9 (1001)2.


Binary Codes
• Binary-Coded-Decimal (BCD) Code:
– This code is a group of 4 bits.
Binary Codes
• BCD Addition:
– When the BCD sum is equal to or less than 1001
(without a carry), the corresponding BCD digit is
correct.
– When the BCD sum is greater than 1001, the result
is an invalid BCD digit.
• Correction:
– Add 6 = (0110)2 to the binary sum to convert it to
the correct digit.
• 0110 (6)10 is the result of 1111 (16)10 – 1010 (10)10.
Binary Codes
• BCD Addition:
– Examples:
Binary Codes
• BCD Addition:
– Examples:
Binary Codes
• BCD Addition:
– Examples:
Binary Codes
• BCD Addition:
– Example: compute 184 + 576.
• Solution: 184 + 576 = 760 in BCD.
Binary Codes
• BCD Addition:
– Example: compute 184 + 576.
• Solution: 184 + 576 = 760 in BCD.
Binary Codes
• BCD Addition:
– Example: compute 184 + 576.
• Solution: 184 + 576 = 760 in BCD.
Binary Codes
• BCD Addition:
– Example: compute 184 + 576.
• Solution: 184 + 576 = 760 in BCD.
Binary Codes
• BCD Addition:
– Example: compute 184 + 576.
• Solution: 184 + 576 = 760 in BCD.
Binary Codes
• Gray Code:
– The advantage of the Gray code over the straight
binary number sequence is that only one bit in the
code group changes in going from one number to
the next.
– Used in systems that probably have normal
sequence of numbers.
Binary Codes
• Gray Code:
Binary Codes
• Gray Code:
– Binary to gray code:
1. Write most significant bit (MSB) same as the MSB in
binary number.
2. The successive bits of the Gray code can be found by
performing the XOR operation between the previous
and current bits of the binary number.
– XOR Operation:
• 1If both bits are 0 or 1, the output will be 0.
• If any one of the bits is 1, the output will be 1.
Binary Codes
• Gray Code:
– Binary to gray code:
– Example: convert the number 910 = 10012 to gray
code.
• Solution:

Binary 1 0 0 1

Gray code 1 1 0 1
Binary Codes
• Gray Code:
– Binary to gray code:
– Example: convert the number 910 = 10012 to gray
code.
XOR
• Solution:

Binary 1 0 0 1

Gray code 1 1 0 1
Binary Codes
• Gray Code:
– Binary to gray code:
– Example: convert the number 910 = 10012 to gray
code.
XOR
• Solution:

Binary 1 0 0 1

Gray code 1 1 0 1
Binary Codes
• Gray Code:
– Binary to gray code:
– Example: convert the number 910 = 10012 to gray
code.
XOR
• Solution:

Binary 1 0 0 1

Gray code 1 1 0 1
Binary Codes
• Gray Code:
– Binary to gray code:
– Example: convert the number 910 = 10012 to gray
code.
XOR
• Solution:

Binary 1 0 0 1

Gray code 1 1 0 1
Binary Codes
• Gray Code:
– Binary to gray code:
– Example: convert the number 910 = 10012 to gray
code.
XOR
• Solution:

Binary 1 0 0 1

Gray code 1 1 0 1
Binary Codes
• Gray Code:
– Binary to gray code:
– Example: convert the number 910 = 10012 to gray
code.
XOR
• Solution:

Binary 1 0 0 1

Gray code 1 1 0 1
Binary Codes
• ASCII Code:
– Besides numbers, we have to represent other types
of information:
• Letters of alphabet, mathematical symbols.
– For English, alphanumeric character set includes:
• 10 decimal digits.
• 26 letters of alphabet (both lowercase and uppercase).
• Several special characters.
– We need an alphanumeric code:
• ASCII (American Standard Code for Information
Exchange), uses 7 bits to encode 128 characters.
– (b6 b5 b4 b3 b2 b1 b0)2.
Binary Codes
• ASCII Code:
– Examples:
• A  65 = (1000001),…, Z  90 = (1011010).
• a  97 = (1100001), …, z  122 = (1111010).
• 0 48 = (0110000), …,9  57 = (0111001).
– 128 different characters:
• 26 + 26 + 10 = 62 (letters and decimal digits).
• 32 special printable characters %, *, $.....
• 34 special control characters (non-printable): BS, CR, etc.
Binary Codes
• ASCII Code:
Binary Codes
• Error-Detecting Code:
– Most computers manipulate 8-bit quantity as a
single unit (byte) ASCII code.
• One ASCII character is stored using a byte.
• One un-used bit can be used for other purposes such as
representing Greek alphabet, italic type font, etc.
– The 8th bit can be used for error-detection.
• It is called the parity bit.
Binary Codes
• Error-Detecting Code:
– A parity bit is an extra bit included with a message
(the binary number) to make the total number of 1’s
either even or odd.
– Parity of the 7 bits of the ASCII code:
– A  (0 1000001) even parity.
– A  (1 1000001) odd parity.
– Detects one, three, and any odd number of bit errors.
Binary Codes
• Error-Detecting Code:
– A parity bit is an extra bit included with a message
(the binary number) to make the total number of 1’s
either even or odd.
– Parity of the 7 bits of the ASCII code:
– A  (0 1000001) even parity.
– A  (1 1000001) odd parity.
– Detects one, three, and any odd number of bit errors.
– Even parity is more common.
Topics of Today
• Digital Systems.
• Binary Numbers.
• Number-Base Conversions.
• Octal and Hexadecimal Numbers.
• Complements of Numbers.
• Signed Binary Numbers.
• Binary Codes.
• Binary Logic.
Binary Logic
• Definition of Binary Logic:
– Binary logic is equivalent to what is called “two-
valued Boolean algebra”.
• It is an implementation of Boolean algebra.
– Deals with variables that take “two discrete values”
and operations that assume “logical meaning”.
• Two discrete values:
– {true, false}.
– {yes, no}.
– {1, 0}.
• Binary logic should not be confused with binary
arithmetic.
Binary Logic
• Definition of Binary Logic:
– We use A, B, C, x, y, z, etc. to denote binary
variables.
• Each can take {0, 1}.
– Logical operations:
1. AND  x · y = z or xy = z.
2. OR  x + y = z.
3. NOT  x = z or x’ = z.
– For each combination of the values of x and y, there is a value
specified by the definition of the logical operation.
– This definition may be listed in a compact form called truth
table.
Binary Logic
• Definition of Binary Logic:
Binary Logic
• Logic Gates:
– Binary values are represented as electrical signals
• Voltage, current.
Binary Logic
• Logic Gates:
– Binary values are represented as electrical signals
• Voltage, current.
– Logic gates are electronic circuits that operate on
one or more input signals to produce output signals
• AND gate, OR gate, NOT gate.
– Symbols:

OR AND NOT
Binary Logic
• Logic Gates:
– Binary values are represented as electrical signals
• Voltage, current.
– Logic gates are electronic circuits that operate on
one or more input signals to produce output signals
• AND gate, OR gate, NOT gate.
– Symbols:
Questions?

Das könnte Ihnen auch gefallen