Anda di halaman 1dari 31

Basic Electrical & Electronics Engineering

Unit IV
NUMBER SYSTEMS USED IN DIGITAL ELECTRONICS,
Number systems are used to describe the quantity of something or represent certain information. Because of this, I can say that the word "calculator" contains ten letters. Our number system, the decimal system, uses ten symbols. Therefore, decimal is said to be Base Ten. By describing systems with bases, we can gain an understanding of how that particular system works. When we count in Base Ten, we count starting with zero and going up to nine in sequence 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Once we reach the last symbol, we create a new placement in front of the first and count that up. 8, 9, 10, 11, 12 19, 20 This continues when we run out of symbols for that placement. So, after 99, we go to 100. The placement of a symbol indicates how much it is worth. Each additional placement is an additional power of 10. Consider the number of 2853. We know this number is quite large, for example, if it pertains to the number of apples in a basket. That's a lot of apples. How do we know it is large? We look at the number of digits. Each additional placement is an additional power of 10, as stated above. Consider this chart. 103 102 101 100 digit digit digit digit *1000 *100 *10 *1 Each additional digit represents a higher and higher quantity. This is applicable for Base 10 as well as to other bases. Knowing this will help you understand the other bases better.

BINARY
Binary is another way of saying Base Two. So, in a binary number system, there are only two symbols used to represent numbers: 0 and 1. When we count up from zero in binary, we run out of symbols much more frequently. 0, 1, From here, there are no more symbols. We do not go to 2 because in binary, a 2 doesn't exist. Instead, we use 10. In a binary system, 10 is equal to 2 in decimal. We can count further. Binary 0 Decimal 0 1 10 11 100 101 110 111 1000 1001 1010 1 2 3 4 5 6 7 8 9 10

Just like in decimal, we know that the more digits there are, the larger the number. However, in binary, we use powers of two. In the binary number 1001101, we can create a chart to find out what this really means. 1
Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


2 2 2 2 2 2 2 1 0 0 1 1 0 1 64+0+0+8+4+0+1 87
6 5 4 3 2 1 0

Since this is base two, however, the numbers don't get quite as large as it does in decimal. Even still, a binary number with 10 digits would be larger than 1000 in decimal. The binary system is useful in computer science and electrical engineering. Transistors operate from the binary system, and transistors are found in practically all electronic devices. A 0 means no current, and a 1 means to allow current. With various transistors turning on and off, signals and electricity is sent to do various things such as making a call or putting these letters on the screen. Computers and electronics work with bytes or eight digit binary numbers. Each byte has encoded information that a computer is able to understand. Many bytes are stringed together to form digital data that can be stored for use later.

OCTAL
Octal is another number system with less symbols to use than our conventional number system. Octal is fancy for Base Eight meaning eight symbols are used to represent all the quantities. They are 0, 1, 2, 3, 4, 5, 6, and 7. When we count up one from the 7, we need a new placement to represent what we call 8 since an 8 doesn't exist in Octal. So, after 7 is 10.

Octal 0 Decimal 0

1 1

2 3 2 3

4 4

5 5

6 6

7 10 11 12 17 20 30 77 100 7 8 9 10 15 16 24 63 64

Just like how we used powers of ten in decimal and powers of two in binary, to determine the value of a number we will use powers of 8 since this is Base Eight. Consider the number 3623 in base eight. 8 3 8 2 81 80 3 6 2 3 1536+384+16+3 1939 Each additional placement to the left has more value than it did in binary. The third digit from the right in binary only represented 23-1, which is 4. In octal, that is 83-1 which is 64.

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering HEXADECIMAL


The hexadecimal system is Base Sixteen. As its base implies, this number system uses sixteen symbols to represent numbers. Unlike binary and octal, hexadecimal has six additional symbols that it uses beyond the conventional ones found in decimal. But what comes after 9? 10 is not a single digit but two Fortunately, the convention is that once additional symbols are needed beyond the normal ten, letters are to be used. So, in hexadecimal, the total list of symbols to use is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. In a digital display, the numbers B and D are lowercase. When counting in hexadecimal, you count 0, 1, 2, and so on. However, when you reach 9, you go directly to A. Then, you count B, C, D, E, and F. But what is next? We are out of symbols! When we run out of symbols, we create a new digit placement and move on. So after F is 10. You count further until you reach 19. After 19, the next number is 1A. This goes on forever. Hexadecimal 9 A B C D E F 10 11 19 1A 1B 1C 9F A0 Decimal 9 10 11 12 13 14 15 16 17 25 26 27 28 159 160 Digits are explained as powers of 16. Consider the hexadecimal number 2DB7. 163 162 161 160 2 D B 7 8192+3328+176+7 11703 As you can see, placements in hexadecimal are worth a whole lot more than in any of the other three number systems.

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering CONVERSION AND OPERATION


BASE CONVERSION TABLE
BIN OCT HEX DEC ---------------------0000 00 0 0 0001 01 1 1 0010 02 2 2 0011 03 3 3 0100 04 4 4 0101 05 5 5 0110 06 6 6 0111 07 7 7 ---------------------1000 10 8 8 1001 11 9 9 1010 12 A 10 1011 13 B 11 1100 14 C 12 1101 15 D 13 1110 16 E 14 1111 17 F 15

Convert From Any Base To Decimal Let's think more carefully what a decimal number means. For example, 1234 means that there are four boxes (digits); and there are 4 one's in the right-most box (least significant digit), 3 ten's in the next box, 2 hundred's in the next box, and finally 1 thousand's in the left-most box (most significant digit). The total is 1234:
Original Number: 1 2 | | How Many Tokens: 1 2 Digit/Token Value: 1000 100 Value: 1000 + 200 3 | 3 10 + 30 4 | 4 1 + 4

= 1234

or simply,

1*1000 + 2*100 + 3*10 + 4*1 = 1234

Thus, each digit has a value: 10^0=1 for the least significant digit, increasing to 10^1=10, 10^2=100, 10^3=1000, and so forth. Likewise, the least significant digit in a hexadecimal number has a value of 160=1 for the least significant digit, increasing to 161=16 for the next digit, 162=256 for the next, 163=4096 for the next, and so forth. Thus, 1234 means that there are four boxes (digits); and there are 4 one's in the right-most box (least significant digit), 3 sixteen's in the next box, 2 256's in the next, and 1 4096's in the left-most box (most significant digit). The total is:
1*4096 + 2*256 + 3*16 + 4*1 = 4660

Example:

Convert the hexadecimal number 4B3 to decimal notation. What about the decimal

equivalent of the hexadecimal number 4B3.3? 4


Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


Solution:
Original Number: 4 B | | How Many Tokens: 4 11 Digit/Token Value: 256 16 Value: 1024 +176 3 | 3 1 + 3 . 3 | 3 0.0625 + 0.1875

= 1203.1875

Example: Solution:

Convert 234.14 expressed in an octal notation to decimal.


4 | 4 1 + 4 . 1 | 1 0.125 + 0.125 + 4 | 4 0.015625 0.0625

2 3 | | How Many Tokens: 2 3 Digit/Token Value: 64 8 Value: 128 + 24

Original Number:

= 156.1875

Convert From Decimal to Any Base Again, let's think about what you do to obtain each digit. As an example, let's start with a decimal number 1234 and convert it to decimal notation. To extract the last digit, you move the decimal point left by one digit, which means that you divide the given number by its base 10.
1234/10 = 123 + 4/10

The remainder of 4 is the last digit. To extract the next last digit, you again move the decimal point left by one digit and see what drops out.
123/10 = 12 + 3/10

The remainder of 3 is the next last digit. You repeat this process until there is nothing left. Then you stop. In summary, you do the following:
Quotient Remainder ----------------------------1234/10 = 123 4 --------+ 123/10 = 12 3 ------+ | 12/10 = 1 2 ----+ | | 1/10 = 0 1 --+ | | | | | | | 1 2 3 4

(Stop when the quotient is 0.) (Base 10)

Now, let's try a nontrivial example. Let's express a decimal number 1341 in binary notation. Note that the desired base is 2, so we repeatedly divide the given decimal number by 2.
Quotient Remainder ----------------------------1341/2 = 670 1 ----------------------+ 670/2 = 335 0 --------------------+ | 335/2 = 167 1 ------------------+ | | 167/2 = 83 1 ----------------+ | | | 83/2 = 41 1 --------------+ | | | | 41/2 = 20 1 ------------+ | | | | | 20/2 = 10 0 ----------+ | | | | | | 10/2 = 5 0 --------+ | | | | | | | 5/2 = 2 1 ------+ | | | | | | | | 2/2 = 1 0 ----+ | | | | | | | | | 1/2 = 0 1 --+ | | | | | | | | | | | | | | | | | | | | | 1 0 1 0 0 1 1 1 1 0 1

(Stop when the quotient is 0) (BIN; Base 2)

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


Let's express the same decimal number 1341 in octal notation.
Quotient Remainder ----------------------------1341/8 = 167 5 --------+ 167/8 = 20 7 ------+ | 20/8 = 2 4 ----+ | | 2/8 = 0 2 --+ | | | | | | | 2 4 7 5

(Stop when the quotient is 0) (OCT; Base 8)

Let's express the same decimal number 1341 in hexadecimal notation.


Quotient Remainder ----------------------------1341/16 = 83 13 ------+ 83/16 = 5 3 ----+ | 5/16 = 0 5 --+ | | | | | 5 3 D

(Stop when the quotient is 0) (HEX; Base 16)

Example: Convert the decimal number 3315 to hexadecimal notation. What about the hexadecimal equivalent of the decimal number 3315.3? Solution:
Quotient Remainder ----------------------------3315/16 = 207 3 ------+ 207/16 = 12 15 ----+ | 12/16 = 0 12 --+ | | | | | C F 3

(Stop when the quotient is 0) (HEX; Base 16) (HEX; Base 16) 0.4 C C C ... | | | | ----+ | | | | | ------+ | | | | --------+ | | | ----------+ | | ---------------------+ (HEX)

Product Integer Part -------------------------------0.3*16 = 4.8 4 0.8*16 = 12.8 12 0.8*16 = 12.8 12 0.8*16 = 12.8 12 : : Thus, 3315.3 (DEC) --> CF3.4CCC...

Note that from the Base Conversion Table, you can easily get the binary notation from the hexadecimal number by grouping four binary digits per hexadecimal digit, or from or the octal number by grouping three binary digits per octal digit, and vice versa.
HEX 5 3 D BIN 0101 0011 1101 OCT 2 4 7 5 BIN 010 100 111 101

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


Finally, the fractional part is a decimal number can also be converted to any base by repeatedly multiplying the given number by the target base. Example: Convert a decimal number 0.1234 to binary notation
Product Integer Part -------------------------------0.1234*2 = 0.2468 0 0.2468*2 = 0.4936 0 0.4936*2 = 0.9872 0 0.9872*2 = 1.9744 1 0.9744*2 = 1.9488 1 0.9488*2 = 1.8976 1 0.8976*2 = 1.7952 1 0.7952*2 = 1.5904 1 0.5904*2 = 1.1808 1 0.1808*2 = 0.3616 0 0.3616*2 = 0.7232 0 0.7232*2 = 1.4464 1 : : (BIN; Base 2) 0.0 0 0 1 1 1 1 1 1 0 0 1 ... | | | | | | | | | | | | | ----+ | | | | | | | | | | | | ------+ | | | | | | | | | | | --------+ | | | | | | | | | | ----------+ | | | | | | | | | ------------+ | | | | | | | | --------------+ | | | | | | | ----------------+ | | | | | | ------------------+ | | | | | --------------------+ | | | | ----------------------+ | | | ------------------------+ | | --------------------------+ | ----------------------------+

Addition and Multiplication Tables You generate the addition tables in bases other then 10 by following the same rule you do in base 10. The resulting tables have the appearance of shifting the columns to the left by one in each subsequent row. Note how simple the addition and multiplication tables are for the binary system; addition operation is simply the bit-wise XOR operation with carry, and multiplication is simply the logical AND operation.

Decimal Addition Table: | 0 1 2 3 4 5 6 7 8 9 ---+----------------------------0 | 0 1 2 3 4 5 6 7 8 9 1 | 1 2 3 4 5 6 7 8 9 10 2 | 2 3 4 5 6 7 8 9 10 11 3 | 3 4 5 6 7 8 9 10 11 12 4 | 4 5 6 7 8 9 10 11 12 13 5 | 5 6 7 8 9 10 11 12 13 14 6 | 6 7 8 9 10 11 12 13 14 15 7 | 7 8 9 10 11 12 13 14 15 16 8 | 8 9 10 11 12 13 14 15 16 17 9 | 9 10 11 12 13 14 15 16 17 18

Binary Addition Table (equivalent to logical XOR operation with carry): | 0 1 ---+----0 | 0 1 1 | 1 10

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


Octal Addition Table: | 0 1 2 3 4 5 6 7 ---+----------------------0 | 0 1 2 3 4 5 6 7 1 | 1 2 3 4 5 6 7 10 2 | 2 3 4 5 6 7 10 11 3 | 3 4 5 6 7 10 11 12 4 | 4 5 6 7 10 11 12 13 5 | 5 6 7 10 11 12 13 14 6 | 6 7 10 11 12 13 14 15 7 | 7 10 11 12 13 14 15 16 Hexadecimal Addition Table: | 0 1 2 3 4 5 6 7 8 9 A B C D E F ---+----------------------------------------------0 | 0 1 2 3 4 5 6 7 8 9 A B C D E F 1 | 1 2 3 4 5 6 7 8 9 A B C D E F 10 2 | 2 3 4 5 6 7 8 9 A B C D E F 10 11 3 | 3 4 5 6 7 8 9 A B C D E F 10 11 12 4 | 4 5 6 7 8 9 A B C D E F 10 11 12 13 5 | 5 6 7 8 9 A B C D E F 10 11 12 13 14 6 | 6 7 8 9 A B C D E F 10 11 12 13 14 15 7 | 7 8 9 A B C D E F 10 11 12 13 14 15 16 8 | 8 9 A B C D E F 10 11 12 13 14 15 16 17 9 | 9 A B C D E F 10 11 12 13 14 15 16 17 18 A | A B C D E F 10 11 12 13 14 15 16 17 18 19 B | B C D E F 10 11 12 13 14 15 16 17 18 19 1A C | C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B D | D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C E | E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D F | F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E

You can also generate multiplication tables in bases other than 10 by following the same rule you do in base 10.
Decimal Multiplication Table: | 0 1 2 3 4 5 6 7 8 9 ---+----------------------------0 | 0 0 0 0 0 0 0 0 0 0 1 | 0 1 2 3 4 5 6 7 8 9 2 | 0 2 4 6 8 10 12 14 16 18 3 | 0 3 6 9 12 15 18 21 24 27 4 | 0 4 8 12 16 20 24 28 32 36 5 | 0 5 10 15 20 25 30 35 40 45 6 | 0 6 12 18 24 30 36 42 48 54 7 | 0 7 14 21 28 35 42 49 56 63 8 | 0 8 16 24 32 40 48 56 64 72 9 | 0 9 18 27 36 45 54 63 72 81

Binary Multiplication Table (equivalent to logical AND operation): | 0 1 ---+----0 | 0 0 1 | 0 1

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


Octal Multiplication Table: | 0 1 2 3 4 5 6 7 ---+----------------------0 | 0 0 0 0 0 0 0 0 1 | 0 1 2 3 4 5 6 7 2 | 0 2 4 6 10 12 14 16 3 | 0 3 6 11 14 17 22 25 4 | 0 4 10 14 20 24 30 34 5 | 0 5 12 17 24 31 36 43 6 | 0 6 14 22 30 36 44 52 7 | 0 7 16 25 34 43 52 61

Hexadecimal Multiplication Table: | 0 1 2 3 4 5 6 7 8 9 A B C D E F ---+----------------------------------------------0 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 | 0 1 2 3 4 5 6 7 8 9 A B C D E F 2 | 0 2 4 6 8 A C E 10 12 14 16 18 1A 1C 1E 3 | 0 3 6 9 C F 12 15 18 1B 1E 21 24 27 2A 2D 4 | 0 4 8 C 10 14 18 1C 20 24 28 2C 30 34 38 3C 5 | 0 5 A F 14 19 1E 23 28 2D 32 37 3C 41 46 4B 6 | 0 6 C 12 18 1E 24 2A 30 36 3C 42 48 4E 54 5A 7 | 0 7 E 15 1C 23 2A 31 38 3F 46 4D 54 5B 62 69 8 | 0 8 10 18 20 28 30 38 40 48 50 58 60 68 70 78 9 | 0 9 12 1B 24 2D 36 3F 48 51 5A 63 6C 75 7E 87 A | 0 A 14 1E 28 32 3C 46 50 5A 64 6E 78 82 8C 96 B | 0 B 16 21 2C 37 42 4D 58 63 6E 79 84 8F 9A A5 C | 0 C 18 24 30 3C 48 54 60 6C 78 84 90 9C A8 B4 D | 0 D 1A 27 34 41 4E 5B 68 75 82 8F 9C A9 B6 C3 E | 0 E 1C 2A 38 46 54 62 70 7E 8C 9A A8 B6 C4 D2 F | 0 F 1E 2D 3C 4B 5A 69 78 87 96 A5 B4 C3 D2 E1

Arithmetic Operations: You do arithmetic with hexadecimal numbers or numbers in any base in exactly the same way you do with decimal numbers, except that the addition and multiplication tables you employ to base your calculations are a bit different. Subtraction is equivalent to adding a negative number, and division is equivalent to multiplying by the inverse. Example: Find the sum of two hexadecimal integers 123 and DEF. Solution:
From the above hexadecimal addition table, we see that: 3+F=12, 2+E=10, and 1+D=E 123 + DEF ----carry 11 table E02 ----sum F12

Example: Find the sum of two binary integers 1 0010 0011 and 1101 1110 1111 9
Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


Solution:
1 0010 0011 + 1101 1110 1111 ---------------1 1 11 1100 1100 1100 ---------------1 1 1110 1000 1010 ---------------1 1 1110 0000 0010 ---------------1111 0001 0010 (binary) F 1 2 (hex)

carry table carry table carry table sum

Example. Find the product of two hexadecimal integers 123 and DEF. Solution:
Step 1: We break down the second multiplier into single digits. 123*DEF = 123*(D00+E0+F) = (123*D)*100 + (123*E)*10 + (123*F) Step 2: We find the product in parentheses. From the above hexadecimal multiplication table, we see that: 1*D=D, 2*D=1A, 3*D=27; thus, 123*D = (100+20+3)*D = 1*D*100 + 2*D*10 + 3*D = D*100 + 1A*10 + 27 = D00 + 1A0 + 27 = EC7 Likewise, 123*E = (100+20+3)*E = 1*E*100 + 2*E*10 + 3*E = E*100 + 1C*10 + 2A = E00 + 1C0 + 2A = FEA 123*F = (100+20+3)*F = 1*F*100 + 2*F*10 + 3*F = F*100 + 1E*10 + 2D = F00 + 1E0 + 2D = 110D Or, in elementary school style: 123 x D ----27 1A D ----EC7 Step 3: We sum up 123*DEF = = = = 123 x E ----2A 1C E ----FEA 123 x F ----2D 1E F ----110D

the individual products. (123*D)*100 + (123*E)*10 + (123*F) EC7*100 + FEA*10 + 110D EC700 + FEA0 + 110D FD6AD

Or, in elementary school style (in the order shown above):

10

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


123 x DEF ----EC7 FEA 110D ----FD6AD Or, in elementary school style: 123 x DEF ----110D FEA EC7 ----FD6AD

Example: Find the product of two binary integers 1 0010 0011 and 1101 1110 1111 Solution:
Step 2: 1 0010 0011 x 1 (the 1st "1" in 1101 1110 1111) ------------1 0010 0011 1 0010 0011 x 1 (the 1st "1" in 1101 1110 1111) ------------1 0010 0011 1 0010 0011 x 0 (the 1st "0" in 1101 1110 1111) ------------0 0000 0000 : : 1 0010 0011 x 1 (the last "1" in 1101 1110 1111) ------------1 0010 0011 Step 3: We sum up the individual products. 1 0010 0011 x 1101 1110 1111 -------------------100100011 100100011 000000000 100100011 100100011 100100011 100100011 000000000 100100011 100100011 100100011 100100011 -------------------11111101011010101101 (binary, after summing up all the above 12 binary numbers) F D 6 A D (hex)

11

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering BINARY ARITHMETIC


The arithmetic operations - addition, subtraction, multiplication and division, performed on the binary numbers is called binary arithmetic. In computer systems, the basic arithmetic operations performed on the binary numbers is Binary Addition, and Binary Subtraction,

In the following subsections, we discuss the binary addition and the binary subtraction operations.

Binary Addition Binary addition involves adding of two or more binary numbers. The binary addition rules are used while performing the binary addition. Table 1 shows the binary addition rules. Table 1. Binary Addition Rules for two inputs Input 1 Input 2 Sum Carry 0 0 0 No Carry 0 1 1 No Carry 1 0 1 No Carry 1 1 0 1 Binary addition of three inputs, when all the inputs are 1, follows the rule shown in Table 2. Table 2. Binary Addition Rules for three inputs Input 1 1 Input 2 1 Input 3 1 Sum 1 Carry 1

Addition of the binary numbers involves the following steps1. Start addition by adding the bits in unit column (the rightmost column). Use the rules of binary addition. 2. The result of adding bits of a column is a sum with or without a carry. 3. Write the sum in the result of that column. 4. If carry is present, the carry is carried-over to the addition of the next left column. 5. Repeat steps 2-4 for each column, i.e., the tens column, hundreds column and so on. Let us now understand binary addition with the help of some examples.

Example 1: Add 10 and 01. Verify the answer with the help of decimal addition. When we add 0 and 1 in the unit column, sum is 1 and there is no carry. The sum 1 is written in the unit column of the result. In the tens column, we add 1 and 0 to get the sum 1. There is no carry. The sum 1 is written in the tens column of the result.

12

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering

Example 2: Add 01 and 11. Verify the answer with the help of decimal addition. When we add 1 and 1 in the unit column, sum is 0 and carry is 1. The sum 0 is written in the unit column of the result. The carry is carried-over to the next column, i.e. the tens column. In the tens column, we add 0, 1 and the carried-over 1, to get sum 0 and carry 1. The sum 0 is written in the tens column of the result. The carry 1 is carried-over to the hundreds column. In the hundreds column, the result is 1.

Example 3: Add 11 and 11. Verify the answer with the help of decimal addition. When we add 1 and 1 in the unit column, sum is 0 and carry is 1. The sum 0 is written in the unit column of the result. The carry is carried-over to the tens column. In the tens column, we add 1, 1 and the carried-over 1. We use the rule for binary addition of three inputs shown in Table 2. We get sum 1 and carry 1. The sum 1 is written in the tens column of the result. The carry 1 is carried-over to the hundreds column. In the hundreds column, the result is 1.

13

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


Example 4: Add 1101 and 1111. Verify the answer with the help of decimal addition.

Example 5:

Add 10111, 11100 and 11. Verify the answer with the help of decimal addition.

Binary Subtraction Binary subtraction involves subtracting of two binary numbers. The binary subtraction rules are used while performing the binary subtraction. The binary subtraction rules are shown in Table 3. Input 1 0 0 1 1 Input 2 0 1 0 1 Difference 0 1 1 0 Borrow No Borrow 1 No Borrow No Borrow

The steps for performing subtraction of the binary numbers are as follows1. Start subtraction by subtracting the bit in the lower row from the upper row, in the unit column. 2. Use the binary subtraction rules. If the bit in the upper row is less than lower row, borrow 1 from the upper row of the next column (on the left side). The result of subtracting two bits is the difference. 3. Write the difference in the result of that column. 4. Repeat step 2-3 for each column, i.e., the tens column, hundreds column and so on. Let us now understand binary subtraction with the help of some examples.

14

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


Example 1: Subtract 01 from 11. Verify the answer with the help of decimal subtraction. When we subtract 1 from 1 in the unit column, the difference is 0. Write the difference in the unit column of the result. In the tens column, subtract 0 from 1 to get the difference 1. Write the difference in the tens column of the result.

Example 2: Subtract 01 from 10. Verify the answer with the help of decimal subtraction. When we subtract 1 from 0 in the unit column, we have to borrow 1 from the left column since 0 is less than 1. After borrowing from the left column, 0 in the unit column becomes 10, and, 1 in the left column becomes 0. We perform 10-1 to get the difference 1. We write the difference in the unit column of the result. In the tens column, subtract 0 from 0 to get the difference 0. We write the difference 0 in the tens column of the result.

Example 3: Subtract 0111 from 1110. Verify the answer with the help of decimal subtraction. When we do 0-1 in the unit column, we have to borrow 1 from the left column since 0 is less than 1. After borrowing from the left column, 0 in the unit column becomes 10, and, 1 in the left column becomes 0. We perform 10-1 to get the difference 1. We write the difference in the unit column of the result. In the tens column, when we do 0-1, we again borrow 1 from the left column. We perform 10-1 to get the difference 1. We write the difference in the tens column of the result. In the hundreds column, when we do 0-1, we again borrow 1 from the left column. We perform 10-1 to get the difference 1. We write the difference in the hundreds column of the result. In the thousands column, 0-0 is 0. We write the difference 0 in the thousands column of the result.

15

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering

Example 4: Subtract 10010 from 10101. Verify the answer with the help of decimal subtraction.

Example 5: Subtract 101111 from 110001. Verify the answer with the help of decimal subtraction.

Signed and Unsigned Numbers A binary number may be positive or negative. Generally, we use the symbol + and - to represent positive and negative numbers, respectively. The sign of a binary number has to be represented using 0 and 1, in the computer. An n-bit signed binary number consists of two parts sign bit and magnitude. The left most bit, also called the Most Significant Bit (MSB) is the sign bit. The remaining n-1 bits denote the magnitude of the number. In signed binary numbers, the sign bit is 0 for a positive number and 1 for a negative number. For example, 01100011 is a positive number since its sign bit is 0, and, 11001011 is a negative number since its sign bit is 1. An 8-bit signed number can represent data in the range -128 to +127 (27 to +27-1). The leftmost bit is the sign bit. In an n-bit unsigned binary number, the magnitude of the number n is stored in n bits. An 8bit unsigned number can represent data in the range 0 to 255 (28= 256).

16

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


Complement of Binary Numbers Complements are used in computer for the simplification of the subtraction operation. We now see, how to find the complement of a binary number. There are two types of complements for the binary number system 1s complement and 2s complement.

1s complement of Binary number is computed by changing the bits 1 to 0 and the bits 0 to 1. For example, o 1s complement of 110 is 001 o 1s complement of 1011 is 0100 o 1s complement of 1101111 is 0010000 2s complement of Binary number is computed by adding 1 to the 1s complement of the binary number. For example, o 2s complement of 110 is 001 + 1 = 010 o 2s complement of 1011 is 0100 + 1 = 0101 o 2s complement of 1101111 is 0010000 + 1 = 0010001

Binary Data Representation A binary number may also have a binary point, in addition to the sign. The binary point is used for representing fractions, integers and integer-fraction numbers. Registers are high-speed storage areas within the Central Processing Unit (CPU) of the computer. All data is brought into a register before it can be processed. For example, if two numbers are to be added, both the numbers are brought in registers, added, and the result is also placed in a register. There are two ways of representing the position of the binary point in the register - fixed point number representation and floating point number representation. The fixed point number representation assumes that the binary point is fixed at one position. The binary point is not actually present in the register, but its presence is assumed based on whether the number which is stored is a fraction or an integer. The floating point number representation uses two registers. The first register stores the number without the binary point. The second register stores a number that indicates the position of the binary point in the first register. We shall now discuss representation of data in the fixed point number representation and floating point number representation. Fixed Point Number Representation: The integer binary signed number is represented as follows

For a positive integer binary number, the sign bit is 0 and the magnitude is a positive binary number. For a negative integer binary number, the sign bit is 1. The magnitude is represented in any one of the three wayso Signed Magnitude representation - The magnitude is the positive binary number itself. 17 Prepared By: Deependra Singh

Basic Electrical & Electronics Engineering


o o

Signed 1s complement representation - The magnitude is the 1s complement of the positive binary number. Signed 2s complement representation - The magnitude is the 2s complement of the positive binary number.

Table 4 shows the representation of the signed number 18.

Signed magnitude and signed 1s complement representation are seldom used in computer arithmetic. Lets now perform arithmetic operations on the signed binary numbers. We use the signed 2s complement representation to represent the negative numbers.

Addition of signed binary numbers The addition of any two signed binary numbers is performed as follows o Represent the positive number in binary form.(For e.g., +5 is 0000 0101 and +10 is 0000 1010) o Represent the negative number in 2s complement form. (For e.g., -5 is 1111 1011 and -10 is 1111 0110) o Add the bits of the two signed binary numbers. o Ignore any carry out from the sign bit position. Please note that the negative output is automatically in the 2s complement form. We get the

decimal equivalent of the negative output number, by finding its 2s complement, and attaching a negative sign to the obtained result. Lets understand the addition of two signed binary numbers with the help of some examples.

Example 1: Add +5 and +10.We represent +5 in binary form, i.e., 0000 0101. We represent +10 in binary form, i.e., 0000 1010. Add the two numbers. The result is 0000 1111 i.e. +15.

18

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering

Example 2. Add -5 and +10. We represent -5 in 2s complement form, i.e., 1111 1011. We represent +10 in binary form, i.e., 0000 1010. Add the two numbers. The result is 0000 0101 i.e. +5.

Example 3: Add +5 and -10. We represent +5 in binary form, i.e., 0000 0101. We represent -10 in 2s complement form, i.e., 1111 0110. Add the two numbers. The result is 11111011. The result is in 2s complement form.

To find the decimal equivalent of the result 1111 1011 Find the 2s complement of 1111 1011, i.e., 0000 0100 + 1 = 0000 0101. This is binary equivalent of +5. Attaching a negative sign to the obtained result gives us -5.

Example 4: Add -5 and -10. We represent -5 in 2s complement form, i.e., 1111 1011. We represent -10 in 2s complement form, i.e., 1111 0110. Add the two numbers. The result is 1111 0001. The result is in 2s complement form.

19

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering

To find the decimal equivalent of the result 1111 0001- Find the 2s complement of 1111 0001, i.e., 0000 1110 + 1 = 0000 1111. This is binary equivalent of +15. Attaching a negative sign to the obtained result gives us -15. Subtraction of signed binary numbers The subtraction of signed binary numbers is changed to the addition of two signed numbers. For this, the sign of the second number is changed before performing the addition operation. (-A) (+B) = (-A) + (-B) (+B in subtraction is changed to B in addition) (+A) (+B) = (+A) + (-B) (+B in subtraction is changed to B in addition) (-A) (-B) = (-A) + (+B) (-B in subtraction is changed to +B in addition) (+A) (-B) = (+A) + (+B) (-B in subtraction is changed to +B in addition) We see that the subtraction of signed binary numbers is performed using the addition operation. The hardware logic for the fixed point number representation is simple, when we use 2s complement for addition and subtraction of the signed binary numbers. Floating Point Number Representation: The floating point representation of a number has two parts mantissa and exponent. The mantissa is a signed fixed point number. The exponent shows the position of the binary point in the mantissa. For example, the binary number +11001.11 with an 8-bit mantissa and 6-bit exponent is represented as follows Mantissa is 01100111. The left most 0 indicates that the number is positive. Exponent is 000101. This is the binary equivalent of decimal number +5. The floating point number is Mantissa x 2exponent i.e. + (.1100111) x 2+5.

The arithmetic operation with the floating point numbers is complicated, and uses complex hardware as compared to the fixed point representation. However, floating point calculations are required in scientific calculations, so, computers have a built-in hardware for performing floating point arithmetic operations.

20

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering DEMORGANS THEOREM


DeMorgan's Theorems: a. A*B = A + B b. (A + B) = A* B Note: * = AND operation

Proof of DeMorgan's Theorem (a): For any theorem X=Y, if we can show that X Y = 0, and that X + Y = 1, then by the complement postulates, A A = 0 and A + A = 1, X = Y. By the uniqueness of the complement, X = Y. Thus the proof consists of showing that (A*B)*( A + B) = 0; and also that (A*B) + ( A + B) = 1. Prove: (A*B)*( A + B) = 0 (A*B)*( A + B) = (A*B)*A + (A*B)*B) = (A*A)*B + A*(B*B) = 0*B + A*0 =0+0 =0 (A*B)*( A + B) = 0 Prove: (A*B) + ( A + B) = 1 by distributivity B*C + A = (B + A)*(C + A) (A*B) + ( A + B) = (A + A + B))*(B + B + A) by associativity postulate = (1 + B)*(1 + A) by complement postulate = 1*1 by nullity theorem =1 by identity theorem (A*B) + ( A + B) = 1 Q.E.D. (A*B) + ( A + B) = (A + A + B))*(B + A + B) Since (A*B)*( A + B) = 0, and (A*B) + ( A + B) =1, A*B is the complement of A + B, meaning that A*B=(A + B)'; Thus, A*B= (A + B)''. A'' = A. (A + B)'' = A + B. (note that ' = complement or NOT)

by distributive postulate by associativity postulate by complement postulate by nullity theorem by identity theorem Q.E.D.

The involution theorem states that Thus by the involution theorem, This proves DeMorgan's Theorem (a).

DeMorgan's Theorem (b) may be proven in a similar manner.

21

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering AND, OR, NOT, NOR, NAND, EX-NOR, EX-OR GATES AND THEIR REPRESENTATION & TRUTH TABLE
Boolean functions may be practically implemented by using electronic gates. The following points are important to understand. Electronic gates require a power supply. Gate INPUTS are driven by voltages having two nominal values, e.g. 0V and 5V representing logic 0 and logic 1 respectively. The OUTPUT of a gate provides two nominal values of voltage only, e.g. 0V and 5V representing logic 0 and logic 1 respectively. In general, there is only one output to a logic gate except in some special cases. There is always a time delay between an input being applied and the output responding.

Truth Tables: Truth tables are used to help show the function of a logic gate. If you are unsure about truth tables and need guidance on how go about drawing them for individual gates or logic circuits then use the truth table section link. Logic gates: Digital systems are said to be constructed by using logic gates. These gates are the AND, OR, NOT, NAND, NOR, EXOR and EXNOR gates. The basic operations are described below with the aid of truth tables. AND gate

A 0 0 1 1

2 INPUT AND GATE B A.B 0 0 1 0 0 0 1 1

The AND gate is an electronic circuit that gives a high output (1) only if all its inputs are high. A dot (.) is used to show the AND operation i.e. A.B. Bear in mind that this dot is sometimes omitted i.e. AB OR gate

A 0 0 1 1

2 INPUT OR GATE B A+B 0 0 1 1 0 1 1 1 22


Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


The OR gate is an electronic circuit that gives a high output (1) if one or more of its inputs are high. A plus (+) is used to show the OR operation. NOT gate

1 INPUT NOT GATE A A 0 1 1 0 The NOT gate is an electronic circuit that produces an inverted version of the input at its output. It is also known as an inverter. If the input variable is A, then the inverted output is known as NOT A. This is also shown as A', or A with a bar over the top, as shown at the outputs. The diagrams below show two ways that the NAND logic gate can be configured to produce a NOT gate. It can also be done using NOR logic gates also in the same way.

NAND gate

2 INPUT NAND GATE A B A B 0 0 1 0 1 1 1 0 1 1 1 0 This is a NOT-AND gate which is equal to an AND gate followed by a NOT gate. The outputs of all NAND gates are high if any of the inputs are low. The symbol is an AND gate with a small circle on the output. The small circle represents inversion. NOR gate

2 INPUT NAND GATE A B A B 0 0 1 0 1 0 1 0 0 1 1 0 23


Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


This is a NOT-OR gate which is equal to an OR gate followed by a NOT gate. The outputs of all NOR gates are low if any of the inputs are high. The symbol is an OR gate with a small circle on the output. The small circle represents inversion. XOR gate

2 INPUT XOR GATE A B A B 0 0 0 0 1 1 1 0 1 1 1 0 The 'Exclusive-OR' gate is a circuit which will give a high output if either, but not both, of its two inputs are high. An encircled plus sign ( ) is used to show the EOR operation. EX-NOR gate

2 INPUT XNOR GATE A B A B 0 0 1 0 1 0 1 0 0 1 1 1 The 'Exclusive-NOR' gate circuit does the opposite to the XOR gate. It will give a low output if either, but not both, of its two inputs are high. The symbol is an XOR gate with a small circle on the output. The small circle represents inversion.

The NAND and NOR gates are called universal functions since with either one the AND and OR functions and NOT can be generated.

24

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


Table 1: Logic gate symbols

Table 2 is a summary truth table of the input/output combinations for the NOT gate together with all possible input/output combinations for the other gate functions. Also note that a truth table with 'n' inputs has 2n rows. You can compare the outputs of different gates. Table 2: Logic gates representation using the Truth table

25

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering HALF AND FULL ADDER CIRCUITS,
HALF ADDER: As a first example of useful combinational logic, let's build a device that can add two binary digits together. We can quickly calculate what the answers should be: 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 102

So we well need two inputs (a and b) and two outputs. The low order output will be called S because it represents the sum, and the high order output will be called C because it represents the carry out. The truth table is A 0 0 1 1 B 0 1 0 1 S 0 1 1 0 C 0 0 0 1

Simplifying Boolean equations will produce the same circuit shown below, but start by looking at the results. The S column is XOR gate, while the C column is the AND gate. This device is called a half-adder.

Fig.1: Half Adder

FULL ADDER: The full adder becomes necessary when a carry input must be added to the two binary digits to obtain the correct sum. A half adder has no input for carries from previous circuits. One method of constructing a full adder is to use two half adders and an OR gate as shown in figure below. The inputs A and B are applied to gates 1 and 2. These make up one half-adder. The sum output of this half-adder and the carry from a previous circuit become the inputs to the second half-adder. The carry from each half adder is applied to gate 5 to produce the carry-out for the circuit.

26

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering

Fig. 2: Full Adder

Truth Table A 0 0 1 1 0 0 1 1 B 0 1 0 1 0 1 0 1 CARRY IN 0 0 0 0 1 1 1 1 SUM OUT 0 1 1 0 1 0 0 1 CARRY OUT 0 0 0 1 0 1 1 1

Now lets add a series of numbers and see how the circuit operates. First, lets add 1 and 0. When either A or B is HIGH, gate 1 has an output. This output is applied to gates 3 and 4. Since the carry-in is 0, only gate 3 will produce an output. The sum of 12 and 0 is 12. Now lets add 12 and 12. If A and B are both HIGH, the output of gate 1 is LOW. When the carry-in is 0 (LOW), the output of gate 3 is LOW. Gate 2 produces an output that is applied to gate 5, which produces the carry-out. The sum of 12 and 12 is 102, just as it was for the half adder. When A and B are both LOW and the carry-in is 1, only gate 3 has an output and produces a sum of 12 with no carry-out. Now, lets add A or B and a carry-in. For example, lets assume that A is HIGH and B is LOW. With these conditions, gate 1 will have an output. This output and the carry-in applied to gates 3 and 4 will produce a sum out of 0 and a carry of 1. This carry from gate 4 will cause gate 5 to produce a carry-out. The sum of A and a carry (12 plus 12) is 102.

27

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering FLIP-FLOP


The basic memory elements used in sequential circuits are flip flops. Flip flops are also known as latches and toggle and are used in various devices. Flip flops are interconnected to form sequential logic circuits, such as storage circuit, counter stages, shift registers and in various other computer applications. A flip flop has only two stable states, logic 0 and logic 1.

RS FLIP-FLOP One of the simplest storage device is the RESET-SET (RS) flip flop (FF) and can be formed by using 2 NAND or NOR gates, and it is the simplest sequential circuit element. The output of FF is a LOW (0) or a HIGH (l) and it remains the same. If we wish to change it we have to drive the circuit by an input called trigger. Until the trigger arrives, the output voltage remains LOW or HIGH. An elementary circuit for this is shown in fig.3

Fig.3: Circuit for RS flip-flop

From this figure we observe if a high voltage is applied to S (Set) input then transistor Q1 saturates making Q2 cutoff. Once Q1 is saturated and Q2 cutoff the trigger at the input S can be removed. Similarly we may apply a high voltage to the R (reset) Input which results in saturating Q2 and makes Q1 into cut-off. When a high voltage is applied to the S input it called setting the flip-f1op and gives a binary output of a 1. The applying high voltage to the R input is called resetting the flip flop and gives a binary output of a 0. Logic symbol for a RS flip-flop is shown in figure 4. The realization of RS flipflop using NOR gates or IC equivalent is shown in Fig. 4. In Fig. 5 RS flip-flop is realized using NAND gates. In Fig. 7 the RS flip-flop is redrawn using the negative OR gate equivalent in place of NAND gates.

28

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering

Fig. 4: Logic Symbol for RS flip-flop

Fig. 5: RS Flip-Flop using NOR gates

Fig. 6

Fig. 7: RS flip-flop using Negative-OR gate equivalents in place of NAND gates

In RS flip-flop the output of each NOR gates are fed back to one of the inputs on the other NOR gate. The RS inputs allow us to reset and set the output. The input output combinations are shown in Table below. The first condition is R =0 and S = 0 i.e. RS = 00 In this case the output remains fixed at a state they are in i.e. the 0 will have the last value. We also say that output is latched or stuck to its last state. Because of this some times flip-flops are also called latches. Second condition can be R is low and S is high. RS = 01 This will happen when we have applied trigger to the S input. This will set Q and Q = 0. An action which makes Q a 1 is called set action. We also say output is set. The third input condition can be R is high and S is low i.e. RS = 10 This will happen when a trigger has been applied to R input. This is just opposite to second case. The circuit outputs will be Q = 0 and Q = 1. An action which makes Q a 0 or causes Q =1 is known as reset action and the input which causes it is called reset or R input. The fourth input, condition can be both Rand S are high i.e. RS =11 This will happen only when a trigger has been applied to R and S at the same time and will amount to trying to make the output Q simultaneously a 1 and a 0 which is not possible. Hence this condition being contradictory is forbidden. Table 1 summarizes above four conditions. Grounding S lead resets the FF to a 1 and grounding R lead resets it to a 0. S and R lines cannot be activated simultaneously as logic rules do not permit it. 29
Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


Table: Truth Table for RS FLIP-FLOP

R 0 0 1 1 JK Flip-flop

S 0 1 0 1

Output Last Value or Latch Set Reset Forbidden or Invalid

In RS flip-flop when both the inputs are 1 (R = S =1) we could not get the proper output as it was indeterminate and was not allowed or forbidden. JK flip- flop is the improved version of RS flipflop so that when both inputs are 1 then also the outputs Q and Q are complement of each other. The JK flip-flop has two inputs J and K. The J input of this flip-flop corresponds to S input and K input corresponds to R input of the RS flip-flop. A circuit for a clocked JK flip-flops is shown in Fig. 8 along with its logical symbol Fig 9. This flip-flop is very useful in counter circuits. From Fig 9 showing a basic circuit for JK flip-flop we observe that it has two control signals J and K and the function of flip-flop is determined by signals when a clock pulse arrives as it is positive edge triggered.

Fig. 8: Circuit for positive triggered JK flip-flop

Fig. 9: JK flip-flop Symbol

When J and K both are low both AND gates are disabled and there is no effect of the clock pulse and the output remains what it was before the arrival of the pulse. When J is LOW (0) and K is a HIGH (1) the upper gate is disabled and the flip-flop can not be set and we can only set it if it is not already set and the output Q will be 0. In this case if Q is HIGH as soon as a pulse arrive the lower gate will pass a reset trigger forcing Q to become 0, i.e., when J = 0, K = 1 it will reset the counter if already not reset on the arrival of a clock pulse. Next possibility is when J is HIGH (1) and K is low (0) the lower gate will be disabled and the flip-flop cannot be reset. However we can set the flip-flop as follows. If Q is LOW i.e., it is reset already Q will be a 1 or HIGH and on the arrival of a clock pulse the upper gate will pass a set trigger and will force the output Q to be a 1(if it is already not a 1). Thus J = 1, and K = 0 will set the flip-flop (make Q = 1). These three situations are similar to RS flip-flop.

30

Prepared By:

Deependra Singh

Basic Electrical & Electronics Engineering


However when J = 1 and K = 1 (a forbidden for RS flip-flop) i.e., J and K both are HIGH we can set or reset the flip-flop depending upon its position at present, if Q is a LOW, the upper gate passes a set trigger on the arrival of the next clock pulse and Q will be changed from Q = 0 to Q = 1. If Q is HIGH, the lower gate passes a reset signal on the arrival of next positive clock edge which will force Q from 1 to become a 0. In any case when J and K both are high whatever may be the output it will change to its complement i.e., if it is 0 it will become a 1 and if it is a 1 it will become a 0 i.e., the flip-flop will toggle on the occurrence of the next positive clock edge. These possibilities are shown in Table 2.
Table: Truth Table for JK Flip-Flop

J 0 0 1 1

K 0 1 0 1

Output or Response Q Last State 0 1 Complement of Last State

31

Prepared By:

Deependra Singh

Anda mungkin juga menyukai