Você está na página 1de 46

Digital Logic And Computer Organization UNIT I 1.

0) Introduction
Inside a computer system, data is stored in a format that cannot be easily read by human beings. This is the reason why input and output (I/O) interfaces are required. Every computer stores numbers, letters and other special characters in a coded form. Before going into the details of these codes, it is essential to have a basic understanding of the number system. It also introduces some of the commonly used number systems by computer professionals and the relationship between them. This chapter deals with the basic fundamentals of number system, computer arithmetic and binary Codes. Data in a computer is stored in a series of bits which are often interpreted in blocks known as bytes [8 bits] or words. The ALU (Arithmetic and Logic Unit) performs arithmetic operations on data and the control unit needs to decode instructions. Both of these functions are performed by logic circuits. The second part of this chapter deals with the digital logic, the Boolean algebra and the logical gates.

1.1) Objectives
This chapter presents the various binary systems suitable for representing information in digital systems. The binary number system is explained and binary codes are illustrated. Examples are given for addition and subtraction of signed binary numbers and decimal numbers in BCD. In this Chapter you will learn about Introduction Number Systems Decimal Number System Binary Number System Octal Number System Hexadecimal Number System Number System Conversions Representation of Negative Numbers Binary Coded Decimal and Gray Code Boolean Algebra Logic Gates Half Adder Full Adder Subtractors Karnaugh Maps (K-Maps) The Flip Flop

Page1

Digital Logic And Computer Organization

1.2) Content
1.2.1 Number Systems Number systems are basically of two types: non-positional and positional. Non-Positional Number Systems In early days, human beings counted on fingers. When ten fingers were not adequate, stones, pebbles or sticks were used to indicate values. This method of counting uses an additive approach or the non-positional number system. In this system, symbols such as I for 1, II for 2, III for 3, IIII for 4, IIIII for 5, etc are used. Each symbol represents the same value regardless of its position in the number and the symbols are simply added to find out the value of a particular number. Since it is very difficult to perform arithmetic with such a number system, positional number systems were developed as the centuries passed. Positional Number Systems In a positional number system, there are only a few symbols called digits and these symbols represent different values depending on the position they occupy in the number. The value of each digit in such a number is determined by three considerations. 1. 2. 3. the digit itself; the position of the digit in the number; and the base of the number system (where base is defined as the total number of digits available in the number system).

The number system that is used in our day-to-day life is called the Decimal number system. In this system, the base is equal to 10 because there are altogether ten symbols or digits (0,1,2,3,4,5,6,7,8,9) used in this system. In the decimal system, the successive positions to the left of the decimal point represent units, tens, hundreds, thousands, etc. It may also be observed that the same digit signifies different values depending upon the position it occupies in the number. For example, In 258610 In 256810 In 265810 In 625810 the digit 6 signifies 6 the digit 6 signifies 6 the digit 6 signifies 6 the digit 6 signifies 6 100 = 6 101 = 60 102 = 600 103 = 6000

Page2

Digital Logic And Computer Organization


Thus using the available digits and arranging them in various positions can represent any number. The principles that apply to the decimal system apply in any other positional number system. There are two characteristics of all number systems that are suggested by the value of the base. In all the number systems, the value of the base determines the total number of different symbols or digits available in the number system. The first of these choices is always zero. The second characteristic is that the maximum value of a single digit is always equal to one less than the value of the base. Decimal Number System The conventional number system used currently is the decimal number system. The decimal number system has the digits from 0 to 9 and the numbers have a base ten. The smallest number in this system is 0 and the largest number is 9. A decimal number fifty-eight is represented as (58)10 Any decimal number can be converted to another base by dividing the given decimal number by the base to be converted to. Binary Number System The binary number system is exactly like the decimal system except that the base is 2 instead of 10. There are only two symbols or digits (0 and 1) that can be used in this number system. Note the largest single digit is 1 (one less than the base). Again, each position in a binary number represents a power of the base (2). As such, in this system, the rightmost position is the units (20) position, the second position from the right is the 2s (21) position and proceeding in this way the third position is the 4s (22) position, the fourth position is the 8s (23) position and so on. Thus, the decimal equivalent of the binary number 10101 (written as 101012) is (1 24) + (0 23) + (1 22) + (0 21) + (1 20) or or 16 21 + 0 + 4 + 0 + 1

In order to be specific about which system is referred to, it is common practice to indicate the base as a subscript. Thus the numbers are represented as: 101012 = 2110 The common abbreviation bit often refers to Binary digit. Thus, a bit in computer technology means either a 0 or a 1. A binary number consisting of n bits is called an n-bit number. Table 1.1 lists all the 3-bit numbers along with their decimal equivalent. Remember that there are only two digits, 0 and 1, in the binary system and hence the binary equivalent of the decimal number 2 has to be stated as 10 (read as one,zero). Page3

Digital Logic And Computer Organization


Another important point to note is that with 3 bits (positions), only 8 (23) different patterns of 0s and 1s are possible and from Table 1.1 it may be seen that a 3-bit number can have one of the 8 values in the range 0 to 7. In fact, it can be shown that any decimal number in the range 0 to 2n-1 can be represented in the binary form as an n-bit number. Binary Decimal Equivalent

000 0 001 1 Table 1.1: 3-bit010 Numbers With their Decimal Values 2 011 3 Octal Number System 100 4 In the octal number system the base is 8. So in this system, there are only eight 101 5 symbols or digits: 0,1,2,3,4,5,6 110 7 (8 and 9 do not exist in this system). Here, the and 6 largest single digit is 7 (one less than the base). 7Again, each position in an octal number 111 represents a power of the base (8). Thus, the decimal equivalent of the octal number 2057 (written as 20578) is : (2 83)+ (0 82) + (5 81)+ (7 80) or 1024 + 0 + 40 + 7 or 1071 Thus, 20578 = 107110. Observe that since there are only 8 digits in the octal number system, so 3 bits (23 =8) are sufficient to represent any octal number in binary. Hexadecimal Number System The hexadecimal number system is one with a base of 16. The base of 16 suggests choices of 16 single-character digits or symbols. The first 10 digits are the digits of a decimal system 0,1,2,3,4,5,6,7,8 and 9. The remaining six digits are denoted by A,B,C,D,E and F representing the decimal values of 10,11,12,13,14 and 15 respectively. In the hexadecimal number system, therefore, the letters A through F are number digits. The number A has a decimal equivalent value of 10, B has a value of 11 and so on. Thus, the largest single digit is F or 15 (one less than the base). Again, each position in a hexadecimal system represents a power of the base (16). Thus, the decimal equivalent of the hexadecimal number 1AF is 431. (1 162) + (A 161) + (F 160) or or (1 256)+(10 16)+(15 1) 256 + 160 + 15

Page4

Digital Logic And Computer Organization


or 431

Thus, 1AF16 = 43110 Observe that since there are only 16 digits in the hexadecimal number system, 4 bits (2 = 16) are sufficient to represent any hexadecimal number in binary.
4

1.2.2 Number System Conversions Numbers expressed in decimal are much more meaningful than are values expressed in any other number system. This is mainly because of the fact that decimal numbers are used in day-to-day life. Any number value in one number system can be represented in any other number system. Because the input and the final output values are to be in decimal, computer professionals are often required to convert numbers in other number systems to decimal and vice versa. There are many methods or techniques that can be used to convert numbers from one base to another. Converting to Decimal from another base The following three steps are used to convert to a base 10 value from any other number system: Step 1: Determine the column (Positional) value of each digit (this depends on the position of the digits and the base of the number system). Step 2: Multiply the obtained column values (In Step 1) with the digits in the corresponding columns. Step 3: Sum the products calculated in Step 2. The total is the equivalent value in decimal. Example 1.1 110012 = ?10 Solution: Step 1: Determine column values Column Number (from right) 1 2 3 4 5 Column Value 20 = 1 21 = 2 22 = 4 23 = 8 24 =16

Step 2: Multiply column values by corresponding column digits

Page5

Digital Logic And Computer Organization


16 8 4 2 1 1 1 0 0 1 ____ ____ ____ ____ ____ 16 8 0 0 1 Step 3: Sum the products 16+8+0+0+1=25 Hence, 110012 = 2510 Example 1.2 47068 = ?10 Solution: Step 1: Column Number (from right) 1 2 3 4 Step 2: 512 64 4 7 2048 448 Step 3: 2048 + 448 + 0 + 6 = 2502 Hence, 47068 = 250210 Example 1.3 1AC16 = ?10 Solution: 1AC16 = 1 162 + A 161 + C 160 = 1 256 + 10 16 + 12 1 = 256 + 160 + 12 = 42810 8 0 0 1 6 6 Column Value 80 = 1 81 = 8 82 = 64 83 = 512

Page6

Digital Logic And Computer Organization


Converting from a Base 10 to a New Base This method is also called as Division Remainder Technique. The following four steps are used to convert a number from base 10 to a new base. Step 1: Divide the decimal number to be converted, by the value of the new base. Step 2: Record the remainder from step1 as the Rightmost digit (least significant digit) of the number to the new base. Step 3: Divide the quotient of the previous division by the new base. Step 4: Record the remainder from step 3 as the next digit (to the left) of the number to the new base. Repeat steps 3 and 4, recording remainders from right to left, until the quotient becomes zero in step 3. Note the last remainder thus obtained will be the most significant digit (MSD) of the new base number. Example 1.4 2510 = ?2 Solution: Steps 1 & 2: Steps 3 & 4: Steps 3 & 4: Steps 3 & 4: Steps 3 & 4: 25/2=12 and remainder 1 12/2=6 and remainder 0 6/2 =3 and remainder 0 3/2 =1 and remainder 1 1/2 =0 and remainder 1

As mentioned in Steps 2 & 4, the remainders have to be arranged in the reverse order so that the first remainder becomes the Least Significant Digit (LSD) and the last remainder becomes the Most Significant Digit (MSD). Hence 2510 = 110012 Example 1.5 4210 = ?2 Solution: 2 42 21 Remainders 0

Page7

Digital Logic And Computer Organization


10 5 2 1 0 Hence,4210 = 1010102 Example 1.6 95210 = ? 8 Solution: 8 952 119 14 1 0 Hence, 95210 = 16708 Example 1.7 42810 =?16 Solution: 16 428 26 1 0 Hence, 42810 =1AC16 Converting from a base other than 10 to a base other than 10 The following two steps are used to convert a number from a base other than 10 to a base other than 10. Page8 Remainders in Hexadecimal 12 = C 10 = A 1=1 Remainders 0 7 6 1 1 0 1 0 1

Digital Logic And Computer Organization


Step1: Convert the original number to a decimal number (base 10). Step2: Convert the decimal number so obtained to the new base. Example 1.8 1011102=?8 Solution: Step1: Convert 1011102 to base 10 1011102 = 1 25 + 0 24 + 1 23 + 1 22 + 1 21 + 0 20 = 32 + 0 + 8 + 4 + 2 + 0 = 4610 Step2: Convert 4610 to base 8. 8 46 5 0 Remainders 6 5

Hence, 4610 = 568 So, 1011102 = 4610=568 Thus, 1011102 = 568 Shortcut methods for conversions There are shortcut methods of conversion from one base to another. The octal number can be converted to hexadecimal format without being converted to decimal and then being divided by 16. Each digit of the octal number are split and represented by equivalent binary numbers of 3 bits each. And the binary number can then be grouped into 4 bits each for representing a hexadecimal number. The shortcut methods of conversion are as follows: Binary to Octal The following steps are used in this method: Step 1: Divide the binary digits into groups of three (starting from the right). Step 2: Convert each group of three binary digits into one octal digit. Since decimal digits 0 to 7 are equal to octal digits 0 to 7 so binary to decimal

Page9

Digital Logic And Computer Organization


conversion can be used in this step. Example 1.9 1011102 = ?8 Solution: Step 1: Divide the binary digits into groups of 3 starting from right (LSD) 101 110

Step 2: Convert each group into one digit of octal (use binary-to-decimal conversion) 1012 = 1 22 + 0 21 + 1 20 = 4 + 0 + 1 = 58 = 1 22 + 1 21 + 0 20 = 4 + 2 +0 = 68

1102

Hence, 1011102 = 568 Octal to Binary The following steps are used in this method: Step 1 : Convert each octal digit to a 3 digit binary number (The octal digits may be treated as Decimal for this conversion). Step 2: Combine all the resulting binary groups (of 3 digits each) into a single binary number. Example 1.10 5628 = ?2

Solution: Step 1: Convert each octal digit to 3 binary digits. 58 = 1012 68 = 1102 28 = 0102 Page10

Digital Logic And Computer Organization


Step 2: Combine the binary groups. 5628 = 101 110 010 5 6 2 Hence, 5628 = 1011100102 Example 1.11 67518 = ?2 Solution : 67518 = 110 111 101 001 6 7 5 1

= 1101111010012 Hence, 67518 = 1101111010012 Binary to Hexadecimal The following steps are used in this method: Step 1: Divide the binary digits into groups of four (Starting from the right). Step 2: Convert each group of four binary digits to one hexadecimal digit. (The hexadecimal digits 0 to 9 are equal to decimal digits 0 to 9 and hexadecimal digits. A to F are equal to decimal digits 10 to 15. The decimal values 10 to 15 must be represented as hexadecimal A to F. Example 1.12 110100112 =? 16 Solution: Step 1: Divide the binary digits into groups of 4. 1101 0011 Step 2: Convert each group of 4 binary digits to 1 hexadecimal digit. 11012 = = = = 1 23 +1 22 +0 2 1+1 20 8 + 4 + 0 +1 1310 D16

0011 2 = 0 2 3 + 0 22 + 1 2 1 + 1 2 0 = 0 + 0 + 2 + 1 Page11

Digital Logic And Computer Organization


= 3 16 Hence, 110100112 = D3 16 Example 1.13 101101011002 =? 16 Solution: 101101011002 = 0101 1010 1100 (Group 4 digits from right) = 5AC (Convert each group to a hexadecimal digit) Hence, 101101011002 = 5AC 16 Hexadecimal to Binary The following steps are used in this method: Step 1: Convert the decimal equivalent of hexadecimal digit to 4 bit binary number. Step 2: Combine all the resulting binary groups (of 4 digits each) into single binary number. Example 1.14 2AB16 = ?2 Solution: Step 1: Convert the decimal equivalent of each hexadecimal digit into 4 binary digits. 216 = 210 = 00102 A16 = 1010 = 10102 B16 = 1110 = 10112 Step 2: Combine the binary groups 2AB16 = 0010 1010 1011 2 A B Hence, 2AB16 = 001010101011 2

Page12

Digital Logic And Computer Organization


Example 1.15 ABC16 = ? 2 Solution: ABC16 = 1010 A 1011 1100 B C

= 1010101111002 Hence, ABC16 = 1010101111002 Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Hexa Decimal 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 Binary 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10000 Octal 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 20

Table 1.2: Relationship between Decimal, Hexadecimal, Binary and Octal Number Systems. Finally, the above Table 1.2 summarizes the relationship between the decimal, binary, hexadecimal and octal number systems. Note that the maximum value for a single digit of octal (7) is equal to the maximum value of three digits of binary. The value range of one digit of octal duplicates the value range of three digits of binary. If octal digits are substituted for binary digits, the substitution is on a one-to-three basis. Similarly, note that the maximum value of one digit in hexadecimal is equal to the maximum value of four digits in binary. Thus, the value range of one digit of hexadecimal is equivalent to the value range of four digits of binary. Therefore, hexadecimal shortcut notation is a one-to-four reduction in the space and time required for memory dump.

Page13

Digital Logic And Computer Organization


1.2.3 Fractional Numbers In binary number system, fractional numbers are formed in the same general way as in the decimal system. A fraction in decimal number system can be represented as: 0.235 = (2 10-1) + (3 10-2) + (5 10-3) and 68.53 = (6 101) + (8 100) + (5 10-1) + (3 10-2) Similarly in the binary system, 0.101= (1 2-1) + (0 2-2) + (1 2-3) and 10.01= (1 21) + (0 20) +(0 2-1)+(1 2-2) Thus, the binary point serves the same purpose as the decimal point. Some of the positional values in the binary system are given below.

Binary Point Position 4 3 2 1 0 . -1 -2 -3 -4

Position Value 24 23 22 21 20 Quantity Represented 16 8 4 2 1

2-1 2-2 2-3 24 1/2 1/4 1/8 1/16

In general, a number in a number system with base b would be written as: an an-1 a1 a0 .a-1 a-2 a-m and would be interpreted to mean an bn + an-1 bn-1 + + a0 b0 + a-1 b-1 + a-2 b-2 + a-m b-m The symbols an a n-1, ., a-m used in the above representation should be one of the symbols allowed in the number system. Thus, as per the above mentioned general rule,

Page14

Digital Logic And Computer Organization


46.328 = (4 81) + (6 80) + (3 8-1) + (2 8-2) and 5A.3C16 = (5 161)+(A 160)+(3 16-1)+(C 16-2) Example 1.16 Find the decimal equivalent of the binary number 110.101 Solution: 110.1012 = = = = 1 22 + 1 21 + 0 20 +1 2-1+0 2-2+1 2-3 4 + 2 +0 + .5 + 0 + .125 6 + 0.5 + 0.125 6.62510

Example 1.17 Find the decimal equivalent of the octal number 127.54 Solution: 127.548 = 1 82 + 2 81+7 80+5 8-1+4 8-2 = 64 + 16 + 7 + 5/8 + 4/64 = 87+0.625+0.0625 = 87.687510 Example 1.18 Find the decimal equivalent of the hexadecimal number 2B.C4 Solution: 2B.C416 = 2x16 1+ Bx160 + Cx16-1+4x16-2 = 32 + 11 + C/16 + 4/256 = 43 + 0.75 + 0.015625 = 43.765652 10 1.2.4 Representation of Negative Number The 2s complement is used to represent the negative of a binary number. Before proceeding to 2s complement in the binary number system, 9s and 10s complement in the decimal number system are dealt with for better understanding.

Page15

Digital Logic And Computer Organization


9s complement. To obtain the 9s complement of a decimal number each digit of the number is subtracted from 9. For example, the 9s complement of 45 is (99-45) = 54. The 9s complement of 523 = (999 523) = 476. 10s complement. The 10s complement of a decimal number = its 9s complement + 1. The 10s complement of 45 = 54 + 1 = 55. The 10s complement of 523 = 476 + 1 = 477. On adding the number 45 and its 10s complement, the sum becomes zero (omitting the carry over). Example 1 + 4 5 0 5 5 0 Carry =1 (decimal number) (its 10s complement)

In this case the decimal number is of two digits. If the sum of the number and its 10s complement only up to two digits are considered, the sum becomes zero. Similarly, Example 2 5 2 3 (decimal number) + 4 7 7 (its 10s complement) ________________________________________ 0 0 0 Carry = 1 The decimal number 523 is of three digits. Considering the sum of the number and its 10s complement only up to three digits, the sum becomes zero. Thus it is concluded that the 10s complement gives the negative value of the number The 10s complement of a decimal number = - decimal number. 1s Complement. The 1s complement in the binary number system is similar to the 9s complement in the decimal system. The 1s complement of a binary number is obtained by subtracting each bit of the number from 1. The 1s complement of 01 is 10. The 1s complement of 111 is 000. Thus, the 1s complement of a binary number can be obtained by simply changing bit 1 to 0 and 0 to 1.

Page16

Digital Logic And Computer Organization


Example 1. Find 1s complement of 100110. The 1s complement of 100110 = 011001. Example 2 Find 1s complement of 0000 The 1s complement of 0000 = 1111. Example 3 Find 1s complement of 11111. The 1s complement of 11111 = 00000. 2s Complement. The 2s complement in the binary number system is similar to the 10s complement in the decimal number system. The 2s complement of binary number = its 1s complement + 1. Example 1. Find 2s complement of 10011. The 2s complement of 10011 = 01100 + 1 = 01101. Example 2. Find 2s complement of 111. The 2s complement of 111 = 000 + 1 = 001. Example 3. Find 2s complement of 0000. The 2s complement of 0000 = 1111 + 1 = 0000. Consider a case of adding a binary number to its 2s complement. Example 1. Binary number = 1001 Its 1s complement = 0110 Its 2s complement = 0110 + 1 = 0111. Number + its 2s complement = 1 0 0 + 0 1 1 __________________ 0 0 0 Carry =1

1 1 0

Page17

Digital Logic And Computer Organization


The last carry is lost if the processor is of 4 bits or only 4 bits sum is considered. For 8-bit processor the number and 2s complement will be written in 8 bits as given below: Number 1s complement 2s complement Number + 2s complement = = = = = = 00001001 11110110 11110110 + 1 11110111 00001001 11110111

__________________ 00000000 carry =1 The last carry will be neglected, if the 8 bit sum is considered. Example 2 + 4 (decimal) = -4 = Its 2s complement +4 -4 Example 3 Add + 5 and 7 7 -7 = 00000111 = 11111000 + 1 = 11111001 +5 = 00000101 -7 = 11111001 ____________________________ -2 = 11111110 2 -2 00000100 (binary) = 11111011 + 1 = 11111100 = 00000100 = 11111100 ______________________ 00000000

Check:

= 00000010 = 11111101 + 1 = 11111110 Thus, the 2s complement of a binary number represents its negative. 1.2.5 Binary Subtraction Using 2s Complement. The addition of 2s complement of a number is equivalent to the subtraction of the number. Suppose, 0010 ( 2 decimal) has to be subtracted from 0101 ( 5 decimal ). If the 2s complement of 0010 (2 decimal) is added to 0101 (5 decimal) the sum will be 0011 (3 decimal). It is equal to 0101 (5 decimal) 0010 (2 decimal) = 0011 (3 decimal).

Page18

Digital Logic And Computer Organization


Ordinary binary subtraction: 0101 (5 decimal) - 0010 (-2 decimal) ____________________ 0011 (3 decimal) Subtraction using 2s complement: 1s complement of 0010 (2 decimal) = 1101 2s complement of 0010 = 1101 + 1 = 1110 0101 (5 decimal) + 1110 ( + 2s complement of 2) ______________________________________ 0011 (3 decimal) The carry of the last stage is neglected. 1.2.6 Binary Coded Decimal One of the most widely used representations of numerical data is the binary coded decimal (BCD) form in which a 4-bit binary number represents each integer of a decimal number. It is particularly useful for the driving of display devices where a decimal output is desired. BCD usually refers to such coding in which the binary digits have their normal values, that is, 8421. Sometimes it is written "8421 BCD" to clearly distinguish it from other binary codes such as the 4221 Code, but when BCD is used without qualification, the 8421 version is assumed.

Figure 1.1: Binary Coded Decimal The following table gives the decimal number along with their BCD codes. __________________________________________________________________ Decimal Number Standard BCD Number

__________________________________________________________________ 0 0000 1 0001 2 0010 3 0011 4 0100 Page19

Digital Logic And Computer Organization


5 6 7 8 9 10 11 12 13 14 15 30 45 64 73 98 0101 0110 0111 1000 1001 00010000 00010001 00010010 00010011 00010100 00010101 00110000 01000101 01100100 01110011 10011000

__________________________________________________________________ Table 1.3: Decimal to Standard BCD Conversion 1.2.7 Alphanumeric Coding For the inherently binary world of the computer, it is necessary to put all symbols, letters, numbers, etc. into binary form. The most commonly used alphanumeric code is the ASCII code, with others like the EBCDIC code being applied in some communication applications. Gray Code The reflected binary or Gray Code is shown in Table 1.4. In this code only one bit changes in the transition from one number to the next higher number. The Gray code is used in shaft encoder, which is to indicate the angular position of a shaft. The use of Gray code reduces errors. Suppose that the present position of the shaft is indicated by Gray code 0100, which is for 7. If the position changes to 8, the Gray code will be 1100. If the detector does not pick up the encoder the new change in binary bit will show the previous position, that is, 7. But in case of ordinary binary code 7 is represented by 0111 and 8 by 1000. Now suppose the detector picks up the least significant bits, that is, 000, but fails to pick up the most significant bit 1, the output will be 0000 instead of 1000. So there is a large error if a simple binary code is used for a shaft encoder. _________________________________________________________________ _ Decimal Binary Code Gray Code _________________________________________________________________ _ 0 0000 0000

Page20

Digital Logic And Computer Organization


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1s Complement form 2s Complement Form Computer logic Computer Logic is based on Boolean Algebra (and, or, etc.) and it is possible to combine such operations into complex logical expressions. For example, (A OR B) AND (C NOT D) There are rules governing priority of the operators. Boolean Variables A Boolean variable has one of two values:

0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Table 1.4. Gray Code

0001 0011 0010 0110 0111 0101 0100 1100 1101 1111 1110 1010 1011 1001 1000

often referred to as TRUE or FALSE. dealing with an electronic system has either a voltage present (e.g. 5 or 3.3V) a value of 1 or no voltage a value of 0.

1.2.8 Boolean Algebra Boolean Algebra is the algebra of binary variables. Binary variables are also known as Boolean variables. Boolean variables have only two values 0 and 1. The only logical operations in Boolean algebra are OR, AND and NOT operations. The mathematical symbol + and . stand for OR and AND operations respectively. The symbol or is used for NOT (INVERT or COMPLEMENT) operation.

Page21

Digital Logic And Computer Organization


There are two important means to express the relationship between input and output variables of a digital system: truth table and Boolean expression. The aim of a designer is to use minimum number of basic circuits to perform a digital operation for which the first step is to write a Boolean expression for the system. This expression is minimized using Boolean theorems. The map is also a minimization technique which is used in the design of digital systems. The minimum number of circuits reduces the cost and increases the speed and reliability of the system. Table 1.1 presents a list of important Boolean theorems. The first four laws are for OR operation. The first law is A+0=A The binary variable A can have only two values, either 0 or 1. When 0 is put in the above equation for A, the above equation becomes: 0 + 0 = 0; This is true for OR operation. Similarly, when 1 is put for A, the following is got 1 + 0 =1 which is true for OR operation. Similarly, other laws can be explained putting 0 or 1 value for the binary variable A. 1. 2. 3. 4. 5. 6. 7. 8. A+0=A A + 1 =1 A+A=A A+A=1 A.0 = 0 A.1 = A A.A =A A . A=0

OR Laws

AND Laws

9. A = A 10. 1 = 0 11. 0 = 1 12. If A=0, then A =1 13. If A=1, then A = 0

Laws of complementation

Page22

Digital Logic And Computer Organization


14. A + B = B + A 15. A .B = B .A 16. (A + B) + C = A + (B + C) = A + B + C 17. (A.B).C = A.(B.C) = A.B.C 18. A . (B+C) = A .B + A .C Commutative laws Associative Laws Distributive Laws

19. A + AB = A 20. A . (A + B) = A 21. A + AB = A + B 22. A . (A + B) = AB 23. AB + AB = A 24. (A + B)(A + B) = A 25. AB + AC = (A + C) . (A + B) 26. (A + B) ( A + C) = AC + AB 27. AB + AC + BC = AB + AC 28. (A + B)(A + C)(B + C) = (A + B)(A + C) 29. (A + B +C + ) = A . B . C. 30. A.B.C = A + B + C Table 1.1. Boolean Algebraic Theorems In Table 1.1, laws 5 to 8 are for AND operation. The fifth law is A.0 = 0. This law is true for AND operation when A is put equal to either 0 to 1. Similarly, laws from 6 to 8 are true when the value of A is put either 0 or 1.Laws of complementation from 9 to 13 are obvious and very simple. Similarly all the laws can be justified by either assuming the value 1 or 0 for the variable used or using truth table or with the help of other Boolean laws. 1.2.9 Logic Gates The term Gate is used to describe the members of a set of basic electronic components which, when combined with each other, are able to perform complex logical and arithmetic operations. 'Gates' are the physical realization of the simple Boolean expressions. Logic gates can be designed with only a few electronic components. Types of Logic Gates

Page23

Digital Logic And Computer Organization


The transistors are the main components in designing the circuits. There are various types of logic gates.

Figure 1.1: Basic Gates 'OR' Gate If any input is logic 1 then the output of an OR gate will be logic 1.

Figure 1.2: OR Gate Truth Table


X 0 0 1 1 Y 0 1 0 1 X OR Y 0 1 1 1

The output value is 1 when at least one input value is 1 'AND' Gate The AND gate requires both inputs to be logic 1 for an output of logic 1

Figure 1.3: AND Gate

Page24

Digital Logic And Computer Organization


Truth Table
X 0 0 1 1 Y 0 1 0 1 X AND Y 0 0 0 1

The output is 1 only when both inputs are 1 XOR Gate If both the inputs are different the output is high.

Figure 1.4: XOR Gate Truth Table


X 0 0 1 1 Y 0 1 0 1 X XOR Y 0 1 1 0

'NOT' Gate (Inverter Gate) Any input is inverted. Logic 1 input yields logic 0 as output and vice versa.

Figure 1.5: NOT Gate Truth Table


X 0 1 X NOT Y 1 0

Not Gate takes only one input and is written as X or ~X in Boolean expressions.

Page25

Digital Logic And Computer Organization


NAND Gate It is a combination of AND gate and a NOT gate.

Figure 1.6: NAND Gate Truth Table


X 0 0 1 1 Y 0 1 0 1 X NAND Y 1 1 1 0

If both the inputs are high the output is low. NOR Gate It is a combination of OR gate and NOT gate.

Figure 1.7: NOR Gate Truth Table


X 0 0 1 1 Y 0 1 0 1 X NOR Y 1 0 0 0

XNOR Gate If both the inputs are same the output is high.

Page26

Digital Logic And Computer Organization

Figure 1.8: XNOR Gate Truth Table


X 0 0 1 1 Y 0 1 0 1 X XNOR Y 1 0 0 1

For two binary variables (taking values 0 and 1) there are 16 possible functions. The functions involve only three operations which make up Boolean algebra: AND, OR and COMPLEMENT. These operations are like ordinary algebraic operations in that they are commutative, associative and distributive.

Figure 1.9: Logical Functions Half Adder The logic circuits that perform addition within the Arithmetic and Logic Unit (ALU) of the CPU are called adders. A unit that adds two binary digits is called the half adder and the one that adds together three binary digits is called a full adder. A half adder sums two binary digits to give a sum term (S) and a carry term (C), both being Boolean variables. The truth table for the half adder would be as follows: Page27

Digital Logic And Computer Organization

X 0 0 1 1

Y 0 1 0 1

S 0 1 1 0

C 0 0 0 1

Figure 1.10: Truth Table for Half Adder.

Figure 1.11: Logic Gate for Half Adder. Full Adder A half adder logic circuit is an important component of computing systems however as this circuit cannot accept a carry bit from a previous addition it is not enough to fully perform additions for binary number greater than 1. In order to achieve this, a full adder is required. A full adder gives the sum and carry obtained after adding 3 bits.

Figure 1.12: Logic Gate for Full Adder.

Page28

Digital Logic And Computer Organization


Full Adder Logic

From the truth table, the carry bit output is given by the relationship COUT=ABCIN + ABCIN +ABCIN +ABCIN Since X +X =X, ABCIN can be added to the above expression giving, COUT=ABCIN + ABCIN +ABCIN +ABCIN+ ABCIN+ ABCIN Rearranging the terms gives, COUT=ABCIN + ABCIN + ABCIN +ABCIN +ABCIN+ ABCIN On taking out the common terms, COUT =BCIN(A+A)+ACIN(B+B)+AB(CIN+CIN) COUT =ACIN+ BCIN+AB The full adder logic relationship from the truth table is: S=ABCIN+ABCIN+ABCIN+ABCIN Factoring out A S=A(BCIN+BCIN)+A(BCIN+BCIN) which is, Assume, then this can be seen to be another XOR statement, which can be written as

Page29

Digital Logic And Computer Organization

Subtractors Binary Subtraction can be done by means of complements. For example, Subtraction of A B can be done by means of taking 2s complement of B and adding it to A. The 2s complement of B is obtained by taking 1s complement of B and adding 1 to the least significant bit. The 1s complement is implemented with inverters and one is added to the sum through the input carry. The addition and subtraction operations can be combined into one common circuit by including an Exclusive-OR gate with each full adder. A 4-bit adder-subtractor circuit is shown in figure 2.13. The mode input M controls the operation. When M = 0 the circuit is an adder and when M = 1 the circuit becomes a subtractor. Each Exclusive-OR gate receives input M and one of the inputs B. When M = 0, B 0 = B. The full-adders receive the value of B, the input carry is 0 and the circuit performs A plus B. When M = 1, B 1 = B and C0 = 1 results. The B inputs are all complemented and a 1 is added through the input carry. The circuit performs the operation A plus the 2s complement of B. For unsigned numbers, this gives A B if A >= B or the 2s complement of (B A) if A<= B.
B3 A3 B2 A2 B1 A1 B0 A0
M

FA
C4

C3

FA
S2

C2

FA
S1

C1

FA
S0

C0

S3

Figure 1.13: Logic Gate for Subtractor 1.2.10 Karnaugh Maps (K-Maps) Karnaugh or K- maps are useful tool fot boolean function minimization and for visualization of the boolean function. In brief, K-maps provide a graphical method for minimizing boolean functions via pattern recognition forup to about n=6 variables. For larger numbers of variables, there are computer algorithms which can yield near-minimal implementations. K-maps are a way of expressing truth tables to make minimization easier. They are constructed from minterm codes. Page30

Digital Logic And Computer Organization


Consider the boolean function

The truth table is A B f 0 0 1 m0 0 1 1 m1 1 0 1 m2 1 1 0 m3 The K-map is shown in Figure 1.14. The essence of the K-map is the two dimensional representation of f, which is equivalent to the truth table but more visual. To minimize f, the logical adjacencies are looped out. (a)

Page31

Digital Logic And Computer Organization


(b)

Figure 1.14: K-map showing looped-out terms and also corresponding minterms. Therefore This is less complex than f in canonical SOP form. Note that looping out logical adjacencies is a graphical alternative to algebraic calculations. Unit distance code (Gray code.) For two bits, the Gray code is: 00 01 11 10 Only one bit changes as one goes from left to right. This code preserves logical adjacencies. The K-map method is to loop out groups of 2n logically adjacent minterms. Each looped out group corresponds to a product term in a minimal SOP expression. 1. Loop out single 1s (n=0) which have no logical adjacencies. 2. Loop out all pairs of 1s (n=1) which cannot be included in a larger group. 3. Loop out all quads of 1s (n=2) which cannot be included in a larger group etc. Example. The K-map is shown in Figure 1.15.

Figure 1.15: K-map for . Page32

Digital Logic And Computer Organization


Moving left to right or up to down in the K-map changes only one digit in the minterm code. Note the wrap-around at the ends: because of logical adjacency, the top and bottom are joined and the left and right are joined. n=0: none n=1: n=2: Therefore the minimal SOP representation is

Example : The K-map is shown in Figure 1.16.

Figure 1.16: K-map for

Page33

Digital Logic And Computer Organization


Therefore the minimal SOP representation is

Don't cares. In some applications it doesn't matter what the output is for certain input values. These are called don't cares. For instance, in the Binary Coded Decimal code, not all input values occur: 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 0 1 2 3 4 5 6 7 8 9

1 0 1 0 10 1 0 1 1 11 1 1 0 0 12 1 1 0 1 13 1 1 1 0 14 1 1 1 1 15 The decimal numbers are those in the range needed to encode these. The remaining numbers which are not used in BCD. and a minimum of 4 bits is correspond to code values

The symbols or X are used to denote don't cares. Don't cares can be exploited to help minimize boolean functions. Example : Figure 1.17. The K-map is shown in

Page34

Digital Logic And Computer Organization

Figure 1.17: K-map for . The minimal SOP representation is 1.2.11 The Flip-Flop One of the basic operations in a computer is the storage and retrieval of data from memory. Part of the electronic component responsible for the storage of data is known as the 'flip-flop'. It can store binary bit either 0 or 1. It has two stable states: HIGH and LOW, that is, 1 and 0. It has the property to remain in one state indefinitely until it is directed by an input signal to switch over to the other state. It is also called bistable multivabrator. It is a basic memory element. The basic flip flops are S-R Flip flop, JK Flip flop, D Flip flop, T Flip flop. For Presetting and Clearing a clocked flip flop may be required before applying inputs. For this purpose Preset (PR) and Clear (CLR) terminals are provided. PR and CLR are not low at the same time. Preset and Clear are used to initialize a circuit before normal clocked operation of the circuit starts.

Figure 1.18: Basic Flip-Flops

Page35

Digital Logic And Computer Organization


Multivibrators Two-state devices called multivibrators are used extensively in digital electronics. The bistable multivibrators are called flip-flops and are the basic memory devices used in sequential logic. Other two-state devices include the astable multivibrator, which serves as an oscillator, and the monostable multivibrator ("one-shot" multivibrator), which can serve as a pulse source. Astable Multivibrator Astable multivibrator is a two-state device which is not stable in either state. The configuration of NAND gate inverters shown is one of many ways to create an astable multivibrator. If point A is high, then that high voltage charges the capacitor and after a time characteristic of the time constant RC will reach the threshold for switching A low and B high. Then the charging process will reverse until the transition back to the original state occurs. This circuit can be constructed from NAND gate.

Figure 1.19: Astable Multivibrator Monostable Multivibrator In response to a positive trigger pulse the monostable multivibrator or "one-shot" will produce a single output pulse of length t determined by the value of the resistor and capacitor. The non-retriggerable one-shot will not respond to further trigger pulses which happen during its pulse length.

(a) (b) Figure 1.20: (a) Monostable Multivibrator (b) Timing diagram

Page36

Digital Logic And Computer Organization


The logic circuit for the (SR) flip-flop is simple and shows that complex operations in a computer can be built-up from simple components.

Figure 1.21: Logic Circuit for the SR flip-flop Clocked Set-Reset Flip-flop When the signal line S goes high, the other line to the NAND gate from the pulse steering circuit must also be high for it to generate a low output. Likewise, a clock pulse must have the reset NAND gate high to receive a high RESET pulse. Therefore all transitions are synchronized to the clock.

Figure 1.22: Clocked Set-Reset Flip-flop Pulse-Steering Circuit In order to add clock synchronization to a flip-flop, a ciruit is used to apply the clock pulses to the flip-flop. To convert a NAND gate latch to a clocked S/R flip-flop, two NAND gates may be used as above left to enable an input pulse on either the S or R lines to trigger a transition.

Figure 1.23: Set-Reset Flip-flop clock pulses

Page37

Digital Logic And Computer Organization


Resetting the NAND Latch The NAND latches are reset as shown below in the figure 1.24(a) . The time sequence in figure 1.24(b) shows the conditions under which the set and reset inputs cause a state change and when they don't.

(a) (b) Figure 1.24: (a) Resetting NAND Gate (b) Timing Diagram Clocked D Flip-Flop A D flip-flop constructed from a NAND-latch. The D flip-flop tries to follow the input D but cannot make the required transitions unless it is enabled by the clock. Note that if the clock is low when a transition in D occurs, the tracking transition in Q occurs at the next upward transition of the clock.

(a)

(b)

Figure 1.25: (a) D-Flip-Flop (b) Clocked D Flip-flop

Page38

Digital Logic And Computer Organization

Figure 1.26: (a) D-Flip-Flop (b) Clocked D Flip-flop T Flip Flop The T Flip-Flop is obtained from a JK flip-flop when J and K are connected to provide a single input designated by T. The T flip-flop therefore has only to conditions. When T = 0 (J=K=0) a clock transition does not change the state of the flip-flop. When T = 1 (J=K=1) a clock transition complements the state of the flip-flop. These conditions can be expressed by a characteristic equation: Q (t 1) = Q(t) T J J >C
K

K 0 1 0 1

Q(t + 1) Q(t) 0 1 Q(t) No Change Clear to 0 Set to 1 Complement

0 0 1 1

T Q >C

J 0 1

Q(t + 1) Q(t) Q(t) No Change Complement

J-K Flip-Flop The J-K flip-flop is the most versatile of the basic flip-flops. It has the input- following character of the clocked D flip-flop but has two inputs,traditionally labeled J and K. If J and K are different then the output Q takes the value of J at the next clock edge. The outputs feed back to the enabling NAND gates. This is what gives the toggling action when J=K=1 If J and K are both low then no change occurs. If J and K are both high at the clock edge then the output will toggle from one state to the other. It can perform the functions of the set/reset flip-flop and has the advantage that there are no ambiguous

Page39

Digital Logic And Computer Organization


states. It can also act as a T flip-flop to accomplish toggling action if J and K are tied together. This toggle application finds extensive use in binary counters.

(a)

(b)

(c) Figure 1.27: (a) J-K Flip Flop circuit (b) Truth Table (c) J-K Flip-Flop with clock Switching Example - J-K Flip-Flop The positive going transition (PGT) of the clock enables the switching of the output Q. The "enable" condition does not persist through the entire positive phase of the clock. The J & K inputs alone cannot cause a transition, but their values at the time of the PGT determine the output according to the truth table. This is an application of the J-K flipflop.

(a)

Page40

Digital Logic And Computer Organization

(b) Figure 1.28: (a) Clock J-K Flip Flop (b) Timing Diagram

J-K Flip-Flop Data Transfer In synchronous data transfer between two J-K flip-flops, a transfer signal on the clock put causes transfer from cell A to cell B. The transfer signal could be applied to several such cells in series to create a shift register.

(a)
Figure 1.29: Truth Table for J-K Flip Flop

(b)

In asynchronous data transfer, a transfer pulse may be applied at any time to force the data onto the asynchronous set and clear inputs, storing the data regardless of what is happening on the other inputs. NAND-gate Latch The concept of a "latch" circuit is important to creating memory devices. The function of such a circuit is to "latch" the value created by the input signal to the device and hold that value until some other signal changes it.

Page41

Digital Logic And Computer Organization

Figure 1.30: NAND Gate Latch Setting and Resetting the NAND Latch After being set to Q=1 by the low pulse at S (NAND gate function), the restored normal value S=1 is consistent witht the Q=1 state, so it is stable. Another negative pulse on S gives which does not switch the flip-flop, so it ignores further input.

(a)

(b) Figure 1.31: (a) Setting NAND Gate Latch (b) Resetting NAND Gate Latch

Page42

Digital Logic And Computer Organization 1.3) Revision Points


In binary coding, every symbol, which appears in the data, is represented by a group of bits The group of bits used to represent a symbol is called a byte. Most modern computers use 8 bits to represent a symbol. Hence, the term byte is commonly used to mean a group of 8 bits. The commonly used computer codes for internal representation of data are BCD, EBCDIC, ASCII BCD( Binary Coded Decimal) is a 6- bit code, which can represent 64 different characters. EBCDIC(Extended Binary- coded Decimal Interchange Code) is an 8- bit code which can represent 256 different characters. ASCII(American Standard Code for Information Interchange) is one of the most popular computer codes. It is of two types ASCII -7 and ASCII-8. ASCII-7 is a 7- bit code which can represent 128 different characters and ASCII_8 is an 8-bit code, which can represent 256 different characters. Negative numbers can be represented by: 1. Signed- magnitude form 2. 1s Complement form 3. 2s Complement Form

1.4) Intext Questions


1. What is the difference between a positional and a non-positional number system? 2. A new computer code is designed, which uses 10 bits. How many different characters are possible in this code? 3. Write short notes on: 1.ASCII 2.BCD 3.EBCDIC 4.Hexadecimal notation & 5.Octal Notation 4. What is the exact number of bytes in a system that contains 1. 32KB 2. 64 MB 3. 12.8 GB

1.5) Summary
Number systems are basically of two types: non-positional and positional. In all the number systems, the value of the base determines the total number of different symbols or digits available in the number system. The decimal number system has the digits from 0 to 9 and the numbers have a base ten. The binary number system has only two symbols or digits (0 and 1) that can be used with the base 2.

Page43

Digital Logic And Computer Organization


In the octal number system the base is 8. In this system, there are only eight symbols or digits: 0,1,2,3,4,5,6 and 7. In the hexadecimal number system the base is 16. In this system, there are only 16 symbols or digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F. It is convenient to use Gray code to represent the digital data when it is converted from analog data. The advantage of Gray code over the straight binary number sequence is that only one bit in the code group changes when going from one number to the next. Data in a computer is stored in a series of bits which are often interpreted in blocks known as bytes [8 bits], words [2, 4 or 8 bytes]. Computer Logic is based on Boolean Algebra and it is possible to combine such operations into complex logical expressions. A Boolean variable has one of two values often referred to as TRUE or FALSE. There are two important means to express the relationship between input and output variables of a digital system: truth table and Boolean expression. The term Gate is used to describe the members of a set of basic electronic components which, when combined with each other, are able to perform complex logical and arithmetic operations. 'Gates' are the physical realization of the simple Boolean expressions. For two binary variables (taking values 0 and 1) there are 16 possible functions, that involve only three operations which make up Boolean algebra: AND, OR and COMPLEMENT. One of the most widely used representations of numerical data is the binary coded decimal (BCD) form in which a 4-bit binary number represents each integer of a decimal number. The logic circuits that perform addition within the Arithmetic and Logic Unit (ALU) of the CPU are called adders. Part of the electronic component responsible for the storage of data is known as the 'flip-flop'.

1.6) Terminal Exercises


1. Find out the octal equivalents of the following binary numbers: 2. (a) 1101011 (b) 1000 3. Find out the hexadecimal equivalents of the following binary numbers: 4. (a) 11010010 (b) 110001 5. Convert the following numbers to decimal: 6. (a) 2A3B16 (b) 12349 7. Convert the following decimal numbers to binary: 8. (a) 43510 (b) 3210 Page44

Digital Logic And Computer Organization


9. Explain the Boolean theorems. 10. Describe the various types of logic gates with circuits and truth tables. 11. Explain the functionality of Half adder and Full adder. 12. Explain the types of multi-vibrators. 13. Explain the Clocked Set-Reset flip-flop in detail. 14. Explain the J-K flip-flop in detail. 15. Explain the D flip-flop in detail.

1.7) Supplementary Materials


1. Digital Design, M. Morris Mano, Pearson Education Asia

1.8) Assignments
Conversions from one representation to another can be given

1.9) Reference Books


1. Computer Engineering: Hardware Design, M>Morris; Mano, PrenticeHall

1.10) Learning Activities


Convert decimal +71 and + 67 to binary using the signed- 2s complement representation and enough digits to accommodate the numbers. Then perform the binary equivalent of (+71) + (-67), (-71)+ (+67) (-71 + (-67). Convert the answers back to decimal and verify that they are correct.

1.11) Keywords
Bit Byte Signed magnitude form 1s Complement form 2s Complement Form

Page45

Digital Logic And Computer Organization


Flip-flop Register

Page46

Você também pode gostar