Week 2 Nptel Digital Electronics
Week 2 Nptel Digital Electronics
Example: – 4 – 3 = – 7
EL
4 in binary = 0100.
Flipping the bits, you get –4 (1011) in binary.
3 in binary = 0011.
Flipping the bits, you get –3 (1100) in binary.
1011 (11 in decimal, or 15-4)
+ 1100 (12 in decimal, or 15-3)
PT
-----------------------------------------
1,0111 (23 in decimal (15+15-7))
So now take the extra 1 and remove it from the 5th spot and add it to the remainder
0111
+ 1
------------------------------------------
1000 (-7 in 1’s comp)
Recovery of the Numbers
EL
1's Complement 2's Complement
Let f(x) = 2n -1 -x Let g(x) = 2n - x
Theorem: f(f(x)) = x Theorem: g(g(x)) = x
Proof: f (f(x)) Proof: g(g(x))
PT
= f (2n - 1 - x)
= 2n - 1 - (2n -1 - x)
=x
= g(2n - x)
= 2n - (2n - x)
=x
EL
Floating point numbers
PT
Real Numbers
EL
• Two’s complement representation deal with
signed integer values only.
• Without modification, these formats are not
useful in scientific or business applications
PT
that deal with real number values.
• Floating-point representation solves this
problem.
Floating-Point Representation
EL
• If we are clever programmers, we can perform floating-point
calculations using any integer format.
• This is called floating-point emulation, because floating point
values aren’t stored as such; we just create programs that
make it seem as if floating-point values are being used.
PT
• Most of today’s computers are equipped with specialized
hardware that performs floating-point arithmetic with no
special programming required.
– Not embedded processors!
Floating-Point Representation
EL
• Floating-point numbers allow an arbitrary number of
decimal places to the right of the decimal point.
– For example: 0.5 0.25 = 0.125
• They are often expressed in scientific notation.
PT
– For example:
0.125 = 1.25 10-1
5,000,000 = 5.0 106
Floating-Point Representation
• Computers use a form of scientific notation for floating-
EL
point representation
• Numbers written in scientific notation have three
components:
PT
Floating-Point Representation
EL
• Computer representation of a floating-point
number consists of three fixed-size fields:
PT
• This is the standard arrangement of these fields.
Note: Although “significand” and “mantissa” do not technically mean the same thing, many
people use these terms interchangeably. We use the term “significand” to refer to the fractional
part of a floating point number.
Floating-Point Representation
EL
• The one-bit sign field is the sign of the stored value.
PT
• The size of the exponent field determines the range of values
that can be represented.
• The size of the significand determines the precision of the
representation.
Floating-Point Representation
EL
• We introduce a hypothetical “Simple Model” to explain
PT
the concepts
• In this model:
– A floating-point number is 14 bits in length
– The exponent field is 5 bits
– The significand field is 8 bits
Floating-Point Representation
EL
• The significand is always preceded by an implied binary
point.
value.
PT
• Thus, the significand always contains a fractional binary
EL
– Express 3210 in the simplified 14-bit floating-point
model.
• We know that 32 is 25. So in (binary) scientific notation 32 = 1.0
x 25 = 0.1 x 26.
– In a moment, we’ll explain why we prefer the second
PT
notation versus the first.
• Using this information, we put 110 (= 610) in the exponent field
and 1 in the significand as shown.
Floating-Point Representation
EL
• The illustrations shown at
the right are all equivalent
representations for 32 using
our simplified model.
• Not only do these
PT
synonymous representations
waste space, but they can
also cause confusion.
Floating-Point Representation
EL
• Another problem with our system is that we have made
no allowances for negative exponents. We have no way
PT
to express 0.5 (=2 -1)! (Notice that there is no sign in the
exponent field.)
EL
establish a rule that the first digit of the significand must
be 1, with no ones to the left of the radix point.
• This process, called normalization, results in a unique
pattern for each floating-point number.
– In our simple model, all significands must have the form
PT
0.1xxxxxxxx
– For example, 4.5 = 100.1 x 20 = 1.001 x 22 = 0.1001 x 23. The last
expression is correctly normalized.
EL
• To provide for negative exponents, we will use a
biased exponent.
• A bias is a number that is approximately midway in
the range of values expressible by the exponent.
We subtract the bias from the value in the exponent
to determine its true value.
PT
– In our case, we have a 5-bit exponent. We will use 16 for
our bias. This is called excess-16 representation.
• In our model, exponent values less than 16 are
negative, representing fractional numbers.
Example 1
EL
• Example:
– Express 3210 in the revised 14-bit floating-point model.
• We know that 32 = 1.0 x 25 = 0.1 x 26.
• To use our excess 16 biased exponent, we add 16 to 6, giving
2210 (=101102).
PT
• So we have:
Example 2
EL
• Example:
– Express 0.062510 in the revised 14-bit floating-
point model.
• We know that 0.0625 is 2-4. So in (binary) scientific
notation 0.0625 = 1.0 x 2-4 = 0.1 x 2 -3.
PT
• To use our excess 16 biased exponent, we add 16 to -3,
giving 1310 (=011012).
Example 3
• Example:
EL
– Express -26.62510 in the revised 14-bit floating-point
model.
• We find 26.62510 = 11010.1012. Normalizing, we have:
26.62510 = 0.11010101 x 2 5.
PT
• To use our excess 16 biased exponent, we add 16 to 5,
giving 2110 (=101012). We also need a 1 in the sign bit.
Floating-Point Standards
EL
• The IEEE has established a standard for floating-
point numbers
• The IEEE-754 single precision floating point
standard uses an 8-bit exponent (with a bias of 127)
PT
and a 23-bit significand.
• The IEEE-754 double precision standard uses an
11-bit exponent (with a bias of 1023) and a 52-bit
significand.
Floating-Point Representation
EL
• In both the IEEE single-precision and double-precision
floating-point standard, the significant has an implied 1 to the
LEFT of the radix point.
– The format for a significand using the IEEE format is:
1.xxx…
PT
– For example, 4.5 = .1001 x 23 in IEEE format is 4.5 = 1.001 x
22. The 1 is implied, which means it does not need to be
listed in the significand (the significand would include only
001).
Floating-Point Representation
EL
• Example: Express -3.75 as a floating point number using
IEEE single precision.
• First, let’s normalize according to IEEE rules:
– -3.75 = -11.112 = -1.111 x 21
– The bias is 127, so we add 127 + 1 = 128 (this is our exponent)
(implied) PT
– The first 1 in the significand is implied, so we have:
EL
• For a 32 bit number
– 8 bit exponent
– +/- 2256 1.5 x 1077
PT
• Accuracy
– The effect of changing lsb of significand
– 23 bit significand 2-23 1.2 x 10-7
– About 6 decimal places
Expressible Numbers
EL
PT
Floating-Point Representation
• Using the IEEE-754 single precision floating point
EL
standard:
– An exponent of 255 indicates a special value.
• If the significand is zero, the value is infinity.
• If the significand is nonzero, the value is NaN, “not a
number,” often used to flag an error condition.
PT
• Using the double precision standard:
– The “special” exponent value for a double precision
number is 2047, instead of the 255 used by the single
precision standard.
Floating-Point Representation
• Both the 14-bit model that we have presented and the
EL
IEEE-754 floating point standard allow two
representations for zero.
– Zero is indicated by all zeros in the exponent and the
significand, but the sign bit can be either 0 or 1.
PT
• This is why programmers should avoid testing a floating-
point value for equality to zero.
– Negative zero does not equal positive zero.
Floating-Point Representation
EL
• Floating-point addition and subtraction are done using
methods analogous to how we perform calculations
using pencil and paper.
• The first thing that we do is express both operands in
the same exponential power, then add the numbers,
PT
preserving the exponent in the sum.
• If the exponent requires adjustment, we do so at the
end of the calculation.
FP Addition & Subtraction Flowchart
EL
PT
Floating-Point addition example
EL
• Example:
– Find the sum of 1210 and 1.2510 using the 14-bit “simple” floating-
point model.
• We find 1210 = 0.1100 x 2 4. And 1.2510 = 0.101 x 2 1 = 0.000101 x 2 4.
PT
Floating-Point Multiplication
EL
• Floating-point multiplication is also carried out in a
manner akin to how we perform multiplication using
pencil and paper.
• We multiply the two operands and add their
exponents.
PT
• If the exponent requires adjustment, we do so at the
end of the calculation.
Floating Point Multiplication flowchart
EL
PT
Rounding and Errors
EL
• No matter how many bits we use in a floating-point
representation, our model must be finite.
• The real number system is, of course, infinite, so our
models can give nothing more than an approximation of a
real value.
PT
• At some point, every model breaks down, introducing
errors into our calculations.
• By using a greater number of bits in our model, we can
reduce these errors, but we can never totally eliminate
them.
Rounding and Errors
EL
• Our job becomes one of reducing error, or at least
being aware of the possible magnitude of error in our
calculations.
• We must also be aware that errors can compound
through repetitive arithmetic operations.
PT
• For example, our 14-bit model cannot exactly represent
the decimal value 128.5. In binary, it is 9 bits wide:
10000000.12 = 128.510
Rounding and Errors
EL
• When we try to express 128.510 in our 14-bit model, we lose
the low-order bit, giving a relative error of:
PT
• If we had a procedure that repetitively added 0.5 to 128.5, we
would have an error of nearly 2% after only four iterations.
Rounding and Errors
EL
• Floating-point errors can be reduced when we use
operands that are similar in magnitude.
• If we were repetitively adding 0.5 to 128.5, it would have
been better to iteratively add 0.5 to itself and then add
128.5 to this sum.
PT
• In this example, the error was caused by loss of the low-
order bit.
• Loss of the high-order bit is more problematic.
Rounding and Errors
EL
• Floating-point overflow and underflow can cause programs to
crash.
• Overflow occurs when there is no room to store the high-order
bits resulting from a calculation.
• Underflow occurs when a value is too small to store, possibly
PT
resulting in division by zero.
EL
• When discussing floating-point numbers, it is important to
understand the terms range, precision, and accuracy.
• The range of a numeric integer format is the difference between
the largest and smallest values that can be expressed.
• Accuracy refers to how closely a numeric representation
PT
approximates a true value.
• The precision of a number indicates how much information we
have about a value
Rounding and Errors
EL
• Most of the time, greater precision leads to better accuracy, but
this is not always true.
– For example, 3.1333 is a value of pi that is accurate to
two digits, but has 5 digits of precision.
PT
• There are other problems with floating point numbers.
• Because of truncated bits, you cannot always assume that a
particular floating point operation is commutative or distributive.
Rounding and Errors
EL
• This means that we cannot assume:
(a + b) + c = a + (b + c) or
a*(b + c) = ab + ac
• Moreover, to test a floating point value for equality to some other number,
it is best to declare a “nearness to x” epsilon value. For example, instead
of checking to see if floating point x is equal to 2 as follows:
PT
if x == 2 then …
it is better to use:
if (abs(x - 2) < epsilon) then ...
(assuming we have epsilon defined correctly!)
Some Exercises
EL
• If (75)x = (45)y, then possible values of x and y are
• Possible values of x and y satisfying (2x)5 = (3y)6 are
• If x6 = (32)9 * (24)5 then x is equal to
•
PT
The number 2678 in base-11 number system is
EL
Boolean Algebra
PT Santanu Chattopadhyay
Electronics & Electrical Communication Engineering
Introduction
EL
• Developed by English Mathematician George
Boole in between 1815 - 1864.
• It is described as an algebra of logic or an
PT
algebra of two values i.e True or False.
• The term logic means a statement having
binary decisions i.e True/Yes or False/No.
Application of Boolean algebra
EL
• It is used to perform the logical operations in digital computer.
• In digital computer True represent by ‘1’ (high voltage) and
False represent by ‘0’ (low voltage)
• Logical operations are performed by logical operators. The
PT
fundamental logical operators are:
1. AND (conjunction)
2. OR (disjunction)
3. NOT (negation/complement)
AND operator
EL
• It performs logical multiplication and denoted by (.)
dot.
X Y X.Y
0
0
1
1
PT0
1
0
1
0
0
0
1
OR operator
EL
• It performs logical addition and denoted by (+) plus.
X Y X+Y
0 0 0
0
1
1 PT1
0
1
1
1
1
NOT operator
EL
• It performs logical negation and denoted by (-)
bar. It operates on single variable.
X
0
1 PTX
1
0
(means complement of x)
Truth Table
EL
• Truth table is a table that contains all possible values
of logical variables/statements in a Boolean
expression.
PT
No. of possible combinations = 2n, where n=number of
variables used in a Boolean expression.
Truth Table
EL
• The truth table for XY + Z is as follows:
Dec X Y Z X.Y X.Y+Z
0 0 0 0 0 0
1 0 0 1 0 1
PT
2 0 1 0 0 0
3 0 1 1 0 1
4 1 0 0 0 0
5 1 0 1 0 1
6 1 1 0 1 1
7 1 1 1 1 1
Tautology & Fallacy
EL
• If the output of Booean expression is always True
or 1 is called Tautology.
• If the output of Boolean expression is always
False or 0 is called Fallacy.
P
0
1
P’
1
0 PT output (P + P’) output (P . P’)
1
1
EL
1. Evaluate the following Boolean expression
using Truth Table.
(a) X’Y’+X’Y (b) X’YZ’+XY’
PT
(c) XY’(Z+YZ’)+Z’
EL
• Boolean Algebra applied in computers
electronic circuits. These circuits perform
Boolean operations and these are called logic
PT
circuits or logic gates.
Logic Gate
EL
• A gate is an digital circuit which operates on one or more signals and
produce single output.
• Gates are digital circuits because the input and output signals are denoted
by either 1(high voltage) or 0(low voltage).
PT
• Three type of gates are as under:
1. AND gate
2. OR gate
3. NOT gate
AND gate
EL
• The AND gate is an electronic circuit that gives a high
output (1) only if all its inputs are high.
• AND gate takes two or more input signals and produce only
one output signal. Input Input Output
PT
A B AB
0 0 0
0 1 0
1 0 0
1 1 1
OR gate
EL
• The OR gate is an electronic circuit that gives a high
output (1) if one or more of its inputs are high.
• OR gate also takes two or more input signals and
PT
produce only one output signal. Input
0
0
1
1
A
Input
0
1
0
1
B
Output
A+B
0
1
1
1
NOT gate
EL
• The NOT gate is an electronic circuit that gives a high output (1) if its
input is low .
• NOT gate takes only one input signal and produce only one output
signal.
• The output of NOT gate is complement of its input.
PT
• It is also called inverter. Input A
0
1
Output A
1
0
Principal of Duality
EL
•In Boolean algebras the duality Principle is obtained by
interchanging AND and OR operators and replacing 0's by 1's
and 1's by 0's. Compare the identities on the left side with the
identities on the right.
Example
PT
A+1 = 1 then A.0 = 0
Basic Theorem of Boolean Algebra
EL
T1 : Properties of 0
(a) 0 + A = A
(b) 0 A = 0
PT
T2 : Properties of 1
(a) 1 + A = 1
(b) 1 A = A
Basic Theorem of Boolean Algebra
EL
T3 : Commutative Law
(a) A + B = B + A
(b) A B = B A
T4 : Associate Law
PT
(a) (A + B) + C = A + (B + C)
(b) (A B) C = A (B C)
T5 : Distributive Law
(a) A (B + C) = A B + A C
(b) A + (B C) = (A + B) (A + C)
(c) A+A’B = A+B
Basic Theorem of Boolean Algebra
EL
T6 : Indempotence (Identity ) Law
(a) A + A = A
(b) A A = A
PT
T7 : Absorption (Redundance) Law
(a) A + A B = A
(b) A (A + B) = A
Basic Theorem of Boolean Algebra
EL
T8 : Complementary Law
(a) X+X’=1
(b) X.X’=0
PT
T9 : Involution
(a) x’’ = x
T10 : De Morgan's Theorem
(a) (X+Y)’=X’.Y’
(b) (X.Y)’=X’+Y’
Exercise
EL
Q 1. State & Verify De Morgan's Law by using truth
table and algebraically.
Q 2. State and verify distributive law.
PT
Q 3. Draw a logic diagram for the following
expression:
(a) ab+b’c+c’a’
(b) (a+b).(a+b’).c
Representation of Boolean expression
EL
Boolean expression can be represented by either
(i) Sum of Product( SOP) form or
(ii) Product of Sum (POS form)
e.g.
AB+AC SOP
PT
(A+B)(A+C) POS
In above examples both are in SOP and POS respectively but they are not in Standard SOP and POS.
Canonical form of Boolean Expression
EL
(Standard form)
In standard SOP and POS each term of Boolean
expression must contain all the literals (with and
without bar) that has been used in Boolean
PT
expression.
If the above condition is satisfied by the Boolean
expression, that expression is called Canonical
form of Boolean expression.
Canonical form of Boolean Expression (Standard form)
EL
Contd..
PT
in 2nd term AC. That is why AB+AC is not a
Canonical SOP.
Canonical form of Boolean Expression (Standard form)
EL
Contd..
Convert AB+AC in Canonical SOP (Standard
SOP)
PT
Sol. AB + AC
AB(C+C’) + AC(B+B’)
ABC+ABC’+ABC+AB’C
ABC+ABC’+AB’C
Distributive law
Canonical form of Boolean Expression (Standard form)
EL
Contd..
Convert (A+B)(A+C) in Canonical SOP (Standard
SOP)
PT
Sol. (A+B).(A+C)
((A+B)+(C.C’)) .((A+C)+(B.B’))
Distributive law
(A+B+C).(A+B+C’).(A+B+C)(A+B’+C)
Remove duplicates
(A+B+C).(A+B+C’)(A+B’+C)
Conversion between SOP and POS
EL
PT
Canonical form of Boolean Expression (Standard form)
EL
Contd..
PT
literals (with or without bar) within the Boolean expression.
EL
x y Index Minterm Maxterm
0 0 0 m0 = x’ y’ M0 = x + y
0 1 1 m1 = x’ y M1 = x + y’
1 0 2 m2 = x y’ M2 = x’ + y
1 1
PT 3 m3 = x y M3 = x’ + y’
The minterm mi should evaluate to 1 for each combination
of x and y.
The maxterm is the complement of the minterm
Solved Problem
EL
Prob. Find the minterm designation of XY’Z’
Sol. Subsitute 1’s for non barred and 0’s for
barred letters
PT
Binary equivalent = 100
Decimal equivalent = 4
Thus XY’Z’=m4
Purpose of the Index
Minterms and Maxterms are designated with an index
EL
The index number corresponds to a binary pattern
The index for the minterm or maxterm, expressed as a binary number, is used
to determine whether the variable is shown in the true or complemented
form
For Minterms:
PT
‘1’ means the variable is “Not Complemented” and
‘0’ means the variable is “Complemented”.
For Maxterms:
‘0’ means the variable is “Not Complemented” and
‘1’ means the variable is “Complemented”.
Solved Problem
Write SOP form of a Boolean Function F, Which is represented by the following
EL
truth table.
Sum of minterms of entries that evaluate to ‘1’
x y z F Minterm
0 0 0 0
0 0 1 1 m1 = x’ y’ z
0 1 0 0
PT Focus on the
0 1 1 0
1 0 0 0
1 0 1 0 ‘1’ entries
1 1 0 1 m6 = x y z’
1 1 1 1 m7 = x y z
F = m1 + m6 + m7 = ∑ (1, 6, 7) = x y z + x y z + x y z
Exercise
EL
1. Write POS form of a Boolean Function F, Which is represented by the
following truth table x y z F
0 0 0 1
0 0 1 1
0 1 0 0
0 1 1 0
PT
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 1
2. Write equivalent canonical Sum of Product expression for the following
Product of Sum Expression: F(X,Y,Z)=Π(1,3,6,7)
Minimization of Boolean Expression
EL
Canonical SOP (Sum of Minterms) and POS (Product of Maxterm) is the
derivation/expansion of Boolean Expression.
PT
Minimization of Boolean expression is needed to simplify the Boolean
expression and thus reduce the circuitry complexity as it uses less number
of gates to produce same output that can by taken by long canonical
expression.