0% found this document useful (0 votes)
12 views38 pages

EE221 Lecture 1 - 3

Digital Logic Design covers digital systems and binary numbers. Chapter 1 discusses binary number representations including signed and unsigned binary, and subtraction methods like 1's complement and 2's complement. It also summarizes binary codes for representing decimal numbers, including binary coded decimal and arithmetic on BCD codes.

Uploaded by

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

EE221 Lecture 1 - 3

Digital Logic Design covers digital systems and binary numbers. Chapter 1 discusses binary number representations including signed and unsigned binary, and subtraction methods like 1's complement and 2's complement. It also summarizes binary codes for representing decimal numbers, including binary coded decimal and arithmetic on BCD codes.

Uploaded by

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

Digital Logic Design

Chapter 1:
Digital Systems and Binary Numbers

1
Subtraction with Complements

• The subtraction of two n-digit unsigned numbers M – N in base


r can be done as follows:
– Add the minuend, M, to the r’s complement of the subtrahend, N:
» M + (rn – N) = M – N + rn
– If M  N, the sum will produce an end carry, r n, which can be discarded; what is
left is the result of M – N.
– If M  N, the sum does not produce an end carry and is equal to r n – (N – M),
which is the r’s complement of (N – M). To obtain the answer in a familiar form,
take the r’s complement of the sum and place a negative sign in front.
10’s Complement Subtraction

• The subtraction of two n-digit unsigned numbers M – N in base r can be done as follows:
– Add the minuend, M, to the r’s complement of the subtrahend, N:
» M + (rn – N) = M – N + rn
– If M  N, the sum will produce an end carry, r n, which can be discarded; what is left is the result
of M – N.
– If M  N, the sum does not produce an end carry and is equal to r n – (N – M), which is the r’s
complement of (N – M). To obtain the answer in a familiar form, take the r’s complement of the
sum and place a negative sign in front.

» 10’s complement by leaving all LSB 0s unchanged, subtract first non-zero digit from 10
and rest all digits from 9

• Note that the extra 9 in the 10’s complement of N is to fill the space holder 0.
10’s Complement Subtraction

• Using 10’s complement, subtract 2140 – 62513


• If M  N, the sum does not produce an end carry and is equal to r n –
(N – M), which is the r’s complement of (N – M). To obtain the answer
in a familiar form, take the r’s complement of the sum and place a
negative sign in front.
2’s Complement Subtraction
• Using 2’s complement, subtract 1001001 – 1000110

• Using 2’s complement, subtract 1000110 - 1001001


Using 1’s Complement
• You can also use the 1’s complement for performing subtraction.
• You can add the minuend M to the (r-1)’s complement of subtrahend N.
Then inspect the result
– If an end carry occurs add 1
– If there is no end carry take (r-1)’s complement of the result obtained
and place a negative sign
– Note: Remember that 1’s complement is 1 less than 2’s complement.
We must compensate by adding 1 when an end carry occurs.
Removing an end-carry and adding one is called an end-around carry.
Using 1’s complement, subtract 1001001 - 1000110
1’s Complement Subtraction

• Using 1’s complement, subtract 1000110 - 1001001


Signed Binary Numbers

• In ordinary arithmetic a negative number is indicated by minus


sign and positive number by plus sign. This is not possible in
computers, because of hardware limitation computers must
represent everything with binary digits. There are two methods
to do this:
– The signed magnitude convention uses the left-most bit to represent the sign (0
for positive and 1 for negative).
– The signed complement system negates a number by taking its complement.
» It could be either, 1’s complement representation
» or 2’s complement representation.

sign bit

1 1 1 1 0 1 1 0
Negative

0 0 0 0 1 0 1 0 Positive
Signed Complement System

• The Signed Complement System negative number is indicated by its complement


(Complement of positive number)
– Positive numbers always start with 0 (plus), its complement (representing negative
number) will always start with 1
– Signed complement system can use either 1’s complement or 2’s complement.
– For example:
» +9 is represented only as 00001001 but –9 can be represented as:
• 11110110 Signed 1’s complement representation
• 11110111 Signed 2’s complement representation

• Note that to determine 2’s complement, leave the least significant 0’s and
the first 1 unchanged and then switch the remaining 1’s to 0’ and 0’s to 1’s.
Number Representations
• The following is the representation for +11:
– 00001011
• The following are different methods for representing -11:
– Signed magnitude: 10001011
– Signed-1’s-complement: 11110100
– Signed-2’s-complement: 11110101

Note that to determine 2’s


complement, leave the
least significant 0’s and
the first 1 unchanged and
then switch the remaining
1’s to 0’ and 0’s to 1’s.
Signed Binary Numbers
• The signed magnitude convention uses the left-most bit to represent the sign (0
for positive and 1 for negative).
• The signed complement system negates a number by taking its complement.
• It could be either, 1’s complement representation
• or 2’s complement representation.

Note that to determine 2’s


complement, leave the
least significant 0’s and
the first 1 unchanged and
then switch the remaining
1’s to 0’ and 0’s to 1’s.
Arithmetic Addition (Signed Magnitude System)

• The addition of two signed binary numbers in the signed-


magnitude system follows the rules of ordinary arithmetic
• If the signs are the same, we add the two magnitudes and give
the sum the common sign
• If the signs are different, we subtract the smaller magnitude
from the larger and give the result the sign of the larger
magnitude
Arithmetic Addition (Signed 2’s Complement system)

• This system doesn’t require the comparison of the signs and the
magnitudes (as in signed-magnitude system), but only addition.
• The addition of two signed binary numbers with negative numbers
represented in signed-2’s complement form is obtained from
addition of the two numbers, including their sign bits.
• A carry out of the sign-bit position is discarded.
• If the sum is negative, it will be in 2’s complement form.
Arithmetic Subtraction

• Subtraction can be performed by simply converting the equation


into an addition formula.
– 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
– Note: Subtraction operation can be changed to an addition
operation if the sign of the subtrahend is changed. This is
easily done by taking it’s 2’s complement
Binary Codes

• All symbols in a computer must be represented by a binary code


(binary representation).
• An n-bit binary code is a group of n bits that can represent up to
2n distinct combinations of 1’s and 0’s.
– Each distinct combination represents a single symbol in the
computer.
BCD Code (8 4 2 1)

• The most common representation for binary


digits is the binary coded decimal (BCD) form
which is a binary assignment of the decimal
numbers.
– This code is the simplest, most intuitive
binary code for decimal digits and uses the
same weights as a binary number, but only
encodes the first ten values from 0 to 9 (6
out of 16 possible combinations remains
unassigned ).
– A number with k distinct decimal digits will
require 4k bits in BCD.
– Each digit of a decimal value is converted to
its respective binary representation.
– BCD number needs more bits than its
equivalent binary value?
BCD Addition

• BCD only represents each of the decimal digitals 0 through 9 as a single 4-bit
binary value.
• When adding two BCD values, if the sum is equal to or less than 1001 (9), the
corresponding BCD value is correct.
• However, when the binary sum is greater or equal to 1010 (10), the result is an
invalid BCD value.
– To overcome the invalid BCD value, add 0110 (6) to the result to obtain the
BCD representation and produces a carry as required.
» The use of 0110 (6) works because the difference between a carry in the
most significant bit position of the binary sum and a decimal carry differ
by 16-10 = 6.
BCD Arithmetic
• BCD arithmetic involving negative numbers uses the 10’s
complement for representing the negative numbers including
the sign digit.
– 0 (0000) represents a positive sign and 9 (1001) represents a negative sign
• As an example, imagine we want to add
(+257) + (-160) = +97

• Note: To obtain 10’s complement of a BCD number, we first take the 9’s
complement (by subtraction of each digit from 9) and then add one to
least significant digit
Other Decimal Codes

• There are various other decimal codes that can be used:


– BCD (8 4 2 1)
– 2421
– Excess-3 code. (adds binary 0011 to the BCD code)
– 8 4 -2 -1
– Gray Code
– ASCII Character Code
– Error-Detecting Code
• Each bit has a "weight" associated with it and you can compute
the decimal value by adding the weights where a 1 exists in the
code-word.
Four Different Binary Codes
Gray Code vs Binary Code
•Convenient to use the Gray code to represent the
digital data when it is converted from analog data
•The advantage of Gray code over straight binary
number sequence is that only one bit in the code
group changes when going from one number to
the next
•Compare the number of bits changing when
going from one number to the next:
–In Gray code it is always 1 bit.
ASCII Character Code- ASCII Table
• The American Standard Code for Information Interchange (ASCII) uses
seven bits to code 128 characters, representing the alphabet, decimal
numbers, and various other symbols.
– The following ASCII chart allows you to specify the characters in decimal representation by
concatenating the column headings to the row headings.
» For example, the character 5 is represented in binary as 0110101
ASCII Character Code- ASCII Table
Error-Detecting Code
• Error-Detecting uses an eighth bit (added to 7-bit ASCII character)
to indicate parity.
– A parity bit is an extra bit that is set to 0 or 1 as needed to make the total number of 1’s
either even or odd.
– In an odd-parity code, the parity bit is specified so that the total number of ones is odd.
– In an even-parity code, the parity bit is specified so that the total number of ones is
even.
– It detects one, three or any odd combination of errors but even combination of errors is
undetected.

P Information Bits
1 1 0 0 0 0 1 1 0 1 0 0 0 0 1 1
 
Added even parity bit Added odd parity bit
Parity Code Example

• Concatenate a parity bit to the ASCII code for the characters 0,


X, and = to produce both odd-parity and even-parity codes.

Character ASCII Odd-Parity Even-Parity


ASCII ASCII

0 0110000 10110000 00110000

X 1011000 01011000 11011000

= 0111100 10111100 00111100


Binary Storage

• Binary storage represents the storage mechanisms for binary


data stored in a computer.
– A binary cell is a device that possesses two stable states, and it can store a single
state value (0 or 1). It stores single bit of data. examples: flip-flop circuits, ferrite
cores, capacitor
– A register is a group of binary cells. n cells allows the register to store n bits and
thus 2n possible states.
» The type of information (BCD, ASCII, etc.) stored in a register has to be
agreed upon by the users of the register.

0 0 1 0 1 0 1 1

Binary Cell
• The memory cell is an electronic circuit that stores one bit of binary information and it must be set to store a logic 1
(high voltage level) and reset to store a logic 0 (low voltage level). Its value is maintained/stored until it is changed
by the set/reset process. The value in the memory cell can be accessed by reading it.
Register Transfer
• A Register transfer operation involves the
transfer of binary information from one set
of binary registers into other set of binary
registers.
• The capture and storage of information
requires:
– An input register to store the key inputs
from the keyboard
– A processor register to store the data
when processed by the CPU
– A memory register in the memory unit
to store the values

• Data input at keyboard


• Shifted into place
• Stored in memory

– NOTE: Data input in ASCII


Binary Information Processing
• The actual processing of binary information in a
computer is completed by digital logic circuits
which have been implemented to serve a
specific purpose (i.e., addition).
– The registers are accessed (read and write)
when they are needed to complete an
operation. For example, we need two
register sets to store two values to be added
and a register set to store the result of the
sum.
» Furthermore, we need three registers in
both the memory unit and in the
processor.

• We need processing
• We need storage
• We need communication
Binary Logic
• Binary logic consists of binary variables and logical operations.
– The variables are designated by letters of the alphabet (A, B, C, x, y, z, etc.).
– There are three basic logical operations:
» AND
» OR
» NOT

• AND is represented by a dot or the absence of an operator.


– x·y = z or xy = z
– Means that z=1 if and only if x=1 and y=1
• OR is represented by a plus sign.
– x+y = z
– Means that z=1 if x=1 or y=1 or both x=1 and y=1
• NOT is represented by a prime or an overbar.
– x’=z or x = z
– Means that if x=1 then z=0 or if x=0 then z=1
Truth Tables

• Each binary variable consists of value of 0 or 1, each combination of


values for the variables involved in a binary operation has a specific result
value.
• A truth table is a method of visualizing all possible combinations of the
input values and the respective output values that occur due to the
operation on the specified combination.

NOT
A A'
0 1
1 0
Truth Tables
AND
A B A.B
0 0 0
0 1 0
1 0 0
1 1 1

OR
A B A+B
0 0 0
0 1 1
1 0 1
1 1 1
Binary Signal

• Two separated voltage levels


represents a binary variable
equal to logic 1 or logic 0
• Logic 0 is equal to 0 volt and
logic 1 equal to 4 volt (with
acceptable range as shown in
figure)
Logic Gates

• Logic gates are electronic circuits that operate on one or more input
signals to produce an output signal.
– The state (high-low, on-off) of electricity on a line represents each of the two states for
binary representation (1 or 0).

• Logic Gate Notation


AND Logic Function

• Using door • Using Switches


– Both doors are opened to pass • Switches are input and LED is
the light output
• Both switches closed (ON) to
give output
OR Logic Function

• Using door • Using Switches


– Any one or both doors are • Switches are input and LED is
opened to pass the light output
• Any one switch or both closed to
give output
Timing Diagram
Multi-Input Circuits
End of Chapter 1
End of Chapter 1

You might also like