You are on page 1of 94

EEN 417 1A

LOGIC CIRCUIT AND SWITCHING THEORY WEEK 1

JUNE 2012

PREPARED BY: ENGR. DARWIN D. ALPIS

Logic Circuit and Switching Theory


COURSE OUTLINE:

Number System Other Number System and Number Conversion System Boolean Algebra and Logic Gates Minimization of Boolean Functions Combinational Circuits Sequential Circuits Algorithmic State Machine (ASM) Asynchronous Sequential Logic Design of Digital Systems

Logic Circuit and Switching Theory Introduction to Number System Number System is define by their parameters. An understandings of these parameters and their relevance to number system is a fundamental to the understanding of how various systems operate. The following are the different characteristics that define a number system: 1. Number of independent digits used in the number system. 2. Place values of the different digits constituting the number. 3. Maximum numbers that can be written with the given number of digits.

Logic Circuit and Switching Theory Radix or Base is the number of the unique digits, including zero, that a positional numeral system uses to represent numbers. Ex. Decimal has a radix of 10 Binary has a radix of 2 Octal has a radix of 8 Hexadecimal has a radix of 16 The place value of different digits in the integer part of the number are given by r0, r1, r2, r3 and so on where: r is the radix of the number system.

Logic Circuit and Switching Theory The maximum numbers that can be written with n digits in a given number system are equal to rn. Decimal Number System The decimal number system is a radix 10 number system and therefore has 10 different digits or symbols. These are 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. All higher numbers after 9 are represented in terms of these 10 digits only. The place values of different digits in a mixed decimal number, starting form the decimal point are 100, 101, 102 and so on (for the integer part) and 10-1, 10-2, 10-3 and so on (for the fractional part).

Logic Circuit and Switching Theory The value or magnitude of a given decimal number can be expressed as the sum of the various digits multiplied by their place values or weights.

Ex. 3586.265 is equal to (as an integer)


3586 = 6 x 100 + 8 x 101 + 5 x 102 + 3 x 103 = 6 + 80 + 500 + 3000 (as a decimal) 0.265 = 2 x 10-1 + 6 x 10-2 + 5 x 10-3

Logic Circuit and Switching Theory Binary Number System The binary number system is a radix 2 number system with 0 and 1 as the two independent digits. All large binary numbers are represented in terms of 0 and 1. Octal Number System The octal number system has a radix of 8 and therefore has eight distinct digits. All higher-order numbers are expressed as a combination of these on the same pattern as the one followed in the case of the binary and decimal number. The independent digits are 0, 1, 2, 3, 4, 5, 6 and 7. The next 10 numbers that follow 7 would be 10, 11, 12, 13, 14, 15, 16, 17, 20 and 21.

Logic Circuit and Switching Theory Hexadecimal Number System The hexadecimal number system is a radix 16 number system and its 16 basic digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F. The place values or weighs of different digits in a mixed hexadecimal number are 160, 161, 162 and so on (for the integer part) and 16-1, 16-2, 16-3 and so on (for the fractional part). The decimal equivalent of A, B, C, D, E and F are 10, 11, 12, 13, 14 and 15 respectively.

Logic Circuit and Switching Theory Number System Some Common Terms Bit is an abbreviation of the term binary digit and is the smallest unit of information. It is either 0 or 1. Byte is a string of eight bits. The byte is the basic unit of data operated upon as a single unit in computers. The 1s Complement The 1s complement of a binary number is obtained by complementing all its bits, by replacing 0s with 1s and 1s with 0s.

Ex. Obtain the 1s complement of (10010110)2. Answer: (01101001)2

Logic Circuit and Switching Theory The 2s Complement The 2s complement of a binary number is obtained by adding 1 to its 1s complement. Ex. Obtain the 2s complement of (10010110)2. First obtain its 1s complement (01101001)2 Second, add 1s to its 1s complement (01101010)2

Logic Circuit and Switching Theory The 9s Complement The 9s complement of a given decimal number is obtained by subtracting each digit from 9. Ex. Obtain the 9s complement of (2496)10. Solution: (9999)10 - (2496)10 (7503)10

Logic Circuit and Switching Theory The 10s Complement The 10s complement of a given decimal number is obtained by adding 1 to the 9s complement. Ex. Obtain the 10s complement of (2496)10. Solution: Obtain the 9s complement first (9999)10 - (2496)10 (7503)10 Add 1 to the 9s complement. (7503)10 + (1)10 (7504)10

Logic Circuit and Switching Theory The 7s Complement The 7s complement of a given octal number is obtained by subtracting each octal digit from 7. Ex. Obtain the 7s complement of (654)8. Solution: To obtain the 7s complement (777)8 - (654)8 (123)8

Logic Circuit and Switching Theory The 8s Complement The 8s complement is obtained by adding 1 to the 7s complement. Ex. Obtain the 8s complement of (723)8. Solution: First obtain the 7s complement (777)8 - (723)8 (054)8 Add 1 to the 7s complement (054)8 + (1)8 (055)8

Logic Circuit and Switching Theory The 15s Complement The 15s complement of a given octal number is obtained by subtracting each hex digit from 15. Ex. Obtain the 15s complement of (DAE)8. Solution: To obtain the 15s complement (FFF)16 - (DAE)16 (351)16

Logic Circuit and Switching Theory The 16s Complement The 16s complement is obtained by adding 1 to the 15s complement. Ex. Obtain the 16s complement of (9CA)8. Solution: First obtain the 15s complement (FFF)16 - (9CA)16 (746)16 Add 1 to the 15s complement (746)16 + (1)16 (747)16

Logic Circuit and Switching Theory

Logic Circuit and Switching Theory

Logic Circuit and Switching Theory Conversion of Decimal Numbers into any Radix Number In converting decimal numbers into any radix number, successive division is made on its integer number and successive multiplication is required on its fractional number. 1. Decimal to Binary Let use say, we need to convert (34.55)10 into its equivalent binary number.

Logic Circuit and Switching Theory For integer part

Logic Circuit and Switching Theory For fractional part

Therefore, (34.56)10 = (100010.10001100)2

Logic Circuit and Switching Theory Radix Conversion Algorithms

Logic Circuit and Switching Theory Flowchart for Successive Division Method

Logic Circuit and Switching Theory Radix Conversion Algorithms

Logic Circuit and Switching Theory Flowchart for Successive Multiplication Method

Logic Circuit and Switching Theory Complements In digital computers, in order to simplify the subtraction operation and for logical manipulation complements are used. There are two types of complements for each radix system: The radix complement and the diminished radix complement. The first is referred to as the rs complement and the second as the (r-1)s complement. In binary system we substitute base value 2 in place of r to refer to complements as 2s complement and 1s complement. In decimal number system, we substitute base value 10 in place of r to refer complements as 10s complement and 9s complement.

Logic Circuit and Switching Theory 1s Complement Subtraction Subtraction of binary numbers can be accomplished by the direct method, which allows to perform subtraction using only addition. For subtraction of two numbers we have two cases. Case 1: Subtraction of smaller number from larger number

Method: 1. Determine the 1s complement of the smaller number. 2. Add the 1s complement of the smaller number to the larger number. 3. Remove the carry and add it to the result.

Logic Circuit and Switching Theory Example: Subtract 1010112 from 1110012 using 1s complement method.

Solution:
Step 1: Get the 1s complement of the smaller number.

Step 2: Add the 1s complement to the larger number.

Step 3: Remove the carry and add it to the result.

Logic Circuit and Switching Theory 1s Complement Subtraction Case 2: Subtraction of larger number from smaller number.

Method: 1. Determine the 1s complement of the larger number. 2. Add the 1s complement to the smaller number. 3. Answer is in 1s complement form. To get the true answer, get the 1s complement and assign a negative sign to the answer.

Logic Circuit and Switching Theory Example: Subtract 1111102 from 1010112 using 1s complement method.

Solution:
Step 1: Get the 1s complement of the larger number.

Step 2: Add the 1s complement to the smaller number.

Step 3: Get the 1s complement of the answer and affix a negative sign.

Logic Circuit and Switching Theory Advantage of 1s Complement 1. The 1s complement subtraction can be accomplished with a binary adder. Therefore, it is useful in arithmetic logic circuits. 2. The 1s complement can be easily obtained by inverting each bit in the number.

Logic Circuit and Switching Theory Exercises: 1. A. B. C. D. Perform the following operations. 255.410 radix of 2 348 radix of 16 1100.1102 radix of 10 ACE radix of 8

2. Perform the following using 1s complement subtraction A. 11001102 100010002 B. 1010102 1100112 C. ADEH AAAH D. 5768 - 6548

Logic Circuit and Switching Theory 2s Complement Subtraction Like 1s complement subtraction, 2s complement subtraction can also be obtained by addition. The two methods is as follows: Case 1: Subtraction of smaller number from larger number Method: 1. Determine the 2s complement of the smaller number. 2. Add the 2s complement of the smaller number to the larger number. 3. Discard the carry.

Logic Circuit and Switching Theory Example: Subtract 1010112 from 1110012 using 2s complement method.

Solution:
Step 1: Get the 2s complement of the smaller number.

Step 2: Add the 2s complement to the larger number.

Step 3: Discard the carry.

Logic Circuit and Switching Theory 2s Complement Subtraction Case 2: Subtraction of larger number from smaller number.

Method: 1. Determine the 2s complement of the larger number. 2. Add the 2s complement to the smaller number. 3. Answer is in 2s complement form. To get the true answer, get the 2s complement and assign a negative sign to the answer.

Logic Circuit and Switching Theory Example: Subtract 1111102 from 1010112 using 2s complement method. Solution: Step 1: Get the 2s complement of the larger number.

Step 2: Add the 2s complement to the smaller number.

Logic Circuit and Switching Theory Step 3: Get the 2s complement of the answer and affix a negative sign.

Logic Circuit and Switching Theory Signed Binary Numbers In practice, we use plus sign to represent positive numbers and minus sign to represent negative numbers. However, because of hardware limitations, in computers, both positive and negative numbers are represented with only binary digits.

If MSB is 1, the number is negative. If MSB is 0, the number is positive. +6 = 0000 0110 -14 = 1000 1110 +24 = 0001 1000 -64 = 1100 0000

Logic Circuit and Switching Theory In case of unsigned 8-bit binary numbers the decimal range is 0 to 255. For signed 8-bit magnitude binary numbers the largest magnitude is reduced from 255 to 127 because we need to represent both positive and negative numbers. Maximum positive number Maximum negative number 0111 1111 = +127 1111 1111 = -128

Three Ways of Representing Negative Signed Numbers 1. Signed-Magnitude Representation 2. Signed-1s Complement Representation 3. Signed-2s Complement Representation

Logic Circuit and Switching Theory Example: Represent -6 using the three negative signed number ways. Answer: Signed-Magnitude Representation = 1000 0110 Signed-1s Complement Representation = 1111 1001 Signed-2s Complement Representation = 1111 1010

Logic Circuit and Switching Theory Problem: Assuming 8-bit word length, express the following decimal numbers in: (i) Signed magnitude form (ii) 1s complement form (iii) 2s complement form

Logic Circuit and Switching Theory

EEN 417 1A
LOGIC CIRCUIT AND SWITCHING THEORY WEEK 2

JUNE 2013

PREPARED BY: ENGR. DARWIN D. ALPIS

Logic Circuit and Switching Theory The sign-magnitude representation requires separate handling for sign and magnitude during arithmetic operations and hence it is suitable in computer arithmetic. The 1s complement imposes some difficulties and is seldom used for arithmetic operations. It is used as logical operation since the change of 1 to 0 or 0 to 1 is equivalent to a logical complement operation. The signed-2s complement system is commonly used in computer arithmetic.

Binary Arithmetic
Computer circuits do not process decimal numbers; they process binary numbers. Binary addition is the key to binary subtraction, multiplication, and division.

Logic Circuit and Switching Theory

Logic Circuit and Switching Theory Binary Code The digital data is represented, stored and transmitted as groups of binary digit (bits). The group of bits, also known as binary code, represent both numbers and letters of alphabet as well as many special characters and control functions. They are classified as numeric or alphanumeric. Numeric codes are used to represent numbers. On the other hand, alphanumeric codes are used to represent characters: alphabetic letters and numerals. In these codes, a numeral is treated simply as another symbol rather than as a number or numeric value. Classification of Binary Codes The different binary codes can be classified as 1. Weighted codes 2. Non-weighted codes 3. Reflective codes 4. Sequential codes 5. Alphanumeric codes 6. Error Detecting and Correcting Codes

Logic Circuit and Switching Theory Weighted Codes In weighted codes, each digit position of the number represents a specific weight. For example, in decimal code, if number is 378 then weight of 3 is 100, weight of 7 is 10 and weight of 8 is 1. In weighted binary codes each digit has a weight of 8, 4, 2, and 1. The codes 8421, 2421 and 5211 are all weighted codes. Non-weighted Codes Non-weighted codes are not assigned with any weight to each digit position, i.e., each digit position within the number is not assigned fixed value. Excess 3 and gray codes are the nonweighted codes.

Logic Circuit and Switching Theory Reflective Codes A code is said to be reflective when the code for 9 is the complement for the code for 0, 8, for 1, 7 for 2, 6 for 3, and 5 for 4. Note that the 2421, 5211 and excess-3 codes are reflective, whereas the 8421 code is not. Reflectivity is desirable in a code when the nines complement must be found, such as in nines complement subtraction. Sequential Codes In sequential codes each succeeding code is one binary number greater than its preceding code. This greatly aids mathematical manipulation of data. The 8421, and excess-3 are sequential, whereas 2421 and 5211 codes are not.

Logic Circuit and Switching Theory Alphanumeric Codes The code which is consists of both numbers and alphabetic characters are called alphanumeric codes. Most of these codes, however, also represent symbols and various instructions necessary for conveying intelligible information. The most commonly used alphanumeric codes are: ASCII (American Standard Code for Information Interchange), EBCDIC (Extended Binary Coded Decimal Interchange Code) and Hollerith code. Error Detecting and Correcting Codes When the digital information in the binary form is transmitted from one circuit or system an error may occur. This means a signal corresponding to 0 may change to 1 or viceversa due to presence of noise. To maintain the data integrity between transmitter and receiver, extra bit or more than one bit added in the data.

Logic Circuit and Switching Theory These extra bits allow the detection and some times correction of error in the data. The data along with the extra bit/bits forms the code. Codes which allow only error detection are called error detecting codes and codes which allow error detection and correction are called error detecting and correcting codes.

Logic Circuit and Switching Theory BCD (8-4-2-1) BCD is an abbreviation for binary-coded-decimal. BCD is a numeric code in each digit of a decimal number is represented by a separate groups of bits. The most common BCD code is 8-42-1 BCD, in which each decimal digit is represented by a 4-bit binary number. It is called 8-4-2-1 BCD because the weights associated with 4 bits are 8-4-2-1 from left to right. This means that, bit 3 has weight 8, bit 2 has weight 4, bit 1 has weight 2, and bit 0 has weight of 1.

Logic Circuit and Switching Theory BCD (8-4-2-1)

Logic Circuit and Switching Theory BCD ADDITION: BCD addition is done by using the three methods below. Sum is equals 9 or less with carry 0

Sum is greater than 9 with 0 carry

Logic Circuit and Switching Theory BCD ADDITION: Sum is equals 9 or less with carry 1

Logic Circuit and Switching Theory BCD Addition BCD addition is as follows: 1. Add two BCD numbers using ordinary binary addition. 2. If four-bit BCD sum is equal to or less than 9, no correction is needed. The sum is in proper BCD form. 3. If four-bit sum is greater than 9 or if a carry is generated from the four-bit sum, the sum is invalid. 4. To correct the invalid sum, add 01102 to the four-bit sum. If a carry results from this addition, add it to the next higher-order BCD digit.

Logic Circuit and Switching Theory BCD SUBTRACTION: Addition of signed BCD numbers can be performed by using 9s or 10s complement methods. A negative BCD can be expressed by taking the 9s or 10s complement. Subtraction Using 9s Complement: In 9s complement subtraction when 9s complement of smaller number is added to the larger number carry is generated. It is necessary to add this carry to the result. (this is called an end-around carry). When larger number is subtracted from smaller one, there is no carry, and the result is in 9s complement form and negative.

Logic Circuit and Switching Theory BCD SUBTRACTION: Subtraction Using 9s Complement can be summarized as follows: 1. Find the 9s complement of a negative number. 2. Add two numbers using BCD. 3. If carry is generated add carry to the result otherwise find the 9s complement of the result.

Logic Circuit and Switching Theory BCD SUBTRACTION:

Logic Circuit and Switching Theory BCD SUBTRACTION:

Logic Circuit and Switching Theory BCD SUBTRACTION: Subtraction Using 10s Complement: The 10s complement of a decimal number is equal to the 9s complement plus 1. The 10s complement can be used to perform subtraction by adding the minuend to the 10s complement of the subtrahend and dropping the carry.

Logic Circuit and Switching Theory BCD SUBTRACTION:

Logic Circuit and Switching Theory BCD SUBTRACTION:

Logic Circuit and Switching Theory BCD SUBTRACTION:

Logic Circuit and Switching Theory Problem: Perform each of the following decimal additions in 8-4-2-1 BCD.

Logic Circuit and Switching Theory Problem: Perform each of the following decimal subtractions in 8-4-2-1 BCD using 9s complement.

Logic Circuit and Switching Theory Problem: Perform each of the following decimal subtractions in 8-4-2-1 BCD using 10s complement.

Logic Circuit and Switching Theory BCD (2-4-2-1) The 2-4-2-1 BCD is another self-complementing code whose 4-bits code group are weighted. The weights are 2-4-2-1, meaning that the bit 1 and 3 are both weighted 2. Since two positions have the same weight, there are two possible bit patterns that could be used to represent some decimal digits, but only one of those patterns is actually assigned.

Logic Circuit and Switching Theory OTHER 4-BIT CODES

Logic Circuit and Switching Theory Problem: Represent the following decimal numbers in the following 4-bit code. (i). 3-3-2-1 Code (ii). 4-2-2-1 Code (iii). 5-2-1-1 Code (iv). 5-3-1-1 Code (v). 5-4-2-1 Code (vi). 6-3-1-1 Code (vii). 7-4-2-1 Code

(a) 34

(b) 56

(c) 78

Logic Circuit and Switching Theory EXCESS-3 CODE Excess-3 code is a modified form of a BCD number. The Excess-3 code can be derived by adding 3 to each coded number.

Logic Circuit and Switching Theory Excess 3 Addition: 1. Add two excess-3 numbers. 2. If carry is 1, add 3 to the sum of the two digits. If carry is 0, subtract 3 to the sum of the two digits. Example: Determine the excess-3 sum of the decimal numbers 8 and 6. Solution:

Logic Circuit and Switching Theory Excess 3 Addition: Example: Determine the excess-3 sum of the decimal numbers 3 and 4. Solution:

Logic Circuit and Switching Theory Problem: Perform each of the following decimal addition in excess-3 code.

Logic Circuit and Switching Theory Excess 3 Subtraction: 1. Complement the subtrahend. 2. Add complemented subtrahend to minuend. 3. If Carry = 1, Result is positive. Add 3 and end-around carry. If Carry = 0, Result is negative. Subtract 3. Example: Perform the following operations using excess-3 code. Solution:

Logic Circuit and Switching Theory Excess 3 Subtraction: Solution:

Logic Circuit and Switching Theory Excess 3 Subtraction: Solution:

Logic Circuit and Switching Theory Problem: Perform each of the following decimal subtraction in excess-3 code.

Logic Circuit and Switching Theory GRAY CODE Gray code is a special case of unit-distance code. In unitdistance code, bit patterns for two consecutive number differs in only one bit position.

Logic Circuit and Switching Theory GRAY CODE As shown in the Table for gray code any two adjacent code groups differ only in one bit. The gray code is also called reflected code. Notice that the two least significant bits for 410 through 710 are the mirror images of those 00 through 310. Similarly, the three least significant bits for 810 through 1510 are the mirror images of those for 010 through 710. In general, the n least significant bits for 2n through 2n+1 1 are the mirror images of those for 0 through 2n 1. Another property of gray code is that the gray-coded number corresponding to the decimal 2n 1, for any n, differs from gray coded 0 (0000) in one bit position only. For example, for n = 2, 3 and 4, we see that 22 1 = 310 = 0010 in gray 23 1 = 710 = 0100 in gray and 24 1 = 1510 = 1000 in gray

Logic Circuit and Switching Theory Advantages of GRAY CODE For a 3-bit binary code, it indicates the position of a rotating disk. Brushes are used to indicate red and white portions on the disk. When the brushes are on the red portion, they output a 1. When the brush are on the white portion, they output 0.

Logic Circuit and Switching Theory GRAY-to-Binary Conversion The gray to binary code conversion can be achieved using the following steps. 1. The most significant bit of the binary number is the same as the most significant bit of the gray code number. So write it down. 2. To obtain the next binary digit, perform and exclusive-ORoperation between the bit just written down and the next gray code bit. Write down the result. 3. Repeat step 2 until all gray code bits have been exclusiveORed with binary digits. The sequence of bits that have been written down is the binary equivalent of the gray-code number.

Logic Circuit and Switching Theory GRAY-to-Binary Conversion Convert the gray code 1 0 1 0 1 1 into its binary equivalent.

Logic Circuit and Switching Theory Binary-to-Gray Conversion Let us represent binary number as B1 B2 B3 B4 Bn and its equivalent in gray code as G1 G2 G3 G4 Gn. With this representation gray code bits are obtained from the bits as follows:
G1 = B1 G1 = B1 B2 G2 = B 2 B 3 G3 = B 3 B 4 . . Gn = Bn-1 Bn

Logic Circuit and Switching Theory Binary-to-Gray Conversion Convert the binary code 1 0 1 1 1 0 1 1 into its gray code equivalent.

Logic Circuit and Switching Theory Alphanumeric Codes In order to communicate, we need not only numbers, but also letters and other symbols commonly known as non numeric data. Computer manipulates both numbers and symbols. The most programs written by computer users are in the form of characters, i.e. a set of symbols consists of letters, digits, and various special characters, such as +, -, >, <, & and so on. The codes which consists of both numbers and alphabetic characters are called alphanumeric codes. Most of these codes, however, also represent symbols and various instructions necessary for conveying intelligible information. The most commonly used alphanumeric codes are: ASCII (American Standard Code for Information Interchange) and EBCDIC (Extended Binary Coded Decimal Interchange Code).

Logic Circuit and Switching Theory ASCII One standardized alphanumeric code, called the American Standard Code for Information Interchange, is perhaps the most widely used type. It is a seven-bit code in which the decimal digits are represented by the BCD code precede by 011. The letter of the alphabet and other symbols and instructions are represented by other code combinations as shown in the Table 2-4.

Logic Circuit and Switching Theory ASCII CODE

Logic Circuit and Switching Theory ASCII CODE

Logic Circuit and Switching Theory ASCII CODE

Logic Circuit and Switching Theory ASCII CODE

Logic Circuit and Switching Theory ASCII CODE

Logic Circuit and Switching Theory ASCII CODE

Logic Circuit and Switching Theory 1. Example: The following is a message encoded in ASCII code. What is the message? Answer: HELP 2. Example: An operator is typing in a BASIC program at the keyboard of a certain microcomputer. The computer converts each keystroke into its ASCII code and stores the code as a byte in memory. Determine the binary strings that will be entered into memory when the operator types in the following BASIC statement: GOTO 25

Logic Circuit and Switching Theory 3. Example: Encode the following message in ASCII code using the hex representation: COST = $72.

4. Example: The following padded ASCII-coded message is stored in successive memory locations in a computer: 01010011 01010100 01001111 01010000

You might also like