Upload
solomon-mamo-banteywalu
View
13
Download
0
Embed Size (px)
DESCRIPTION
Digital logic, sequential circuits,
Citation preview
Chapter 1 : Introduction to Binary Systems
Chapter 1 – page: 1EE208: Logic Design 1431-1432Dr. Ridha Jemal
By Dr. Ridha JemalElectrical Engineering Department
College of Engineering
King Saud University
1431-14321.1. Introduction to digital Systems
1.2. Binary numbers
1.3. Number base conversion
1.4. Octal and Hexadecimal Numbers
1.5. Complements
1.6. Signed Binary Numbers
1.7. Arithmetic Operations in bases
1.8. Logic gates
Introduction to Digital Systems
Chapter 1 – page: 2EE208: Logic Design 1431-1432Dr. Ridha Jemal
• Digital systems are built from circuits that process binary digits 0s and 1sand are used in:
o Communication;
oTraffic control and Space guidance;
o Medical treatment;
o Weather monitoring;
o Digital telephone, Television and Camera
o Digital Computer and Internet
The purpose of this chapter is to show you how familiar numericquantities can be represented and manipulated in a digital system, andhow nonnumeric data, events, and conditions also can be represented
• One characteristic of Digital Systems is their ability to manipulate discreteelement of information like :
o 10 decimal digits from 0..9 ;
o 26 letters of the alphabet from a.. Z
Introduction to Digital Systems
Chapter 1 – page: 3EE208: Logic Design 1431-1432Dr. Ridha Jemal
• Discrete elements of information are represented in digital system byphysical quantities called signals (Electrical Signals like voltage orcurrent) The electronic device called transistor predominates inthe circuitry that implements these signals. The signals use just twodiscrete values and therefore said to be binary
• Therefore, a digital system designer must establish some correspondencebetween the binary digits processed by digital circuits and real-life numbers,events, and conditions.
•In Electrical Wire: 0 refers to the state “No current in the wire”
1 refers to the state “There is a current in the wire”
•Discrete elements of information are represented with a group of bits calledbinary Codes.
For example: Decimal digits 0 to 9 are represented in digital system with codeof 4 bits.
Introduction to Digital Systems
Chapter 1 – page: 4EE208: Logic Design 1431-1432Dr. Ridha Jemal
• The Digital System is a system that manipulates discrete elements of
information that is represented internally in binary form.
The general purpose of digital compute is the best known example ofdigital system. The major parts of a computer are:
o Central Processor Unit: It performs arithmetic and logic operations andother data processing.
o Memory Unit: It stores programs as well as input, output andintermediate data.
o Input/Output Unit: The program and data prepared by a user aretransferred into memory by means of an input device such as keyboard. Anoutput device as printer, receives that results of the computation to beprinted.
Introduction to Digital Systems
Chapter 1 – page: 5EE208: Logic Design 1431-1432Dr. Ridha Jemal
To understand the operation of each digital module it is necessary tohave a basic knowledge of digital circuits and their logic function
The digital computer manipulates :
oNumerical values;
oLogic Values;
oSet of symbol
oMisc objects: voice, images, etc…
CPU
Memory
IO
A digital System is an interactionof digital modules
Introduction to Digital Systems
Chapter 1 – page: 6EE208: Logic Design 1431-1432Dr. Ridha Jemal
To understand the operation of each digital module it is necessary tohave a basic knowledge of digital circuits and their logic function
The digital computer manipulates :
oNumerical values;
oLogic Values;
oSet of symbol
oMisc objects: voice, images, etc…
CPU
Memory
IO
A digital System is an interactionof digital modules
Binary Numbers
Chapter 1 – page: 7EE351: Control Systems 1431-1432Dr. Ridha Jemal
• A decimal number 7251 represents a quantity equal to :
7 thousands + 2 hundreds + 5 tens + 1 unit
To be more exact this number should be written as:
7 x 103+ 2 x 102 + 5 x 101 + 1 x 100
• In general a number with decimal point is represented by a series of coefficients asfollows :
a4 a3 a2 a1 a0 • a-1 a-2 a-3
• The aj coefficients are any of the 10 digits (0, 1, 2, …, 9), and the subscript value jgives the place value and, hence, the power of 10 by which the coefficient must bemultiplied. This can be expressed as:
a4x104 + a3x103+ a2x102 + a1x101+ a0x100 + a-1x10-1 + a-2x10-2+ a-3x10-3
• The General form can be expressed as:
anx10n + an-1x10n-1 + • • • + a0x100 + a-1x10-1 + • • • + a-mx10-m
n = (digit number before the point )-1
m = digit number after the point
Binary Numbers
Chapter 1 – page: 8EE351: Control Systems 1431-1432Dr. Ridha Jemal
• The decimal number system is said to be of base or radix 10 because it uses 10digits and the coefficient are multiplied by power of 10.
• The binary system is a different number system. The coefficients of the binarynumber have only two possible values : 0 or 1. Each coefficient aj is multiplied by 2j
• For example, the decimal equivalent of the binary number 11010.11 is ……….. asshown from the multiplication of the coefficient by powers of 2
1x24 + 1x23 + 0x22 + 1x21 + 0x20 + 1x2-1 + 1x2-2 = 26.75
• For example, a number expressed in a base-r system has coefficients multiplied bypowers of r
an x rn + an-1 x rn-1 + • • • + a2 x r2 + a1 x r1 + a0 x r0 + a-1 x r-1 + • • • + a-m x r-m
Binary Numbers
Chapter 1 – page: 9EE351: Control Systems 1431-1432Dr. Ridha Jemal
• There are may bases:
o Binary System : r = 2 It manipulates 2 digits or bits 0, 1
o Base-5 System: r = 5 It manipulates 5 digits : 0, 1, 2, 3, 4
o Octal System : r = 8 It manipulates 8 digits : 0, 1, 2, 3, 4, 5, 6, 7
o Hexadecimal System : r = 16 It manipulates 16 digits : 0, 1, 2, 3, 4, 5, 6, 7, 8,
9, A, B, C, D, E, F
Examples:o (4021.2)5 =
o (127.4)8 =
o (B65F)16 =
o (110101)2 =
511.4 10
87.5 10
46687 10
53 10
Number Base Conversion
Chapter 1 – page: 10EE351: Control Systems 1431-1432Dr. Ridha Jemal
• The conversion of a number in base r to decimal is done by expanding thenumber in a power series and adding the terms as shown previously:
In fact, the general form of a number D is :
an …. a2 a1 a0 • a-1 a-2 …a-m
And its value expressed in the base r is:
where r is the radix of the number and there are n digits to the left of the radixpoint and m to the right. For example if r=10, the value of the number can befound by converting each digit of the number to its radix-10 equivalent andexpanding the formula using radix-10 arithmetic. Some examples are given below:
• 1CE816 = 1·163 + 12·162 + 14·161 + 8·160 = 740010
• F1A316 = 15·163 + 1·162 + 10·161 + 3·160 = 6185910
• 436.58 = 4·82 + 3·81 + 6 ·80 + 5·8–1 = 286.62510
• 132.34 = 1·42 + 3·41 + 2 ·40 + 3·4–1 = 30.7510
an x rn + an-1 x rn-1 + • • • + a2 x r2 + a1 x r1 + a0 x r0 + a-1 x r-1 + • • • + a-m x r-m
Chapter 1 – page: 11EE351: Control Systems 1431-1432Dr. Ridha Jemal
• We now present a general procedure for the reverse operation of converting adecimal number to a number of base r
• Consider what happens if we divide the formula by r we will get a quotient Q and a reminderdi. The quotient has the same form as the original formula .Therefore, successive divisions byr will yield successive digits of D from right to left, until all the digits of D have been derived.
The sequence of reminders are listed in the reverse order of the division process
Decimal Integer to Binary Conversion
179 : 2 = 89 remainder 1 (LSB)
: 2 = 44 remainder 1
: 2 = 22 remainder 0
: 2 = 11 remainder 0
: 2 = 5 remainder 1
: 2 = 2 remainder 1
: 2 = 1 remainder 0
: 2 = 0 remainder 1 (MSB)The result can be expressed as : 179 10 = 101100112
Number Base Conversion
Chapter 1 – page: 12EE351: Control Systems 1431-1432Dr. Ridha Jemal
Number Base Conversion
Decimal Fraction to Binary ConversionSimilar method is applied, just the division is replaced by multiplication for the right after thepoint
Example : 0.687510
0.6875x2 = 1 + 0.3750
0.3750X2 = 0 + 0.7500
0.7500x2 = 1 + 0.5000
0.5000x2 = 1 + 0.0000
0.687510 = 0.10112
Decimal Fraction to Octal Conversion0.51310
0.513x8 = 4 + 0.104
0.104X8 = 0 + 0.832
0.832x8 = 6 + 0.656
0.656x8 = 5 + 0.248
0.248x8 = 1 + 0.984
0.984x8 = 7 + 0.872
0.51310 = 0.4065178
Chapter 1 – page: 13EE351: Control Systems 1431-1432Dr. Ridha Jemal
Number Base Conversion
Binary to Octal/Hexadecimal ConversionThe conversion is easily accomplished by partitioning the binary number into group ofthree digits for the octal conversion and four digits for the hexadecimal conversion
Examples :
o (10 110 001 101 011 . 111 100 000 110)2 = (26153.7406)8
o (10 1100 0110 1011 . 1111 0010)2 = (2C6B.F2)16
• The conversion from and to binary, octal and Hexadecimal plays an importantrole in digital computers. Since 23=8 and 24=16 each octal digit corresponds tothree binary digits and each hexadecimal digit correspond to four binary digits.
Octal/Hexadecimal to Binary ConversionConversion from octal or hexadecimal to binary is done by reversing the precedingprocedure . Each octal digit is converted to its three-digit binary equivalent. Similarly, eachhexadecimal digit is converted to its four-digit binary equivalent.
Examples :
o (673.124)8 = (110 111 011. 001 010 100)2
o (306.D)16 = (0011 0000 0110 . 1101)2
Chapter 1 – page: 14EE351: Control Systems 1431-1432Dr. Ridha Jemal
Number Base Conversion
Decimal(Base 10)
Binary(Base 2)
Octal(Base 8)
Hexadecimal(Base 16)
00 0000 00 0
01 0001 01 1
02 0010 02 2
03 0011 03 3
04 0100 04 4
05 0101 05 5
06 0110 06 6
07 0111 07 7
08 1000 10 8
09 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
Chapter 1 – page: 15EE351: Control Systems 1431-1432Dr. Ridha Jemal
• Complements are used in digital computer for simplifying the subtraction operation and for logical manipulation. There are two types of complements for each base-r system:
•The radix complement (r’s complement)•The diminished radix complement ((r-1)’s complement)
Complements
• Given a number N in base r having n digits, the (r-1)’s complement of N isdefined as (rn – 1) –N
o For r=10, r-1=9, so the 9’s complement of N is (10n -1) – N
The 9’s complement of 546700 is 999999 – 546700 = 453299
The 9’s complement of 012398 is 999999 – 012398 = 987601
o For r=2, r-1=1, so the 1’s complement of N is (2n -1) – N
o N=4 ; 24= 100002 and 24 – 1=1111. The 1’s complement is obtained by subtractingeach digit from 1. We have one of the following cases :1 -0 or 1-1.
The (r-1)s complement
Chapter 1 – page: 16EE351: Control Systems 1431-1432Dr. Ridha Jemal
Complements
• The r’s complement = the (r-1)’s complement + 1
[(rn – 1) –N]+1
o For r=10,
The 10’s complement of 012398 is 987602
The 10’s complement of 246700 is 753300
o For r=2,
Given a binary umber 10100101
The 1’s complement of 10100101 is 01011010
The 2’s complement of 10100101 is 01011010+1 = 01011011
The radix complement (r’s complement)
The 1’s complement is obtained by changing 1’s to 0’s and 0’s to 1’s
The 1’s complement of 1011000 is 0100111
Chapter 1 – page: 17EE351: Control Systems 1431-1432Dr. Ridha Jemal
Signed Binary Numbers
Negative Number
• The sign is represented by a bit placed in the leftmost position of thenumber. The convention is to make the sign bit 0 for positive 1 fornegative.
• Positive integers can be represented by unsigned numbers. However, torepresent negative integers, we need a notation for negative values
0 1010010 as unsigned number is equal to :
1 1010010 as unsigned number is equal to :
1 1010010 as signed number is equal to :
Chapter 1 – page: 18EE351: Control Systems 1431-1432Dr. Ridha Jemal
Signed Binary Numbers
Number line extends in both directions:
Ways to represent numbers less than zero:
Signed MagnitudeUse MSB as a flag: 0=+ve, 1=-ve ("sign bit")
All other bits hold the magnitude
eg. using 4 bits
0110 = 6
1010 = -2
One’s Complement• Given a number N in base 2 having n digits, the 1’s complement of N is
defined as (2n – 1) –N
The 1’s complement is obtained by changing 1’s to 0’s and 0’s to 1’s
The 1’s complement of 1011011 is 0100100
Chapter 1 – page: 19EE351: Control Systems 1431-1432Dr. Ridha Jemal
Signed Binary Numbers
Two’s Complement
To negate number: Invert all bits and add 1 ; eg. -2 using 8 bits* 0000 0010 inverted is 1111 1101* Add 1: 1111 1110 (-2)Another way: Start writing down the number from left.
Write the number exactly as it appears until the first one.Write down the first one and invert all digits to its left
Examples : Find the 2’s complement using 8 bits1. +8 = 00001000
1000 write number to first one111 invert the remaining bits
-8 = 111110001. +13 = 00001101
1’s com.: 11110010
2’s com.: 11110011
-13 = 11110011
Chapter 1 – page: 20EE351: Control Systems 1431-1432Dr. Ridha Jemal
Arithmetic Operations in bases (Add, Sub)
If the signs are the same, we add two magnitudes and gives the common sign
Example 1:+8 001000 + 24 0011000
+17 010001 + 32 0100000
------------------------------- ---------------------------------------
+25 011001 +56 0111000
Addition/subtraction
• If the signs are different, we subtract the smaller magnitude from thelarger and we give the result the sign of the larger magnitude. This processrequires a comparison and subtraction. So we will use only the addition inthe signed complement system without need to use the comparison andthe subtraction.
Subtraction = Addition of the 2’s complement of the negative number
Chapter 1 – page: 21EE351: Control Systems 1431-1432Dr. Ridha Jemal
Arithmetic Operations in bases (Add, Sub)
• Example 2+17 010001 010001
-8 101000 111000 2’s complement of 001000
The sign bit is not complemented -----------------------------------------------------
+9 001001
• If the result is negative, we will take its 2’s complement to get the finalresult
• Example 3:+ 24 0011000 0011000
- 35 1100011 1011101 2’s complement of 0100011
------------------------------- ---------------------------------------
1110101 It’s a negative number, we take its
2’s complement which is : 1001011 equal to -11
Chapter 1 – page: 22EE351: Control Systems 1431-1432Dr. Ridha Jemal
Arithmetic Operations in bases (Add, Sub)
• Example 4: +35 -72 = ???
+ 35 00100011 00100011
- 72 11001000 10111000 2’s complement 0f 01001000
---------------------------------------
11011011 It’s a negative number,
we take its 2’s complement which is : 00100101 equal to - 37
Chapter 1 – page: 23EE351: Control Systems 1431-1432Dr. Ridha Jemal
Binary Code – Character Sets
ASCII - American Standard Code for Information Interchange
a.k.a ISO 646-1973 (international)
BS 4730: 1974 (British Standard)
7-bit code (128 different characters)
Numerals, punctuation and letters
American alphabet...
... no symbols for ö, å, ñ etc.
Still VERY widely used
EBCDIC - Extended Binary-Coded-Decimal Interchange Code
Proprietary to IBM
8-bit code
Not compatible with ASCII
ISO Latin1 - 8-bit code
Extension to ASCII (ASCII is compatible)
Has characters for European languages
Future - include ALL characters from ALL languages (!)
Unicode (16 bits)
ISO 10646 (32 bits)
Chapter 1 – page: 24EE351: Control Systems 1431-1432Dr. Ridha Jemal
Binary Codes
• Digital Systems represent and manipulate not only binary numbers but also manyother discrete elements of information which can be represented by a binarycode.
• An n-bit binary code is a group of n bits that assume up to 2n distinctcombinations of 1’s and 0’s.
Examples:
o A set of four elements can be coded with two bits: 00, 01, 10 and 11
o A set of 16 elements requires a 4-bit code
BCD Code (Binary Coded Decimal)Decimal Symbol BCD Digit
0 00001 00012 00103 00114 01005 01016 01107 01118 10009 1001
• A number with k decimal digits willrequire 4k bits in BCD
• (396)10 = (0011 1001 0110)BCD
Chapter 1 – page: 25EE351: Control Systems 1431-1432Dr. Ridha Jemal
Binary Codes
• Consider the addition of two decimal digits in BCD, together with apossible carry from previous less significant pair of bits:
If the result is greater or equal 1010, the result is an invalid BCD digit; Theaddition of 6 = (0110)2 to the binary sum converts it to the correct digitand also produces a carry as required.
Examples:
4 0100 4 0100
+5 +0101 +8 +1000
----------------- ----------------------
+9 1001 12 1100
+ 0110
----------------------
12 1 0010
BCD Addition
Chapter 1 – page: 26EE351: Control Systems 1431-1432Dr. Ridha Jemal
Binary Codes
BCD Addition (contd.)
• The addition of two n-digit unsigned BCD numbers follows the sameprocedure. Consider the addition of 184 +576
184 0001 1000 0100
+576 +0101 0111 0110
--------------------------------
0110 1111 1010
+ 0110 0110
+ 1 1
--------------------------------
0111 0110 0000
7 6 0
Chapter 1 – page: 27EE351: Control Systems 1431-1432Dr. Ridha Jemal
Gray and ASCII Codes
Gray Code DecimalEquivalent
0000 00001 10011 20010 30110 40111 50101 60100 71100 81101 91111 101110 111010 121011 131001 141000 15
ASCII Code Characters
100 0001 A110 0001 a100 0010 B110 0010 b
. .
. .
. .100 0110 F110 0110 f100 0111 G110 0111 g
. .
. .
. .011 0001= 31Hex 1011 0011= 33Hex 3
Chapter 1 – page: 28EE351: Control Systems 1431-1432Dr. Ridha Jemal
Binary Logic
AND gate
• Binary Logic consists on Binary variables and Logical operations
o Variables : A, B, C, …. Z, a, b, c, …1, 2, 3 expressed in the binary system
o Logical Operations : 3 fundamental operations A ND, OR, INV
A B C
0 0 0
0 1 0
1 0 0
1 1 1
AND : Result TRUE if and only if bothinput operands are true
C= A•B
Its graphic Symbol is:
AB
C
Chapter 1 – page: 29EE351: Control Systems 1431-1432Dr. Ridha Jemal
OR and NOT gates
A B C
0 0 0
0 1 1
1 0 1
1 1 1
OR : Result TRUE if operands are true
C= A+B
Its graphic Symbol is:
NOT
: Result TRUE if single input value isFALSE
C= A
Its graphic Symbol is:
A C
0 1
1 0
AB
C
A C
Binary Logic