Академический Документы
Профессиональный Документы
Культура Документы
2007-2008
Habib.Hamam@umoncton.ca
Habib@cud.ac.ae
1
Table of contents - 1
Textbook ………...……………………………..……….…………………………..… 6
Learning outcomes ………...………………..……….…………………………..… 7
Chapter 1: Numerical systems ……………..……………….……………........…. 8
Learning outcomes ….…………………………………...……..…..…………….………… 9
4 commonly used systems …………………………….………………………..……….… 11
Conversions ……………………………….……………………………………………….. 17
Interest of these codes …………………….……………………….………………...…..... 30
BCD code ……………………………………...……….……………………………..….…. 35
Gray code …………………………………………..……….………………………………. 40
Other codes …………………………………………..……….……….……………...……. 45
Error detection …………………………………………..……….……….…………..……. 48
Quiz …………………………………………..……….……….…………………..…..……. 55
Chapter 2: Arithmetic and logic operations ……………...…..……….….….... 61
Learning outcomes ………………………………......…………………….………....….. 62
Binary operations ……………………...………………..…………………………..….…. 64
Octal operations ……………………………………….…………………………….……. 72
Hexadecimal operations …………………………..…...………………………..….……. 75
Quiz ………………………………………………….………………………...…….… ….. 79
Numerical systems
9
Section 1
Learning outcomes
10
Learning outcomes
Upon successful completion of this chapter,
students will able to:
1. understand the typical numerical bases :
decimal, binary, hexadecimal and octal
2. master conversion between bases
3. Understand the principle of BCD and Gray
coding
4. understand a typical method for error detections
12
Bases of calculus
Different bases and systems
Base 8 (octal):
Digits are 0, 1, 2, 3, 4, 5, 6, 7
Each octal digit represents a sequence of 3 bits
7 1 5 3 6 4
Most Significant Digit Lowest Significant Digit
MSD LSD
113
16
Binary system
Binary basis
Composed of two digits 1 & 0
1 0 1 1 0 1
Most Significant Bit Lowest Significant Bit
MSB LSB
Conversions
19
Binary to decimal Conversion
To convert binary numbers into decimal
numbers, we only need to sum powers with non
zero weights (with power ‘1’) :
2510 = 1 1 0 0 12 2510 = 1 1 0 0 1 2
25 0 0
24 11 1 25| 2
- 16 1 | 12 | 2
= 9 23 0|6 |2
- 8
0 |3 |2
= 1 1 |1 |2
20
- 1
1 |0
= 0
Exercice 2:
What is the biggest decimal number that can be
represented by a binary number of
8 bits (1 byte)?
16 bits (2 bytes)?
Exercice 2:
28 - 1 = 255
4 7 2 . 3 1 (Octal)
100 111 010 . 011 001 (Binaire)
E 1 A 3 E 9
1110 0001 1010 0011 1110 1001
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F
Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
9F216 = 9 F 2
1001 1111 0010 = 1001111100102
E 1 A 3 E 9
7 0 3 2 1 7 5 1
Digital Logic Habib Hamam Canadian University of Dubai 31
Section 4
32
Why hexadecimal coding
Digital circuits and computers use binary
numbers to represent data, memory addresses
and I/O, instructions, state indicators, etc.
The hexadecimal code simplifies the
representation and easily compares binary
numbers.
Conversion is very easy.
BCD code
37
BCD
Binary Coded Decimal (BCD) is another way to
present decimal numbers in binary form.
BCD is widely used and combines features of
both decimal and binary systems.
Each digit is converted to a binary equivalent.
4 7 2 (decimal)
0100 0111 0010 (BCD)
8 74
0100 0111 0100 = 010001110100BCD
Gray Code
43
Gray Code
The gray code is used in applications where
numbers change rapidly.
In the gray code, only one bit changes from each
value to the next.
Other codes
47
2-8 Alphanumeric Codes
Represents characters and functions found on a
computer keyboard.
ASCII – American Standard Code for Information
Interchange.
Seven bit code: 27 = 128 possible code groups
Table 2-4 lists the standard ASCII codes
Examples of use are: to transfer information between
computers, between computers and printers, and for
internal storage.
SOH 1 01 ! 33 21 A 65 41 a 97 61
STX 2 02 " 34 22 B 66 42 b 98 62
ETX 3 03 # 35 23 C 67 43 c 99 63
EOT 4 04 $ 36 24 D 68 44 d 100 64
ENQ 5 05 % 37 25 E 69 45 e 101 65
ACK 6 06 & 38 26 F 70 46 f 102 66
BEL 7 07 ' 39 27 G 71 47
g 103 67
BS 8 08 ( 40 28 H 72 48
TAB 9 09 h 104 68
) 41 29 I 73 49
LF 10 0A i 105 69
* 42 2A J 74 4A
VT 11 0B j 106 6A
+ 43 2B K 75 4B
FF 12 0C , 44 2C L 76 4C
k 107 6B ASCII code extended
CR 13 0D l 108 6C
SO 14 0E
-
.
45
46
2D
2E
M
N
77
78
4D
4E m 109 6D to 8 bits
SI 15 0F / 47 2F O 79 4F n 110 6E
DLE 16 10 0 48 30 P 80 50 o 111 6F
DC1 17 11 1 49 31 Q 81 51 p 112 70
DC2 18 12 2 50 32 R 82 52 q 113 71
DC3 19 13 3 51 33 S 83 53 r 114 72
DC4 20 14 4 52 34 T 84 54 s 115 73
NAK 21 15 5 53 35 U 85 55 t 116 74
SYN 22 16 6 54 36 V 86 56
u 117 75
ETB 23 17 7 55 37 W 87 57
v 118 76
CAN 24 18 8 56 38 X 88 58
w 119 77
EM 25 19 9 57 39 Y 89 59
SUB 26 1A x 120 78
: 58 3A Z 90 5A
ESC 27 1B ; 59 3B [ 91 5B y 121 79
FS 28 1C < 60 3C \ 92 5C z 122 7A
GS 29 1D = 61 3D ] 93 5D { 123 7B
RS 30 1E > 62 3E ^ 94 5E | 124 7C
US 31 1F ? 63 3F _ 95 5F } 125 7D
Espace 32 20 @ 64 40 ` 96 60 ~ 126 7E
Error detection
50
Parity Method for Error Detection
Binary data and codes are frequently moved
between locations. For example:
Digitized voice over a microwave link.
Storage and retrieval of data from magnetic and optical
disks.
Communication between computer systems over
telephone lines using a modem.
Signal initial:
Recovered signal
right decision
wrong
Digital Logic Habib Hamam Canadian University of Dubai 52
Parity Method for Error Detection
The parity method of error detection requires the
addition of an extra bit to a code group.
This extra bit is called the parity bit.
The bit can be either a 0 or 1, depending on the
number of 1s in the code group.
There are two methods, even and odd.
Quiz
57
1. Binary base
What is the biggest number that one can obtain
with 5 binary bits
1. 31
2. 32
3. 63
4. 64
1. 63
2. 127
3. 255
4. 511
1. (FF,FF,00)
2. (00,99,00)
3. (00,FF,00)
4. (00,EE,00)
5. (00,00,EE)
1. 19
2. 51
3. 10011
4. 110011
1
4
3
1