EEN 417 – 1A LOGIC CIRCUIT AND SWITCHING THEORY WEEK 1 JUNE 2012 PREPARED BY: ENGR. DARWIN D. ALPIS
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 1/94
EEN 417 – 1A
LOGIC CIRCUIT AND SWITCHING THEORYWEEK 1
JUNE 2012
PREPARED BY:
ENGR. DARWIN D. ALPIS
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 2/94
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 3/94
Logic Circuit and Switching Theory
Introduction to Number System
Number System is define by their parameters. Anunderstandings of these parameters and their relevance tonumber system is a fundamental to the understanding of howvarious systems operate.
The following are the different characteristics that define anumber 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.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 4/94
Logic Circuit and Switching Theory
Radix or Base
is the number of the unique digits, including zero, that apositional numeral system uses to represent numbers.
Ex. Decimal – has a radix of 10Binary – has a radix of 2Octal – has a radix of 8Hexadecimal – has a radix of 16
The place value of different digits in the integer part ofthe number are given by
r 0
, r 1
, r 2
, r 3
and so on… where: r – is the radix of the number system.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 5/94
Logic Circuit and Switching Theory
The maximum numbers that can be written with n digitsin a given number system are equal to r n .
Decimal Number System
The decimal number system is a radix – 10 numbersystem 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” arerepresented in terms of these 10 digits only.
The place values of different digits in a mixed decimalnumber, starting form the decimal point are 10 0, 10 1, 10 2 and soon (for the integer part) and 10 -1, 10 -2, 10 -3 and so on (for thefractional part).
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 6/94
Logic Circuit and Switching Theory
The value or magnitude of a given decimal number canbe expressed as the sum of the various digits multiplied by theirplace values or weights.
Ex. 3586.265 is equal to (as an integer)
3586 = 6 x 10 0 + 8 x 10 1 + 5 x 10 2 + 3 x 10 3 = 6 + 80 + 500 + 3000
(as a decimal)
0.265 = 2 x 10 -1 + 6 x 10 -2 + 5 x 10 -3
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 7/94
Logic Circuit and Switching Theory
Binary Number System
The binary number system is a radix – 2 number systemwith „0‟ and „1‟ as the two independent digits. All large binarynumbers are represented in terms of „0‟ and „1‟.
Octal Number System
The octal number system has a radix of 8 and thereforehas eight distinct digits. All higher-order numbers are expressedas a combination of these on the same pattern as the onefollowed in the case of the binary and decimal number. Theindependent 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, 20and 21.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 8/94
Logic Circuit and Switching Theory
Hexadecimal Number System
The hexadecimal number system is a radix – 16 numbersystem 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 amixed hexadecimal number are 16 0, 16 1, 16 2 and so on (for theinteger 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.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 9/94
Logic Circuit and Switching Theory
Number System – Some Common Terms
Bit – is an abbreviation of the term „binary digit‟ and is thesmallest unit of information. It is either „0‟ or „1‟.
Byte – is a string of eight bits. The byte is the basic unit of dataoperated upon as a single unit in computers.
The 1‟s Complement
The 1 ‟s complement of a binary number is obtained bycomplementing all its bits, by replacing 0s with 1s and 1s with0s.
Ex. Obtain the 1 ‟s complement of (10010110) 2.Answer: (01101001) 2
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 10/94
Logic Circuit and Switching Theory
The 2‟s Complement
The 2 ‟s complement of a binary number is obtained byadding „1‟ to its 1 ‟s complement.
Ex. Obtain the 2 ‟s complement of (10010110) 2.
First obtain its 1 ‟s complement(01101001) 2
Second, add 1 ‟s to its 1 ‟s complement(01101010) 2
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 11/94
Logic Circuit and Switching Theory
The 9‟s Complement
The 9 ‟s complement of a given decimal number isobtained by subtracting each digit from 9.
Ex. Obtain the 9 ‟s complement of (2496) 10.
Solution:(9999) 10
- (2496) 10(7503) 10
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 12/94
Logic Circuit and Switching Theory
The 10‟s Complement
The 10 ‟s complement of a given decimal number isobtained by adding „1‟ to the 9 ‟s complement.
Ex. Obtain the 10 ‟s complement of (2496) 10 .
Solution:Obtain the 9 ‟s complement first
(9999) 10- (2496) 10
(7503) 10
Add „1‟ to the 9 ‟s complement.(7503) 10
+ (1) 10 (7504) 10
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 13/94
Logic Circuit and Switching Theory
The 7‟s Complement
The 7 ‟s complement of a given octal number is obtainedby subtracting each octal digit from 7.
Ex. Obtain the 7 ‟s complement of (654) 8.
Solution:To obtain the 7 ‟s complement
(777) 8- (654) 8
(123) 8
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 14/94
Logic Circuit and Switching Theory
The 8‟s Complement
The 8 ‟s complement is obtained by adding „1‟ to the 7 ‟s complement.
Ex. Obtain the 8 ‟s complement of (723) 8.
Solution:First obtain the 7 ‟s complement
(777) 8- (723) 8
(054) 8
Add „1‟ to the 7 ‟s complement(054) 8+ (1) 8
(055) 8
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 15/94
Logic Circuit and Switching Theory
The 15‟s Complement
The 15 ‟s complement of a given octal number is obtainedby subtracting each hex digit from 15.
Ex. Obtain the 15 ‟s complement of (DAE) 8.
Solution:To obtain the 15 ‟s complement
(FFF) 16- (DAE) 16
(351) 16
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 16/94
Logic Circuit and Switching Theory
The 16‟s Complement
The 16 ‟s complement is obtained by adding „1‟ to the15‟s complement.
Ex. Obtain the 16 ‟s complement of (9CA) 8.
Solution:First obtain the 15 ‟s complement
(FFF) 16- (9CA) 16
(746) 16
Add „1‟ to the 15 ‟s complement(746) 16+ (1) 16
(747) 16
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 17/94
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 18/94
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 19/94
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 andsuccessive multiplication is required on its fractional number.
1. Decimal to BinaryLet use say, we need to convert (34.55) 10 into its equivalentbinary number.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 20/94
Logic Circuit and Switching Theory
For integer part
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 21/94
Logic Circuit and Switching Theory
For fractional part
Therefore, (34.56)10 = (100010.10001100)2
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 22/94
Logic Circuit and Switching Theory
Radix Conversion Algorithms
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 23/94
Logic Circuit and Switching Theory
Flowchart for Successive Division Method
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 24/94
Logic Circuit and Switching Theory
Radix Conversion Algorithms
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 25/94
Logic Circuit and Switching Theory
Flowchart for Successive Multiplication Method
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 26/94
Logic Circuit and Switching Theory
Complements
In digital computers, in order to simplify the subtractionoperation and for logical manipulation complements are used.There are two types of complements for each radix system: Theradix complement and the diminished radix complement. Thefirst is referred to as the r‟s complement and the second as the(r-1 )‟s complement. In binary system we substitute base value 2in place of r to refer to complements as 2 ‟s complement and 1 ‟s complement. In decimal number system, we substitute basevalue 10 in place of r to refer complements as 10 ‟s complementand 9 ‟s complement.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 27/94
Logic Circuit and Switching Theory
1‟s Complement Subtraction
Subtraction of binary numbers can be accomplished bythe direct method, which allows to perform subtraction usingonly addition. For subtraction of two numbers we have twocases.
Case 1: Subtraction of smaller number from larger number
Method:1. Determine the 1 ‟s complement of the smaller number.2. Add the 1 ‟s complement of the smaller number to the larger
number.3. Remove the carry and add it to the result.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 28/94
Logic Circuit and Switching Theory
Example:
Subtract 101011 2 from 111001 2 using 1 ‟s complementmethod.
Solution:
Step 1: Get the 1 ‟s complement of the smaller number.
Step 2: Add the 1 ‟s complement to the larger number.
Step 3: Remove the carry and add it to the result.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 29/94
Logic Circuit and Switching Theory
1‟s Complement Subtraction
Case 2: Subtraction of larger number from smaller number.
Method:1. Determine the 1 ‟s complement of the larger number.2. Add the 1 ‟s complement to the smaller number.3. Answer is in 1 ‟s complement form. To get the true answer,
get the 1 ‟s complement and assign a negative sign to theanswer.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 30/94
Logic Circuit and Switching Theory
Example:
Subtract 111110 2 from 101011 2 using 1 ‟s complementmethod.
Solution:
Step 1: Get the 1 ‟s complement of the larger number.
Step 2: Add the 1 ‟s complement to the smaller number.
Step 3: Get the 1 ‟s complement of the answer and affix anegative sign.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 31/94
Logic Circuit and Switching Theory
Advantage of 1‟s Complement
1. The 1 ‟s complement subtraction can be accomplished with abinary adder. Therefore, it is useful in arithmetic logic circuits.
2. The 1 ‟s complement can be easily obtained by inverting eachbit in the number.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 32/94
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 33/94
Logic Circuit and Switching Theory
2‟s Complement Subtraction
Like 1 ‟s complement subtraction, 2 ‟s complementsubtraction can also be obtained by addition. The two methodsis as follows:
Case 1: Subtraction of smaller number from larger number
Method:1. Determine the 2 ‟s complement of the smaller number.2. Add the 2 ‟s complement of the smaller number to the larger
number.3. Discard the carry.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 34/94
Logic Circuit and Switching Theory
Example:
Subtract 101011 2 from 111001 2 using 2 ‟s complementmethod.
Solution:
Step 1: Get the 2 ‟s complement of the smaller number.
Step 2: Add the 2 ‟s complement to the larger number.
Step 3: Discard the carry.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 35/94
Logic Circuit and Switching Theory
2‟s Complement Subtraction
Case 2: Subtraction of larger number from smaller number.
Method:1. Determine the 2 ‟s complement of the larger number.2. Add the 2 ‟s complement to the smaller number.3. Answer is in 2 ‟s complement form. To get the true answer,
get the 2 ‟s complement and assign a negative sign to theanswer.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 36/94
Logic Circuit and Switching Theory
Example:
Subtract 111110 2 from 101011 2 using 2 ‟s complement
method.Solution:
Step 1: Get the 2 ‟s complement of the larger number.
Step 2: Add the 2 ‟s complement to the smaller number.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 37/94
Logic Circuit and Switching Theory
Step 3: Get the 2 ‟s complement of the answer and affix anegative sign.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 38/94
Logic Circuit and Switching Theory
Signed Binary Numbers
In practice, we use plus sign to represent positive numbers andminus sign to represent negative numbers. However, because ofhardware limitations, in computers, both positive and negativenumbers 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
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 39/94
Logic Circuit and Switching Theory
In case of unsigned 8-bit binary numbers the decimalrange is 0 to 255. For signed 8-bit magnitude binary numbers the
largest magnitude is reduced from 255 to 127 because we needto represent both positive and negative numbers.
Maximum positive number 0111 1111 = +127Maximum negative number 1111 1111 = -128
Three Ways of Representing Negative Signed Numbers
1. Signed-Magnitude Representation
2. Signed-1 ‟s Complement Representation3. Signed-2 ‟s Complement Representation
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 40/94
Logic Circuit and Switching Theory
Answer:
Represent -6 using the three negative signed number ways.
Example:
Signed-Magnitude Representation = 1000 0110
Signed-1 ‟s Complement Representation = 1111 1001
Signed-2 ‟s Complement Representation = 1111 1010
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 41/94
Logic Circuit and Switching Theory
Assuming 8-bit word length, express the following decimalnumbers in:(i) Signed magnitude form(ii) 1‟s complement form(iii) 2‟s complement form
Problem:
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 42/94
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 43/94
EEN 417 – 1A
LOGIC CIRCUIT AND SWITCHING THEORYWEEK 2
JUNE 2013PREPARED BY:ENGR. DARWIN D. ALPIS
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 44/94
Logic Circuit and Switching Theory
The sign-magnitude representation requires separatehandling for sign and magnitude during arithmetic operations
and hence it is suitable in computer arithmetic. The 1 ‟s complement imposes some difficulties and is seldom used forarithmetic operations. It is used as logical operation since thechange of 1 to 0 or 0 to 1 is equivalent to a logical complementoperation. The signed-2 ‟s complement system is commonlyused in computer arithmetic.
Binary Arithmetic
Computer circuits do not process decimal numbers; theyprocess binary numbers. Binary addition is the key to binarysubtraction, multiplication, and division.
i Ci i d S i hi h
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 45/94
Logic Circuit and Switching Theory
L i Ci i d S i hi Th
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 46/94
Logic Circuit and Switching Theory
Binary Code
The digital data is represented, stored and transmittedas groups of binary digit (bits). The group of bits, also known asbinary code, represent both numbers and letters of alphabet aswell as many special characters and control functions. They areclassified as numeric or alphanumeric. Numeric codes are usedto represent numbers. On the other hand, alphanumeric codesare used to represent characters: alphabetic letters andnumerals. In these codes, a numeral is treated simply as anothersymbol rather than as a number or numeric value.
Classification of Binary Codes
The different binary codes can be classified as1. Weighted codes 2. Non-weighted codes3. Reflective codes 4. Sequential codes5. Alphanumeric codes 6. Error Detecting and Correcting
Codes
L i Ci i d S i hi Th
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 47/94
Logic Circuit and Switching Theory
Weighted Codes
In weighted codes, each digit position of the numberrepresents a specific weight. For example, in decimal code, ifnumber is 378 then weight of 3 is 100, weight of 7 is 10 andweight of 8 is 1. In weighted binary codes each digit has aweight 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 isnot assigned fixed value. Excess 3 and gray codes are the non-weighted codes.
L i Ci it d S it hi Th
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 48/94
Logic Circuit and Switching Theory
Reflective Codes
A code is said to be reflective when the code for 9 is thecomplement for the code for 0, 8, for 1, 7 for 2, 6 for 3, and 5 for4. Note that the 2421, 5211 and excess-3 codes are reflective,whereas the 8421 code is not. Reflectivity is desirable in a codewhen the nine‟s complement must be found, such as in nine‟s complement subtraction.
Sequential Codes
In sequential codes each succeeding code is one binarynumber greater than its preceding code. This greatly aidsmathematical manipulation of data. The 8421, and excess-3 are
sequential, whereas 2421 and 5211 codes are not.
L i Ci it d S it hi Th
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 49/94
Logic Circuit and Switching Theory
Alphanumeric Codes
The code which is consists of both numbers andalphabetic characters are called alphanumeric codes. Most ofthese codes, however, also represent symbols and variousinstructions 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) andHollerith code.
Error Detecting and Correcting Codes
When the digital information in the binary form istransmitted from one circuit or system an error may occur. Thismeans a signal corresponding to 0 may change to 1 or vice-versa due to presence of noise. To maintain the data integritybetween transmitter and receiver, extra bit or more than one bitadded in the data.
L gi Ci it d S it hi g Th
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 50/94
Logic Circuit and Switching Theory
These extra bits allow the detection and some times correction oferror in the data. The data along with the extra bit/bits forms the
code. Codes which allow only error detection are called errorde tec t ing codes and codes which allow error detection andcorrection are called er ro r de tec t ing and c or rec t ing cod es .
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 51/94
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 52/94
Logic Circuit and Switching Theory
BCD (8-4-2-1)
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 53/94
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 54/94
Logic Circuit and Switching Theory
BCD ADDITION:
Sum is equals 9 or less with carry 1
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 55/94
Logic Circuit and Switching Theory
BCD addition is as follows:
BCD Addition
1. Add two BCD numbers using ordinary binary addition.
2. If four-bit BCD sum is equal to or less than 9, no correction isneeded. The sum is in proper BCD form.
3. If four-bit sum is greater than 9 or if a carry is generated fromthe four-bit sum, the sum is invalid.
4. To correct the invalid sum, add 0110 2 to the four-bit sum. If acarry results from this addition, add it to the next higher-orderBCD digit.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 56/94
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 57/94
Logic Circuit and Switching Theory
BCD SUBTRACTION:
Subtraction Using 9 ‟s Complement can be summarized as
follows:1. Find the 9 ‟s complement of a negative number.
2. Add two numbers using BCD.
3. If carry is generated add carry to the result otherwise find the9‟s complement of the result.
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 58/94
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 59/94
Logic Circuit and Switching Theory
BCD SUBTRACTION:
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 60/94
Logic Circuit and Switching Theory
BCD SUBTRACTION:
Subtraction Using 10‟s Complement:
The 10 ‟s complement of a decimal number is equal to the9‟s complement plus 1 . The 10 ‟s complement can be used toperform subtraction by adding the minuend to the 10 ‟s complement of the subtrahend and dropping the carry.
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 61/94
Logic Circuit and Switching Theory
BCD SUBTRACTION:
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 62/94
Logic Circuit and Switching Theory
BCD SUBTRACTION:
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 63/94
Logic Circuit and Switching Theory
BCD SUBTRACTION:
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 64/94
Logic Circuit and Switching Theory
Problem:
Perform each of the following decimal additions in 8-4-2-1 BCD.
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 65/94
g g y
Problem:
Perform each of the following decimal subtractions in 8-4-2-1
BCD using 9 ‟s complement.
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 66/94
g g y
Problem:
Perform each of the following decimal subtractions in 8-4-2-1
BCD using 10 ‟s complement.
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 67/94
g g y
The 2-4-2-1 BCD is another self-complementing codewhose 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 twopositions have the same weight, there are two possible bitpatterns that could be used to represent some decimal digits, butonly one of those patterns is actually assigned.
BCD (2-4-2-1)
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 68/94
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 69/94
g g y
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
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 70/94
g g y
Excess-3 code is a modified form of a BCD number. TheExcess-3 code can be derived by adding 3 to each codednumber.
EXCESS-3 CODE
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 71/94
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
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 72/94
Excess – 3 Addition:
Example:
Determine the excess-3 sum of the decimal numbers 3and 4.
Solution:
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 73/94
Problem:
Perform each of the following decimal addition in excess-3 code.
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 74/94
Excess – 3 Subtraction:
1. Complement the subtrahend.
2. Add complemented subtrahend to minuend.
Example:Perform the following operations using excess-3 code.
Solution:
3. If Carry = 1, Result is positive. Add 3 and end-around carry.If Carry = 0, Result is negative. Subtract 3.
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 75/94
Excess – 3 Subtraction:
Solution:
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 76/94
Excess – 3 Subtraction:
Solution:
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 77/94
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 78/94
Gray code is a special case of unit-distance code. In unit-distance code, bit patterns for two consecutive number differs inonly one bit position.
GRAY CODE
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 79/94
As shown in the Table for gray code any two adjacentcode groups differ only in one bit. The gray code is also calledreflected code . Notice that the two least significant bits for 4 10 through 7 10 are the mirror images of those 00 through 3 10.Similarly, the three least significant bits for 8 10 through 15 10 arethe mirror images of those for 0 10 through 7 10 . In general, the n
least significant bits for 2 n through 2 n+1 – 1 are the mirror imagesof those for 0 through 2 n – 1.Another property of gray code is that the gray-coded
number corresponding to the decimal 2 n – 1, for any n, differsfrom gray coded 0 (0000) in one bit position only.
For example, for n = 2, 3 and 4, we see that22 – 1 = 310 = 0010 in gray23 – 1 = 710 = 0100 in gray and24 – 1 = 1510 = 1000 in gray
GRAY CODE
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 80/94
For a 3-bit binary code, it indicates the position of arotating disk. Brushes are used to indicate red and whiteportions on the disk. When the brushes are on the red portion,they output a 1. When the brush are on the white portion, theyoutput 0.
Advantages of GRAY CODE
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 81/94
The gray to binary code conversion can be achieved using thefollowing steps.
1. The most significant bit of the binary number is the same asthe most significant bit of the gray code number. So write itdown.
2. To obtain the next binary digit, perform and exclusive-OR-operation between the bit just written down and the nextgray code bit. Write down the result.
3. Repeat step 2 until all gray code bits have been exclusive-ORed with binary digits. The sequence of bits that have been
written down is the binary equivalent of the gray-codenumber.
GRAY-to-Binary Conversion
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 82/94
Convert the gray code 1 0 1 0 1 1 into its binary equivalent.
GRAY-to-Binary Conversion
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 83/94
Let us represent binary number as
B1 B2 B3 B4 … Bn and its equivalent in gray code asG1 G2 G3 G4 … Gn.
With this representation gray code bits are obtained from the bits
as follows:
Binary-to-Gray Conversion
..
1 1
1 1 2
2 2 3
3 3 4
n n-1 n
G = B
G = B B
G = B B
G = B B
G = B B
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 84/94
Convert the binary code 1 0 1 1 1 0 1 1 into its gray codeequivalent.
Binary-to-Gray Conversion
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 85/94
Alphanumeric Codes
In order to communicate, we need not only numbers, but alsoletters and other symbols commonly known as non numericdata. Computer manipulates both numbers and symbols. Themost programs written by computer users are in the form ofcharacters, i.e. a set of symbols consists of letters, digits, andvarious special characters, such as +, -, >, <, & and so on. The
codes which consists of both numbers and alphabeticcharacters are called alphanumeric codes . Most of these codes,however, also represent symbols and various instructionsnecessary for conveying intelligible information. The mostcommonly used alphanumeric codes are: ASCII (American
Standard Code for Information Interchange) and EBCDIC(Extended Binary Coded Decimal Interchange Code).
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 86/94
ASCII
One standardized alphanumeric code, called theAmerican Standard Code for Information Interchange, is perhapsthe most widely used type. It is a seven-bit code in which thedecimal digits are represented by the BCD code precede by 011.The letter of the alphabet and other symbols and instructions arerepresented by other code combinations as shown in the Table
2-4.
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 87/94
ASCII CODE
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 88/94
ASCII CODE
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 89/94
ASCII CODE
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 90/94
ASCII CODE
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 91/94
ASCII CODE
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 92/94
ASCII CODE
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 93/94
1. Example:
The following is a message encoded in ASCII code. Whatis the message?
Answer:H E L P
2. Example:
An operator is typing in a BASIC program at the keyboardof a certain microcomputer. The computer converts eachkeystroke into its ASCII code and stores the code as a byte in
memory. Determine the binary strings that will be entered intomemory when the operator types in the following BASICstatement:
GOTO 25
Logic Circuit and Switching Theory
8/13/2019 EEN 417-logic circuits
http://slidepdf.com/reader/full/een-417-logic-circuits 94/94
3. Example:
Encode the following message in ASCII code using thehex representation:
“COST = $72. ”
4. Example:
The following padded ASCII-coded message is stored insuccessive memory locations in a computer:
01010011 01010100 01001111 01010000