class work

22
Digital Logic & Design (Class work) Name of the Teacher: Sir Fayaz Ahmed Memon Name of the student: Muhammed Asif Raza. Class Roll number: 06CS36 By: -Muhammed Asif Raza(06CS36). 1

Upload: safia-amir-dahri

Post on 25-Dec-2015

238 views

Category:

Documents


3 download

DESCRIPTION

digital logic design

TRANSCRIPT

Page 1: Class Work

Digital Logic & Design (Class work)

Name of the Teacher: Sir Fayaz Ahmed Memon

Name of the student: Muhammed Asif Raza.

Class Roll number: 06CS36

Subject: Digital Logic & Design

By: -Muhammed Asif Raza(06CS36).

1

Page 2: Class Work

Digital Logic & Design (Class work)

Contents: -Part One (Combinational Logic Design)Chapter#1 …………Number systems and base conversion………………………..Page3Chapter#2. ………...Boolean algebra and Logic Gates………………………………PageChapter#3 …………Minimization Techniques…….………………………………..PageChapter#4 …………Combinational Logic Design…………………………………..PagePart (Sequential Logic Design)Chapter#5 …………Flip-Flops…..…………………………………………………..PageChapter#5 …………Counters………………………………………………………..PageChapter#7 …………Registers………………………………………………………..PageChapter#8 ……………………………………………………………………………..PageChapter#9 ……………………………………………………………………………..PageChapter#10 ……………………………………………………………………………page

By: -Muhammed Asif Raza(06CS36).

2

Page 3: Class Work

Digital Logic & Design (Class work)

Chapter #1

Number Systems and base conversion

The number systems basically depend on the base. each number system has a particular weight. With the help of the weights we can easily convert a number from one system to another. Mostly four number systems we often use.

i. Binaryii. Octal

iii. Decimaliv. Hexadecimal

Binary number system: -In this number system, only two digits (0 and 1) are used to represent the numbers. The binary numbers has the base 2. The weight of binary number system is …24,23,22, 21,20

Decimal number system: -Decimal number system is familiar system and is used commonly. This system has a base 10. In this system, 10 digits(from 0 to 9)are used to represent the numbers. The weight of decimal is 104,103,102,101,100

Octal number system: -Octal number system has a base 8.8 digits from 0 to 7 are used to represent the numbers. The octal number system has a weight 83,82,81,80.Hexadecimal number system: -Hexadecimal number system has a base 16.In this number system ten digits (from 0 to 9)and 6 alphabets A,B,C,D,E and F are used to represent the numbers Where A=10,B=11,C=12,D=13,E=14,and F=15.The weights are 164,163,162,161,160.

Comparison among the representation of number in different systemsDecimal Binary Octal Hexadecimal0 0000 0 01 0001 1 12 0010 2 23 0011 3 34 0100 4 45 0101 5 56 0110 6 67 0111 7 78 1000 10 89 1001 11 910 1010 12 A11 1011 13 B12 1100 14 C13 1101 15 D14 1110 16 E15 1111 17 F

By: -Muhammed Asif Raza(06CS36).

3

Page 4: Class Work

Digital Logic & Design (Class work)

Base Conversion: -

Decimal to Binary: -A decimal number can be converted into binary number by repeated division by 2 and write results from bottom to top.for example: -(79)10=(??)2

(79)10=(1001111)2

A fractional decimal number can be converted to binary number by repeated multiplication by 2. Write results from top to bottom.(61.125)10= (??)2

0.125 x 2=0.2500.250 x 2=0.5000.500 x 2=1.000(61.125)10= (11101.001)2

Similarly any decimal number can be converted to any base number by repeated division by base, write results from bottom to top and similarly the fractional part of a decimal number can be converted to any base by repeated multiplication by base and write results from top to bottom. One example each from remaining two number systems (octal & hexadecimal) is given below.

Example: - Convert (426.123)10 to octal and hexadecimal.

By: -Muhammed Asif Raza(06CS36).

4

Page 5: Class Work

Digital Logic & Design (Class work)

0.123 x 8 =0.9840.984 x 8 =7.8720.872 x 8 =6.9760.976 x 8 =7.808 (426.123)10= (652.0767)8

(ii)(426.123)10= (??)16

0.123 x 16=1.9680.968 x 16=15.4880.488 x 16=7.8080.808 x 16=12.928

(426.123)10= (1AA.1F7C)16

Binary to Decimal: -A binary number can be converted to decimal by multiplying each corresponding bit of binary number by base, increasing the power of base 0 to n-1 where n is the total number of binary bits from right to left and sum up to get decimal equivalent. Example: convert the binary number 111011 to the decimal equivalent.

1x25+1x24+1x23+0x22+1x21+1x20

32+16+8+0+2+1=59while converting the fractional part of a number just give the negative powers to

the base from left to right just as done in the next example.Example: Convert 11011.001 to decimal equivalent.

1x24+1x23+0x22+1x21+1x20+.0x2-1+0x2-2+1x2-3

16+8+2+1+.1/8=27.0125Similarly, number from any base can be converted to decimal equivalent by the

same procedure mentioned above i.e. by multiplying each corresponding digit of number by base, increasing the power of base 0 to n-1 where n is the total number of digits from right to left and sum up to get decimal equivalent. and of course for fractional part give the negative powers to the base from left to right. It will be further clear by this example.Example: convert (56)8 and (DF7)16 to decimal equivalent.

(i) 5x81+6x80

5x8+640+6=46

(ii) Dx162+Fx161+7x160

By: -Muhammed Asif Raza(06CS36).

5

Page 6: Class Work

Digital Logic & Design (Class work)

13x256+15x16+73328+240+7=3575

Binary to Octal: - To convert a binary number to octal number, separate the binary number into groups of three starting from the right and then translate each group into its octal equivalent. Zeros may be added to the left of the binary number to complete a group of three For example, to translate the number 11010 to octal, the formula would be as follows

Binary 011 010Formula 011=3 010=2Octal =32

Binary to Hexadecimal: -To convert a binary number to a hexadecimal number, separate the binary number into groups of four starting from the right and then translate each group into its hexadecimal equivalent. Zeros may be added to the left of the binary number to complete a group of four. For example, to translate the number 11010 to hexadecimal, the formula would be as follows

Binary =11010 0001 1010Formula 0001=1 1010=AHexadecimal=1A

Octal to Hexadecimal: - Octal to hexadecimal conversion is not normally or directly possible. Following procedure is applied when converting octal to hexadecimal. First convert the octal number into equivalent binary number and then convert the binary number into hexadecimal by making the groups of four bits from right to left. Same procedure is applied to convert a hexadecimal number to octal instead that you have to make the groups of three bits.Binary operations: -

Binary numbers can be manipulated with the same familiar operations used to calculate decimal numbers, but using only zeros and ones. To add two numbers there are only four rules to remember.

0+0=0

0+1=1

1+0=1

1+1=10

And for subtraction,

0-0=0

1-0=1

0-1=1 (by taking borrow from next higher digit)1-1=0For multiplication,0×0=00×1=0

By: -Muhammed Asif Raza(06CS36).

6

Page 7: Class Work

Digital Logic & Design (Class work)

0×1=01×1=1

Example: Addition. 101101

+1001111010100

Subtract, using borrow. 101101

- 100111 000110

–Example Multiplication1011× 11__

10111011__

100001Complements

The complement of a number is the number which when added to the original will make it equal to a multiple of the base number system.

The complement of a number can be used as a representation of that number as a negative - moreover, as a positive number representing a negative! It is really a bit of a trick, which we can use to make subtraction easier for machines.

In a computer the representation and manipulation of negative numbers is usually performed using complements Complements for a radix come in two forms

1. r’s complement2. (r-1)’s complement

r’s complement Given a positive number N that has n digit integer part, the r’s complement of N is defined asr n - N for N ≠ 0 ,zero otherwise. 10’s Complement10’s complement of (37218)10 = 10 5 - 37218 = 62782 10’s complement of (0.12345)10 = 10 0 - 0.12345 = 0.876552’s Complement1.  Reverse the value of the bits in the binary number; i.e. change all the 0 bits to 1 and change 1s to 0.  2.  Add 1 to the result. 

2’s complement of (101110)2 = 2 6 - (101110) = 010010 2’s complement of (0.0110)2 = 2 0 - (0.0110) = 0.1010(r-1)’s ComplementGiven a positive number N with integer part n bits, fractional part m bits, the (r-1)’s complement is defined as,

By: -Muhammed Asif Raza(06CS36).

7

Page 8: Class Work

Digital Logic & Design (Class work)

(r n - n -m -N)A simple procedure to obtain the 9’s, 7’s and 15’s complement is that subtract

each digit of the number from 9,7, and 15 respectively.9’s complement (r = 10)9’s complement of (37218)10 = 10 5 - 1 - 37218 = 62781=99999-372189’s complement of (0.12345)10 = (10 0 - 10 -5 - 0.12345)= 0.99999 - 0.12345 = 0.876549’s complement 0f (25.639)10 = (10 2 - 10 -3 - 25.639) = 99.999 - 25.639 = 74.3601’s complement (r = 2)

To obtain 1’s complement of a binary number, simply change the 1’s to 0’s and 0’s to 1’s. 1’s complement of (101100)2 = 2 6 - 1 - (101100)= 111111 - 101100 = 010011 1’s complement of (0.0110)2 = 2 0 - 2 -4 - (0.0110)= 0.1111 -0.0110 = 0.1001Subtracting using Complements: -Using (r-1)’s complement: -

Following procedure is applied to perform subtraction using (r-1)’s complement.Step 1. Find the (r-1)’s complement of the subtrahend.Step 2. Add (r-1)’s complement of the subtrahend to the minuend.Step 3. Check the end around carry

(a) If there is carry, result will be positive, add that carry to the result.(b) If there is no carry, result will be negative. Find the (r-1)’s complement of the

result and put minus sign.Example Using (r)’s complement: -Step 1. Find r’s complement of the subtrahend.Step 2. Add r’s complement of the subtrahend to the minuend.Step 3. Check end around carry.

(a) If there is carry result will be positive. Discard the carry.(c) If there is no carry result is negative, find r’s complement of the result and put

negative sign.

Binary Codes: -Decimal numbers are coded using binary bit patterns. Binary codes for decimal digits require a minimum number of four bits. Numerous different codes can be obtained by arranging four or more bits in ten distinct possible combinations. A few codes are shown in Table-2

Numbers are represented in digital computers either in binary or decimal form through a binary code. The decimal numbers are stored internally in the computer by means of decimal code. Each decimal digit requires at least four storage elements. The decimal numbers are converted into binary when arithmetic operations are done internally in computer with numbers represented in binary. It is also possible to perform the arithmetic operations directly in decimal with all numbers left in a coded form throughout. For example, the decimal number 395, when converted into binary, it is equivalent to 110001011 and consists of nine binary digits. The same number, when represented internally in the BCD code, occupies the four bits for each decimal digit, for a total of 12 bits;0011 1001 0101. The first four bits represented a 3 the next four a 9, and a last four a 5.

It is worthwhile to note the difference between the coding and conversion of a binary number. In either case the result is the series of bits. The bits obtained from

By: -Muhammed Asif Raza(06CS36).

8

Page 9: Class Work

Digital Logic & Design (Class work)

conversion are binary digits. Bits obtained from coding are combination of 1’s and 0’s arranged according to the rules of the code used. Therefore it is extremely important to realize that a series of 1’s and 0’s in a digital system may some times represent a binary number and at other times represent some other discrete quantity of information as specified by a given binary code. The BCD code for example, has been chosen to be both a code and a direct binary conversion as long as the decimal

Table-2Table of various binary codes for decimal digits

Decimal 8421 (BCD) 84-2-1 2421 Excess-3 Gray

0 0000 0000 0000 0011 00001 0001 0111 0001 0100 00012 0010 0110 0010 0101 00113 0011 0101 0011 0110 00104 0100 0100 0100 0111 01105 0101 1011 0101 1000 01116 0110 1010 0110 1001 01017 0111 1001 0111 1010 01008 1000 1000 1110 1011 11009 1001 1111 1111 1100 1101

Binary coded decimal (BCD): The BCD is a straight assignment of binary equivalent. Each decimal digit is represented by a 4-digit binary number; e.g. (7 4 3)10 = (0111 0100 0011)BCD.

2421 and 84-2-1: - 2421 and 84-2-1 are weighted codes. The latter is convenient for 9’s complement operations

Excess-3: - Excess-3 is BCD plus 3. It is convenient 9’s complement operations. Excess-3 code was used in older computers. This is an unweighted code, it code assignment is obtained from the corresponding value of the BCD after addition of 3.Gray code: - In Gray code consecutive digits differ only by one bit. Useful for mechanical position decoding.Example: represent the decimal number (567)10 in the following codes(i)BCD (ii)2421 (iii)5421 (iv)Excess-3Answer: -Decimal BCD 2421 5421 Excess-3567 0101 0110 0111 0101 1110 1101 1000 1001 1010 1000 1001 1010

Binary -to-Gray Conversion: -Following steps are applied to convert a binary number into Gray number.

Step 1: - The MSB of Gray number remains the same as the MSB of the binary number.Step 2: - Start from left to right and add each adjacent pair of binary bits to obtain new gray- code bit. Discard the carries.Example: - Convert (101100101)2 into Gray(101100101)binary=(111010111)Gray Answer.

By: -Muhammed Asif Raza(06CS36).

9

Page 10: Class Work

Digital Logic & Design (Class work)

By: -Muhammed Asif Raza(06CS36).

10

Page 11: Class Work

Digital Logic & Design (Class work)

Chapter # 2Boolean Algebra and Logic Gates

In 1854 George Boole introduced a systematic treatment of logic and developed Boolean algebra. Boolean algebra is the set of rules, laws and theorems by which logic circuits are represented mathematically. It is convenient tool for expressing and analyzing the logical behavior of digital systems. Boolean algebra operations: -Basically there are three basic operations in Boolean algebra that are applied on the variables, AND, OR and NOT (or sometimes called as complement operation).AND operation: -AND operation represents the logical multiplication. Its symbol is “.”(Dot) which is placed between the variables that are to be multiplied. In logic circuits, AND operation is performed with the AND gate. For example

0.0 = 01.0 = 00.1 = 01.1 = 1

OR operation: -OR operation represents the logical addition. Its symbol is “+”(Plus sign). This operation is performed by the OR gate.

0+0 = 00+1 = 11+0 = 11+1 = 1

NOT operation (Complement operation): -NOT operation performs the complement operation. In other words, it complements or inverts the input, for instance,

A = 1Ā = 0

Boolean Function: - A Boolean function is a function that is represented by two binary operators, AND and OR and one unary operator NOT, Binary variables, (), and equal sign. For example F (A, B)= A´B+AB´ Truth Table: -A truth table is a table that describes the logic behavior of the Boolean function of logic circuit. It shows all the inputs combinations with corresponding outputs. To represent any function in terms of truth table, we need 2n input combinations from 0 to 2n-1, where n is the number of input variable. For example the truth table for And operation is given below. Here we use two input variables named as A and B because AND operation requires at least two variables, and the output of function as F. With two variables we have 4 input combinations.Truth Table for AND operation

A B F 0 0 0 0 1 0 1 0 0

1 1 1

By: -Muhammed Asif Raza(06CS36).

11

Page 12: Class Work

Digital Logic & Design (Class work)

Rules of Boolean algebra: - Boolean algebra has some rules, which are useful for minimizing the Boolean

expression and Boolean function. 1. A+A = A 2. A.A = A3. A+1 = 14. A+0 = A5. A+A´ = 16. A.0 = 07. A.A´ = 08. A´´ =A9. A+AB = A10. A+A´B = A+B11. (A+B)´ = A´. B´12. (A.B)´ = A´+B´13. A+B = B+A14. A.1 = A15. A. (B.C) = A.B+A.C Laws of Boolean algebra: -Boolean algebra has the three basic laws:1. Commutative Law: -

i. A+B = B+Aii. A.B = B.A

Truth table for (i) Truth table for (ii)

2. Associative Law: -The law states that “the order in which variables are grouped when performing

OR or AND operation makes no difference i. (A+B)+C = A+(B+C)

ii. (A.B).C = A.(B.C)Truth table for proof

A B C A+B (A+B)+C B+C A+C0 0 0 0 0 0 00 0 1 0 1 1 10 1 0 1 1 1 10 1 1 1 1 1 11 0 0 1 1 1 11 0 1 1 1 1 11 1 0 1 1 1 11 1 1 1 1 1 13. Distributive Law: -

By: -Muhammed Asif Raza(06CS36).

A B A.B B.A0 0 0 00 1 0 01 0 0 0 1 1 1 1

A B A+B B+A0 0 0 00 1 1 11 0 1 11 1 1 1

12

Page 13: Class Work

Digital Logic & Design (Class work)

This law states that “ORing several variables and multiplying with single variable is equivalent to multiplying single variable with all variables and performing OR operation.

i. A.(B+C) = A.B + A.Cii. A+ (BC) = (A+B) . (A+C)

Truth Table for proofA B C BC L.H.S

A+BCA+B A+C R.H.S

(A+B).(A+C)0 0 0 0 0 0 0 00 0 1 0 0 0 1 00 1 0 0 0 1 0 00 1 1 1 1 1 1 11 0 0 0 1 1 1 11 0 1 0 1 1 1 11 1 0 0 1 1 1 11 1 1 1 1 1 1 1

L.H.S = R.H.SDe Morgan’s Theorem: -

This law states that complement of Sums equal to products of complements.(i) (A+B)´ = A´. B´Generally,(x1+x2+x3+x4+…+xn)´ = x1´.x2´.x3´.x4´….xn´And,

Complement of product is equal to sum of the complements. (ii) (AB)´ = A´+B´Generally,(x1.x2.x3.x4….xn)´ = x1´+x2´+x3´+x4’+…xn´Truth Table for proofA B C A+B+C L.H.S

(A+B+C)´A´ B´ C´ R.H.S

A´.B´.C´0 0 0 0 1 1 1 1 10 0 1 1 0 1 1 0 00 1 0 1 0 1 0 1 00 1 1 1 0 1 0 0 01 0 0 1 0 0 1 1 01 0 1 1 0 0 1 0 01 1 0 1 0 0 0 1 01 1 1 1 0 0 0 0 0

L.H.S = R.H.S

Boolean Expression: -It is short hand way to describe the logic circuit in terms of Boolean expression.

The result of the Boolean expression is true, high, or 1 or it may be 0, low or false. There is no third possibility between 1 and 0.The Boolean expression describes the logic actions performed by a circuit. Boolean expressions are basically two forms.

1. Canonical form

By: -Muhammed Asif Raza(06CS36).

13

Page 14: Class Work

Digital Logic & Design (Class work)

2. Standard Form 1. Canonical form: -

This form of a Boolean expression is obtained directly from the truth table of the function. In this form of Boolean expression all variables must be present in the expression. It is not a simplified form. Canonical form has two types.i. Sum of min terms

ii. Product of max termsMin term: - A min term is a product term in which each variable must exist either in complemented (normal) or un complemented form. The variable will be in complemented form, if the bit corresponding to it in the truth table is zero, and variable will be in un complemented form if the corresponding bit is one.

A min term id represented by mj where j is the decimal representation of the binary number in the input combination.Max term: - A max term is a sum term in which each variable must exist either in complemented (normal) or un complemented form. The variable will be in complemented form, if the bit corresponding to it in the truth table is one, and variable will be in un complemented form if the corresponding bit is zero.

A max term is represented by Mj where j is the decimal representation of the binary number in the input combination. It is worthwhile to note that Sum of min term is when complemented produces the Product of max term expression and vice versa. A function has min terms as well as max terms equal to number of input combinations.A B C Min terms mj Max terms Mj0 0 0 A´B´C´ m0 A+B+C M0

0 0 1 A´B´C m1 A+B+C´ M1

0 1 0 A´BC´ m2 A+B´+C M2

0 1 1 A´BC m3 A+B´+C´ M3

1 0 0 AB´C´ m4 A´+B+C M4

1 0 1 AB´C m5 A´+B+C´ M5

1 1 0 ABC´ m6 A´+B´+C M6

1 1 1 ABC m7 A´+B´+C´ M7

(i) Sum of Min term Boolean expression: -The Sum of min term Boolean expression is derived from truth table by writing

all min terms whose output is equal to one and then sum the min terms.(ii) Product of max term Boolean expression: - Product of max term Boolean expression is derived from truth table by writing all Max terms whose out put is zero and then take the product.Example: -Write Sum of min terms and product of max terms Boolean expression of a circuit of three inputs and one output. The circuit produces a high out put when ever their inputs have more one’s than zeros. Other wise the output of the function is zero.Truth TableA B C Output (F) Min terms Max terms0 0 0 0 A´B´C´ A+B+C0 0 1 0 A´B´C A+B+C´0 1 0 0 A´BC´ A+B´+C0 1 1 1 A´BC A+B´+C´

By: -Muhammed Asif Raza(06CS36).

14

Page 15: Class Work

Digital Logic & Design (Class work)

1 0 0 0 AB´C´ A´+B+C1 0 1 1 AB´C A´+B+C´1 1 0 1 ABC´ A´+B´+C1 1 1 1 ABC A´+B´+C´Sum of min terms Boolean expression for F = A´BC+ AB´C+ ABC´+ ABCProduct of max terms Boolean expression for F=(A+B+C)(A+B+C´)(A+B´+C)(A´+B+C)

Standard Form: - The standard form of a Boolean expression is a minimized form of a Sum of min terms Boolean expression or Product of max terms Boolean expression. This form of a Boolean expression is used to draw logical diagram of circuits because this is a minimized form and requires less number of logic gates as compared to canonical form. Like canonical form, it has also two types.

i. Sum of productsii. Product of Sums

It is worthwhile to note that Sum of min terms Boolean expression can be called as Sum of product and Product of max terms Boolean expression can be called Product of Sums because min term is a product term and max term is a sum term. But Sum of product or product of Sums cannot be denoted as Sum of min terms Boolean expression or Product of max terms Boolean expression because they don’t contain min terms or max terms but they contains simple products or sums with lesser variables than canonical form expressions.Logic Gates: -Logic gates are the physical components through which the logical operations are performed. There are eight logic gates, which perform different logical operations, and the each has their own characteristics and as well as inputs and outputs. Normally logic gates have only one output.

1. NOT Gate (Inverter): -The NOT gate has only one input and one output. NOT gate performs the complement operation. Whenever the input is high output will be the low and whenever the input is low the output will be the high.

A Y0 11 0

Y=A´

Logical symbol 2.AND –Gate: -The AND-Gate performs the logical multiplication. This gate has two or more than two inputs and only one output. The output will be high if inputs are high and the output will be low if any of the input is low.

Truth TableA B Y0 0 0

By: -Muhammed Asif Raza(06CS36).

15

Page 16: Class Work

Digital Logic & Design (Class work)

0 1 01 0 01 1 1

Y=A.B

Logical symbol

3. OR gate: -OR gate has two or more than two inputs and one output. Or gate performs the logical addition. The output will be high when ever any of the input is high and output will be low if all inputs are low.

Truth TableA B Y0 0 00 1 11 0 11 1 1

Y=A+B

Logical symbol

By: -Muhammed Asif Raza(06CS36).

16