chapter 1 : introduction to binary systems 1.1. introduction to digital systems 1.2. binary numbers...
Post on 18-Jan-2018
273 Views
Preview:
DESCRIPTION
TRANSCRIPT
Chapter 1 : Introduction to Binary Systems
1.1. Introduction to Digital Systems1.2. Binary Numbers1.3. Number Base Conversion1.4. Octal and Hexadecimal Numbers1.5. Complements1.6. Signed Binary Numbers1.7. Arithmetic Operations in Bases1.8. Logic Gates
Chapter 1 – page: 1EE208: Logic Design 1434-1435
Dr. Ridha Jemal
By Dr. Ridha JemalElectrical Engineering Department
College of EngineeringKing Saud University
1434-1435
Introduction to Digital Systems
Chapter 1 – page: 2
• Digital systems are built from circuits that process binary digits 0s and 1s and are used in:
o Communication;oTraffic control and Space guidance;o Medical treatment;o Weather monitoring;o Digital telephone, Television and Camerao Digital Computer and Internet
The purpose of this chapter is to show you how familiar numeric quantities can be represented and manipulated in a digital system, and how nonnumeric data, events, and conditions also can be represented
• One characteristic of Digital Systems is their ability to manipulate discrete element of information like : o 10 decimal digits from 0..9 ; o 26 letters of the alphabet from a.. Zo etc…
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
Chapter 1 – page: 3
• Discrete elements of information are represented in digital system by physical quantities called signals (Electrical Signals like voltage or current) The electronic device called transistor predominates in the circuitry that implements these signals. The signals use just two discrete values and therefore said to be binary.
• Therefore, a digital system designer must establish some correspondence between 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 called binary Codes.For example: Decimal digits 0 to 9 are represented in digital system with code of 4 bits.
Introduction to Digital Systems
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
Chapter 1 – page: 4
• 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 of digital system. The major parts of a computer are:
o Central Processor Unit: It performs arithmetic and logic operations and other data processing.o Memory Unit: It stores programs as well as input, output and intermediate data.o Input/Output Unit: The program and data prepared by a user are transferred into memory by means of an input device such as keyboard. An output device as printer, receives the results of the computation to be printed.
Introduction to Digital Systems
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
Chapter 1 – page: 5
To understand the operation of each digital module it is necessary to have a basic knowledge of digital circuits and their logic function
The digital computer manipulates :oNumerical values;oLogic Values;oSet of symboloMisc objects: voice, images, etc…
CPU
Memory
IO
A digital System is an interaction of digital modules
Introduction to Digital Systems
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
Chapter 1 – page: 6
Binary Numbers
EE208: Logic Design 1434-1435
Dr. 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 as follows :
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 j gives the place value and, hence, the power of 10 by which the coefficient must be multiplied. 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 )-1m = digit number after the point
Chapter 1 – page: 7EE208: Logic Design 1434-1435
Dr. Ridha Jemal
The decimal number system is said to be of base or radix 10 because it uses 10 digits and the coefficient are multiplied by power of 10.• The binary system is a different number system. The coefficients of the binary
number 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 ……….. as shown 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 by powers 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: 8EE208: Logic Design 1434-1435
Dr. Ridha Jemal
Binary Numbers
There are may bases:oBinary System : r = 2 It manipulates 2 digits or bits 0, 1oBase-5 System: r = 5 It manipulates 5 digits : 0, 1, 2, 3, 4oOctal System : r = 8 It manipulates 8 digits : 0, 1, 2, 3, 4, 5, 6, 7oHexadecimal 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
Chapter 1 – page: 9
Number Base Conversion
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
The conversion of a number in base r to decimal is done by expanding the number 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-mAnd 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 radix point and m to the right. For example if r=10, the value of the number can be found by converting each digit of the number to its radix-10 equivalent and expanding 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: 10EE208: Logic Design 1434-1435
Dr. Ridha Jemal
Number Base ConversionWe now present a general procedure for the reverse operation of converting a decimal 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 reminder di. The quotient has the same form as the original formula .Therefore, successive divisions by r 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 processDecimal 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
Chapter 1 – page: 11
Number Base Conversion
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
Decimal Fraction to Binary ConversionSimilar method is applied, just the division is replaced by multiplication for the right after the point
Example : 0.687510
0.6875x2 = 1 + 0.37500.3750X2 = 0 + 0.75000.7500x2 = 1 + 0.50000.5000x2 = 1 + 0.00000.687510 = 0.10112
Decimal Fraction to Octal Conversion0.51310
0.513x8 = 4 + 0.1040.104X8 = 0 + 0.8320.832x8 = 6 + 0.6560.656x8 = 5 + 0.2480.248x8 = 1 + 0.9840.984x8 = 7 + 0.8720.51310 = 0.4065178
Chapter 1 – page: 12
Number Base Conversion
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
Binary to Octal/Hexadecimal ConversionThe conversion is easily accomplished by partitioning the binary number into group of three 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 important role in digital computers. Since 23=8 and 24=16 each octal digit corresponds to three 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 preceding procedure . Each octal digit is converted to its three-digit binary equivalent. Similarly, each hexadecimal 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: 13
Number Base Conversion
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
Decimal)Base 10(
Binary)Base 2(
Octal)Base 8(
Hexadecimal)Base 16(
00 0000 00 001 0001 01 102 0010 02 203 0011 03 304 0100 04 405 0101 05 506 0110 06 607 0111 07 708 1000 10 809 1001 11 910 1010 12 A11 1011 13 B12 1100 14 C13 1101 15 D14 1110 16 E15 1111 17 F
Chapter 1 – page: 14
Complements
EE208: Logic Design 1434-1435
Dr. 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)
• Given a number N in base r having n digits, the (r-1)’s complement of N is defined as (rn – 1) –N
o For r=10, r-1=9, so the 9’s complement of N is (10n -1) – NThe 9’s complement of 546700 is 999999 – 546700 = 453299The 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) – No N=4 ; 24= 100002 and 24 – 1=1111. The 1’s complement is obtained by subtracting
each digit from 1. We have one of the following cases :1 -0 or 1-1.
The (r-1)s complement
Chapter 1 – page: 15
Complements
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
• 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 987602The 10’s complement of 246700 is 753300
o For r=2,
Given a binary umber 10100101The 1’s complement of 10100101 is 01011010The 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’sThe 1’s complement of 1011000 is 0100111
Chapter 1 – page: 16
Signed Binary Numbers
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
Negative Number
• The sign is represented by a bit placed in the leftmost position of the number. The convention is to make the sign bit 0 for positive 1 for negative.
• Positive integers can be represented by unsigned numbers. However, to represent 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: 17
Signed Binary Numbers
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
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 = 61010 = -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: 18
Signed Binary Numbers
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
Two’s ComplementTo 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 one 111 invert the remaining bits
-8 = 111110001. +13 = 00001101 1’s com.: 11110010 2’s com.: 11110011 -13 = 11110011
Chapter 1 – page: 19
Arithmetic Operations in bases (Add, Sub)
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
If the signs are the same, we add two magnitudes and gives the common signExample 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 the larger and we give the result the sign of the larger magnitude. This process requires a comparison and subtraction. So we will use only the addition in the signed complement system without need to use the comparison and the subtraction.Subtraction = Addition of the 2’s complement of the negative number
Chapter 1 – page: 20EE208: Logic Design 1434-1435
Dr. Ridha Jemal
Arithmetic Operations in bases (Add, Sub)
• Example 2 +17 010001 010001 -8 101000 111000 2’s complement of 001000The sign bit is not complemented -----------------------------------------------------+9 001001
• If the result is negative, we will take its 2’s complement to get the final result
• 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: 21EE208: Logic Design 1434-1435
Dr. Ridha Jemal
• 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
Arithmetic Operations in bases (Add, Sub)
Chapter 1 – page: 22
Binary Code – Character Sets
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
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 lettersAmerican 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: 23
Binary Codes
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
• Digital Systems represent and manipulate not only binary numbers but also many other discrete elements of information which can be represented by a binary code.
• An n-bit binary code is a group of n bits that assume up to 2n distinct combinations of 1’s and 0’s.Examples:o A set of four elements can be coded with two bits: 00, 01, 10 and 11o A set of 16 elements requires a 4-bit code
BCD Code (Binary Coded Decimal)
Decimal Symbol BCD Digit0 00001 00012 00103 00114 01005 01016 01107 01118 10009 1001
• A number with k decimal digits will require 4k bits in BCD
• (396)10 = (0011 1001 0110)BCD
Chapter 1 – page: 24
Binary Codes
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
• Consider the addition of two decimal digits in BCD, together with a possible carry from previous less significant pair of bits:If the result is greater or equal 1010, the result is an invalid BCD digit; The addition of 6 = (0110)2 to the binary sum converts it to the correct digit and 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: 25
Binary Codes
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
BCD Addition (contd.)
• The addition of two n-digit unsigned BCD numbers follows the same procedure. 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: 26
Gray and ASCII Codes
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
Gray Code Decimal Equivalent
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 1
011 0011 =33Hex
3
Chapter 1 – page: 27
Binary Logic
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
AND gate
• Binary Logic consists on Binary variables and Logical operationso Variables : A, B, C, …. Z, a, b, c, …1, 2, 3 expressed in the binary systemo Logical Operations : 3 fundamental operations A ND, OR, INV
A B C0 0 00 1 01 0 01 1 1
AND : Result TRUE if and only if both input operands are true
C= A•B
Its graphic Symbol is:
AB
C
Chapter 1 – page: 28
Binary Logic
EE208: Logic Design 1434-1435
Dr. Ridha Jemal
A B C0 0 00 1 11 0 11 1 1
OR : Result TRUE if operands are trueC= A+BIts graphic Symbol is:
NOT : Result TRUE if single input value is
FALSE C= AIts graphic Symbol is:
A C0 11 0
AB
C
A C
top related