Академический Документы
Профессиональный Документы
Культура Документы
DIGITAL
U
COPYRIGHT ©
By
EDITION … 2008
Engr. Waqas Naeem PRICE … Rs. 175/-
BS Computer Engg. (SSUET)
ME C&SP (UIT)
-1- -2-
Digital Fundamentals Digital Fundamentals
PREFACE
U
TABLE OF CONTENTS
U U
FIRST EDITION
S# TOPIC PAGE#
The book has been designed for B-Tech & Engineering 1 Number Systems 7 –17
students of the Universities & Institutes of Pakistan. It 1.1 Types 7
covers the specific material required to have a basic 1.2 Conversion between numeral systems 7
knowledge of Logic Designing & Theory. The author has 1.2.1 Decimal 7
made an attempt to present the material in a simple, clear 1.2.2 Hexa-Decimal 11
and straightforward manner. Exercises are given at the 1.2.3 Octal 13
end of each section. Students are urged to grapple with
1.2.4 Practice 16
these exercises for acquiring solid understanding and
insight of the subject. 2 Binary Arithmetic 18—30
2.1 Addition 18
I wish to express my infinite gratitude to my family 2.2 Subtraction 20
members who encourages me to achieve this valuable 2.3 Multiplication 20
target. I am responsible for the mistakes and misprints 2.4 Division 21
that might have been left unnoticed. Thanks are also due 2.5 Boolean Algebra 23
to Mr. Riaz Ahmed (HOD Tech. IIHE) who took pains 2.6 Practice 30
for the publication of this book. 3 Logic Gates 31—37
3.1 AND Gate 32
Suggestions for further improvements will be gratefully 3.2 OR Gate 32
acknowledged. 3.3 NOT Gate 33
3.4 NAND Gate 34
KARACHI AUTHOR 3.5 NOR Gate 34
3.6 XOR Gate 35
JUNE, 2008 3.7 XNOR Gate 36
3.8 Summary Truth Table 37
-3- -4-
Digital Fundamentals Digital Fundamentals
-5- -6-
Digital Fundamentals Digital Fundamentals
1. NUMBER SYSTEMS
U U
Operation Remainder
1.1 Types
T
118 ÷ 2 = 59 0
1. Binary Æ 0&1 29 ÷ 2 = 14 1
2. Octal Æ 0,1,2,3,4,5,6 & 7
3. Decimal Æ 0,1,2,3,4,5,6,7,8 & 9
4. Hexadecimal Æ 0,1,2,3,4,5,6,7,8,9,A,B,C, 14 ÷ 2 = 7 0
D, E & F
-7- -8-
Digital Fundamentals Digital Fundamentals
0 110010101101
405 × 2 + 1 = 811 01
0×2+1=1 10010101101
811 × 2 + 0 = 1622 1
1×2+1=3 0010101101
1622 × 2 + 1 = 3245
3×2+0=6 010101101
The result is 324510.
B B
6 × 2 + 0 = 12 10101101
-9- - 10 -
Digital Fundamentals Digital Fundamentals
so it takes four digits of binary to represent one digit of To convert a hexadecimal number into its binary
hexadecimal. equivalent, simply substitute the corresponding binary
digits:
The following table shows each hexadecimal digit along
with the equivalent decimal value and four-digit binary 3A16 = 0011 10102
B B B B
3 3 0011 5216
B B
5 5 0101
6 6 0110 To convert a hexadecimal number into its decimal
7 7 0111 equivalent, multiply the decimal equivalent of each
8 8 1000 hexadecimal digit by the corresponding power of 16 and
9 9 1001 add the resulting values:
A 10 1010
B 11 1011
C 12 1100
- 11 - - 12 -
Digital Fundamentals Digital Fundamentals
4 100
1.2.3 Octal
5 101
Binary is also easily converted to the octal numeral
system, since octal uses a radix of 8, which is a power of
two (namely, 23, so it takes exactly three binary digits to
P P
6 110
represent an octal digit). The correspondence between
octal and binary numerals is the same as for the first
eight digits of hexadecimal in the table above. Binary 7 111
000 is equivalent to the octal digit 0, binary 111 is
equivalent to octal 7, and so on.
Converting from octal to binary proceeds in the same
fashion as it does for hexadecimal:
Octal Binary
658 = 110 1012
B B B B
2 010
100112 = 010 0112 (grouped with padding) = 238
B B B B B B
- 13 - - 14 -
Digital Fundamentals Digital Fundamentals
1 0
658 = (6 × 8 ) + (5 × 8 ) = (6 × 8) + (5 × 1) = 5310
B B P P P P B B
- 15 - - 16 -
Digital Fundamentals Digital Fundamentals
• (2374)8 = ( )16
• (17260)8 = ( )16
Arithmetic in binary is much like arithmetic in other
• (A912F)16 = ( )8
numeral systems. Addition, subtraction, multiplication,
• (19EDF)16 = ( )8 and division can be performed on binary numerals.
6. Conversion between Base-10 and Base-16:
• (317)10 = ( )16
2.1 Addition
• (2319)10 = ( )16
• (AFC1)16 = ( )10
• (10DCB)16 = ( )10
0+0=0
0+1=1
1+0=1
1 + 1 = 10 (carry: 1)
- 17 - - 18 -
Digital Fundamentals Digital Fundamentals
Adding two "1" values produces the value "10" (spoken and a 1 is written in the bottom row. Proceeding like this
as "one-zero"), equivalent to the decimal value 2. This is gives the final answer 1001002 (36 decimal).
B B
5 + 5 = 10 0−0=0
7 + 9 = 16 0 − 1 = 1 (with borrow)
1−0=1
This is known as carrying in most numeral systems. 1−1=0
When the result of an addition exceeds the value of the
radix, the procedure is to "carry the one" to the left, One binary numeral can be subtracted from another as
adding it to the next positional value. Carrying works the follows:
same way in binary:
* * * * (starred columns are borrowed from)
1 1 1 1 1 (carry) 1101110
01101 − 10111
+ 10111 ----------------
------------- =1010111
=100100
2.3 Multiplication
In this example, two numerals are being added together:
011012 (13 decimal) and 101112 (23 decimal). The top
B B B B
- 19 - - 20 -
Digital Fundamentals Digital Fundamentals
Since there are only two digits in binary, there are only 1012 goes into the first three digits 1102 of the dividend
B B B B
two possible outcomes of each partial multiplication: one time, so a "1" is written on the top line. This result is
multiplied by the divisor, and subtracted from the first
• If the digit in B is 0, the partial product is also 0 three digits of the dividend; the next digit (a "1") is
• If the digit in B is 1, the partial product is equal to included to obtain a new three-digit sequence:
A
1
For example, the binary numbers 1011 and 1010 are __________
101 |11011
multiplied as follows: − 101 U U
011
1 0 1 1 (A)
× 1 0 1 0 (B)
---------
The procedure is then repeated with the new sequence,
0 0 0 0 ← Corresponds to a zero in B continuing until the digits in the dividend have been
+ 1 0 1 1 ← Corresponds to a one in B exhausted:
+ 0000
+1011 101
--------------- __________
=1101110 101 |11011
− 101 U U
111
Binary division is again similar to its decimal − 101 U U
counterpart: 10
101 |11011 shown on the top line, while the remainder, shown on the
bottom line, is 102. In decimal, 27 divided by 5 is 5, with
Here, the divisor is 1012, or 5 decimal, while the
B B
B B
a remainder of 2.
dividend is 110112, or 27 decimal. The procedure is the
B B
- 21 - - 22 -
Digital Fundamentals Digital Fundamentals
- 23 - - 24 -
Digital Fundamentals Digital Fundamentals
Expression
U U Rule(s) Used
U U
Expression
U U Rule(s) Used
U U
- 25 - - 26 -
Digital Fundamentals Digital Fundamentals
, Identity;
(¬A)(A + B) + (B + AA)(A + ¬B) Original setting up for
Expression the next step.
(¬A)A + (¬A)B + (B + A)A + (B Idempotent (¬A)B + A(B + T + ¬B) Distributive.
+ A)(¬B) (AA to A), (¬A)B + A Identity,
then twice
Distributive,
- 27 - - 28 -
Digital Fundamentals Digital Fundamentals
(depending Practice
how you
U U
count it).
1. Addition
A + (¬A)B Commutative • 1011101 + 1110101 =
. • 1111010101 + 1010000101 =
(A + ¬A)(A + B) Distributive. • 00010101 + 1001010100 =
• 1011001111 + 10001010100 =
A+B Compliment,
2. Subtraction
Identity.
• 11100111 – 1101 =
• 10011101010 – 100011 =
• 11010101 – 100110 =
• 1011001100 – 1110001 =
3. Multiplication
• 10100001 x 11011 =
• 11101010 x 1010 =
• 11010001 x 100110 =
• 111001110 x 11010 =
4. Division
• 1110001100 divide by 110 =
• 10011110010 divide by 100 =
• 110101000111 divide by 101 =
• 100011110100 divide by 1001 =
5. Solve the Boolean expression by using
different laws:
• {A(¬A+C)&(B+¬B)}
• [{C(A&¬A) & 0} + {C(A+¬C) & B(¬C)}
- 29 - - 30 -
Digital Fundamentals Digital Fundamentals
3. LOGIC GATES
U U
- 31 - - 32 -
Digital Fundamentals Digital Fundamentals
- 33 - - 34 -
Digital Fundamentals Digital Fundamentals
- 35 - - 36 -
Digital Fundamentals Digital Fundamentals
4. COMBINATIONS OF
U
1 1 1 0 1 0 0 1
0 0 1 0 1 1 0
- 37 - - 38 -
Digital Fundamentals Digital Fundamentals
For example the truth table on Inputs Outputs reduce the number of gate inputs or substitute one type of
the right show the intermediate gate for another.
outputs D and E as well as the A B C D E Q
final output Q for the system 0 0 0 1 0 1 Reducing the number of
shown below. 0 0 1 1 0 1 inputs
0 1 0 0 0 0 The number of inputs to a gate can be
reduced by connecting two (or more) inputs together.
0 1 1 0 1 1
The diagram shows a 3-input AND gate operating as a 2-
1 0 0 0 0 0 input AND gate.
1 0 1 0 0 0
1 1 0 0 0 0
Making a NOT gate from a
1 1 1 0 1 1 NAND or NOR gate
Reducing a NAND or NOR gate to
just one input creates a NOT gate. The diagram shows
this for a 2-input NAND gate.
D = NOT (A OR B)
E = B AND C
Q = D OR E = (NOT (A OR B)) OR (B AND C)
4.3 Any gate can be built from NAND or NOR
gates
As well as making a NOT gate, NAND or NOR gates
4.2 Substituting one type of gate for another can be combined to create any type of gate! This enables
a circuit to be built from just one type of gate, either
Logic gates are available on ICs which usually contain NAND or NOR. For example an AND gate is a NAND
several gates of the same type, for example four 2-input gate then a NOT gate (to undo the inverting function).
NAND gates or three 3-input NAND gates. This can be Note that AND and OR gates cannot be used to create
wasteful if only a few gates are required unless they are other gates because they lack the inverting (NOT)
all the same type. To avoid using too many ICs you can function.
- 39 - - 40 -
Digital Fundamentals Digital Fundamentals
AND
- 41 - - 42 -
Digital Fundamentals Digital Fundamentals
Practice
U U
- 43 - - 44 -
Digital Fundamentals Digital Fundamentals
5. CIRCUIT, EQUATION,
U
- 45 - - 46 -
Digital Fundamentals Digital Fundamentals
NOR Æ (A + B)’ Æ G
AND Æ (C & D) Æ H
NAND Æ (E & F)’ Æ I
NAND Æ (G & C’)’ Æ J
NOR Æ (C’ + H)’ Æ K
OR Æ (E’ + I) Æ M
NAND Æ (J & K & M & E’)’
Æ {[(A+B)’&C’] & [C’+(C&D)] & [E’+ (E & F)’] &
E’}---- (ii)
- 47 - - 48 -
Digital Fundamentals Digital Fundamentals
Again the same simple circuit (It might be a traditional (0 or 1). For example we have the following condition to
one …Cheers). Number of possible combination for the construct a circuit for a specified output:
given circuit can be calculated by the formula:
A=B=1; C=0
n
Number of possible combinations = 2
P P O/p = 1
Where “n” is the total number of inputs in the circuit Now we have to precisely examine the input and the
which is “3” in this case (A, B & C). Now the total logical gates we have to satisfy the condition of input. It
possible combinations for the input are 8 (23) and they
P P is known that the functionality of AND gate is that it
are stated below with their respective output: provides logical output HIGH when all the inputs are
HIGH. Leading with this statement we can satisfy the
S# A B C Q conditions for input A and B by using AND gate. Now
1 0 0 0 1 proceeding to the third and last input condition which is
2 0 0 1 1 LOW, we already knows that out of the previous AND
3 0 1 0 0 gate will be HIGH in only condition when A and B will
4 0 1 1 1 be HIGH. Then we should have any gate which checks
5 1 0 0 0 the output of AND and input C. look into the below
6 1 0 1 0 circuit:
7 1 1 0 0
8 1 1 1 1
5.4 CONDITIONS
By verifying the above circuit, we come to know that it
also satisfies our remaining condition. Now the final
As stated earlier that the major concern to design any circuit we achieve is:
logical circuit is to achieve the specific pattern of output.
Here we will discuss how to create a circuit when the
conditions of inputs are given to get any particular output
- 49 - - 50 -
Digital Fundamentals Digital Fundamentals
Practice
U U
- 51 - - 52 -
Digital Fundamentals Digital Fundamentals
6. ADDERS
U U
6.2 FULL ADDER
- 53 - - 54 -
Digital Fundamentals Digital Fundamentals
7. KARNAUGH MAPS
U
7.2 Representation
The Karnaugh map comprises a box for every line in the
truth table; the binary values above the boxes are those
associated with the a and b inputs. Unlike a truth table, in
which the input values typically follow a standard binary
sequence (00, 01, 10, 11), the Karnaugh map's input
values must be ordered such that the values for adjacent
Karnaugh maps for 3-input and 4-input functions.
columns vary by only a single bit, for example, 00, 01,
11, and 10. This ordering is known as a gray code, and it
is a key factor in the way in which Karnaugh maps work.
- 55 - - 56 -
Digital Fundamentals Digital Fundamentals
7.3 Minimization Using Karnaugh Maps the map differ by only one bit, any pair of horizontally or
vertically adjacent boxes corresponds to minterms that
Karnaugh maps often prove useful in the simplification differ by only a single variable. Such pairs of minterms
and minimization of Boolean functions. Consider an can be grouped together and the variable that differs can
example 3-input function represented as a black box with be discarded (Figure 4).
an associated truth table (Figure 3). (Note that the values
assigned to the y output in the truth table were selected
randomly, and have no significance beyond the purposes
of this example.)
- 57 - - 58 -
Digital Fundamentals Digital Fundamentals
The four cells above are a group of four because they all
have the Boolean variables B' and D' in common. In
other words, B=0 for the four cells, and D=0 for the four
- 59 - - 60 -
Digital Fundamentals Digital Fundamentals
cells. The other variables (A, B) are 0 in some cases, 1 in The Boolean expression below has nine p-terms, three of
other cases with respect to the four corner cells. Thus, which have three Booleans instead of four. The
these variables (A, B) are not involved with this group of difference is that while four Boolean variable product
four. This single group comes out of the map as one terms cover one cell, the three Boolean p-terms cover a
product term for the simplified result: Out=B'C' pair of cells each.
For the K-map below, roll the top and bottom edges into
a cylinder (Horizontal Fold) forming eight adjacent cells.
- 61 - - 62 -
Digital Fundamentals Digital Fundamentals
group of eight and a group of four without sharing any Often times there are more than one minimum cost
cells. Final Solution is Out=B'+D' solution to a simplification problem. Such is the case
illustrated below.
Below we map the unsimplified Boolean expression to
the Karnaugh map.
- 63 - - 64 -
Digital Fundamentals Digital Fundamentals
step. It may not be obvious how to pick up the remaining certain input combinations will never occur, then the
cells. value assigned to the output for these combinations is
irrelevant.
Alternatively, for some input combinations the designer
may simply not care about the value on the output. In
both cases, the designer can represent the output values
associated with the relevant input combinations as
question marks in the map.
- 65 - - 66 -
Digital Fundamentals Digital Fundamentals
7.7 Populating Maps Using 0s Versus 1s Karnaugh maps are most often used to represent 3-input
and 4-input functions. It is possible to create similar
When a Karnaugh map is populated using the 1s maps for 5-input and 6-input functions, but these maps
assigned to the truth table's output, the resulting Boolean can become unwieldy and difficult to use. The Karnaugh
expression is extracted from the map in sum-of-products technique is generally not considered to have any
form. As an alternative, the Karnaugh map can be application for functions with more than six inputs.
populated using the 0s assigned to the truth table's
output. In this case, groupings of 0's are used to generate
expressions in product-of-sums format.
- 67 - - 68 -
Digital Fundamentals Digital Fundamentals
Practice 8. LATCHES
U
- 69 - - 70 -
Digital Fundamentals Digital Fundamentals
also be applied to the second input of the other NOR confusing when you first try to deal with NOR-
gate, allowing that output to rise to logic 1 level. This based circuits.
in turn feeds back to the second input of the original
gate, forcing its output to remain at logic 0 even after S R Q n+1B B
0 1 Reset
Applying another logic 1 input to the same gate will
have no further effect on this circuit. However, 1 0 Set
applying logic 1 to the other gate will cause the same 1 1 Undefined
reaction in the other direction, thus changing the state
of the latch circuit the other way. 8.2 RS NAND Latch
T T
Note that it is forbidden to have both inputs at logic In order for a logical circuit to "remember" and
1 level at the same time. That state will force both retain its logical state even after the controlling
outputs to logic 0, overriding the feedback latching input signal(s) have been removed, it is necessary
action. In this condition, whichever input goes to for the circuit to include some form of feedback. We
logic 0 first will lose control, while the other input might start with a pair of inverters, each having its
(still at logic 1) controls the resulting state of the input connected to the other's output. The two
latch. If both inputs go to logic 0 simultaneously, outputs will always have opposite logic levels.
the result is a "race" condition, and the final state of
the latch cannot be determined ahead of time. The problem with this is that we don't have any
additional inputs that we can use to change the logic
One problem with the basic RS NOR latch is that states if we want. We can solve this problem by
the input signals actively drive their respective replacing the inverters with NAND or NOR gates,
outputs to a logic 0, rather than to a logic 1. Thus, and using the extra input lines to control the circuit.
the S input signal is applied to the gate that
produces the Q' output, while the R input signal is The circuit shown below is a basic NAND latch.
applied to the gate that produces the Q output. The The inputs are generally designated "S" and "R" for
circuit works fine, but this reversal of inputs can be "Set" and "Reset" respectively. Because the NAND
- 71 - - 72 -
Digital Fundamentals Digital Fundamentals
inputs must normally be logic 1 to avoid affecting reaction in the other direction, thus changing the state
the latching action, the inputs are considered to be of the latch circuit the other way.
inverted in this circuit.
Note that it is forbidden to have both inputs at a
The outputs of any single-bit latch or memory are logic 0 level at the same time. That state will force
traditionally designated Q and Q'. In a commercial both outputs to logic 1, overriding the feedback
latch circuit, either or both of these may be available latching action. In this condition, whichever input
for use by other circuits. In any case, the circuit goes to logic 1 first will lose control, while the other
itself is: input (still at logic 0) controls the resulting state of
the latch. If both inputs go to logic 1
simultaneously, the result is a "race" condition, and
the final state of the latch cannot be determined
ahead of time.
S R Q n+1
B B
0 0 Undefined
For the NAND latch circuit, both inputs should 0 1 Set
normally be at logic 1 level. Changing an input to a 1 0 Reset
logic 0 level will force that output to logic 1. The same 1 1 Qn
logic 1 will also be applied to the second input of the
B B
- 73 - - 74 -
Digital Fundamentals Digital Fundamentals
J K Q Q’
0 0 No change
0 1 0 1
1 0 1 0
1 1 Toggle
8.4 D Latch
T T
- 75 - - 76 -
Digital Fundamentals Digital Fundamentals
D input, no matter how that changes. When the CLK Converting a D flip-flop to T operation is quite similar;
input falls to logic 0, the last state of the D input is the Q' output is connected back to the D input.
trapped and held in the latch, for use by whatever
other circuits may need this signal.
8.5 T Flip-Flop
- 77 - - 78 -
Digital Fundamentals Digital Fundamentals
9. MUX & DEMUX This circuit can be scaled upward to 3 by 8 MUX (three
NOT gates, eight 4-input AND gates, one 8-input OR
U U
- 79 - - 80 -
Digital Fundamentals
C1 C0 Output
0 0 D0
0 1 D1
1 0 D2
1 1 D3
- 81 -