Loading...

C. Gerousis © Digital Design 3rd Ed., Mano Prentice Hall

Digital vs. Analog • An analog system has continuous range of values

– A mercury thermometer – Vinyl records – Human eye

• A digital system has a set of discrete values

– Digital Thermometer – Compact Disc (CD) – Digital camera

Benefits of using digital

Analog signal

Digital signal

• Advantages of using Digital: • Cheap electronic circuits • Easier to calibrate and adjust • Resistance to noise: Clearer picture and sound

Binary System • Discrete elements of information are represented with bits called binary codes. Example: (09)10 = (1001)2 (15)10 = (1111)2 Question: Why are commercial products made with digital circuits as opposed to analog? Most digital devices are programmable: By changing the program in the device, the same underlying hardware can be used for many different applications.

Decimal Code 4 Review the decimal number system. Base (Radix) is 10 - symbols (0,1, . . 9) Digits For Numbers > 9, add more significant digits in position to the left, e.g. 19>9. Each position carries a weight. MSD Weights: ü

103 102 101 100 10−110−2 10−3

LSD

If we were to write 1936.25 using a power series expansion and base 10 arithmetic:

1× 103 + 9 × 102 + 3× 101 + 6 × 100 + 2 × 10−1 + 5 × 10−2

Binary number system 4 The binary number system. – – –

Base is 2 - symbols (0,1) - Binary Digits (Bits) For Numbers > 1, add more significant digits in position to the left, e.g. 10>1. Each position carries a weight (using decimal).

MSD Weights:

23 2 2 21 2 0

2 −1 2 −2 2 −3

ü If we write 10111.01 using a decimal power series we convert from binary to decimal: 1× 24 + 0 × 23 + 1× 22 + 1× 21 + 1× 20 + 0 × 2−1 + 1× 2 −2 = = 1× 16 + 0 × 8 + 1× 4 + 1× 2 + 1× 1 + 0 × 0.5 + 1× 0. 25 = 23.25

LSD

Binary number system q (110000.0111)2 = ( ? )10 ANS: 48.4375

4 In computer work: 210 =1024 is referred as K = kilo 220 =1048576 is referred as M = mega 230 = ? 240 = ? q What is the exact number of bytes in a 16 Gbyte memory module?

Octal/Hex number systems 4 The octal number system [from Greek: ΟΚΤΩ]. –

Its base is 8 à eight digits 0, 1, 2, 3, 4, 5, 6, 7

ü (236.4)8 = ( ? )10 2 × 82 + 3 × 81 + 6 × 80 + 4 × 8−1 = 158. 5

4 The hexadecimal number system [from Greek: ∆ΕΚΑΕΞΙ]. – Its base is 16 à first 10 digits are borrowed from the decimal system and the letters A, B, C, D, E, F are used for the digits 10, 11, 12, 13, 14, 15

ü (D63FA)16 = ( ? )10 13× 164 + 6 × 163 + 3 × 162 + 15 × 161 + 10 × 160 = 877562

Conversion from Decimal to Binary 4 Conversion from decimal to binary: Let each bit of a binary number be represented by a variable whose subscript = bit positions, i.e.,

(110 ) 2 = (a2 a1a0 ) 2 Its decimal equivalent is:

(1× 2 2 + 1× 21 + 0 × 20 )10 = (a2 × 22 + a1 × 21 + a0 × 20 ) 10 It is necessary to separate the number into an integer part and a fraction: Repeatedly divide the decimal number by 2.

Conversion from Decimal to Binary ü Find the binary equivalent of 37. 2 37 2 18 2 9 2 4 2 2 21 q

= 18 + 0.5

1

0 = 4 + 0.5 1 0 =2 +0 0 =1 +0

LSB

=9 +0

= 0 + 0.5

? 2 5310 = ____

1

3710 = 100101 2 MSB

ANS: 5310 = 110101 2

Conversion from Decimal to Binary 4 Conversion from decimal fraction to binary: same method used for integers except multiplication is used instead of division.

ü

Convert (0.8542)10 to binary (give answer to 6 digits). 0.8542 x 2 = 0.7084 x 2 = 0.4168 x 2 = 0.8336 x 2 = 0.6675 x 2 = 0.3344 x 2 =

1 1 0 1 1 0

+ + + + + +

0.7084 0.4168 0.8336 0.6672 0.3344 0.6688

a-1 = 1 a-2 = 1 a-3 = 0 a-4 = 1 a-5 = 1 a-6 = 0

MSB

LSB

(0. 8542)10 = (0.a−1a−2 a−3 a−4 a−5a− 6 )2 = (0. 110110)2 q (53.8542)10 = (

? )2

Conversion from Decimal to Octal 4 Conversion from decimal to octal: The decimal number is first divided by 8. The remainder is the LSB. The quotient is then divide by 8 and the remainder is the next significant bit and so on.

ü

Convert 1122 to octal.

8 1122 = 140 + 0.25 8 140 = 17 + 0.5 8 17 = 2 + 0.125 8 2 = 0 + 0.25

R2 R4 R1 R2

112210 = 21428

LSB

MSB

Table 1-2 page: 8

Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Hex 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

Octal 00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17

Conversion using Table 4 Conversion from and to binary, octal, and hexadecimal plays and important part in digital computers. since 2 3 = 8 and 2 4 = 16 each octal digit corresponds to 3 binary digits and each hexa digit corresponds to 4 binary digits. ü (010 111 100 . 001 011 000)2 = (274.130)8 ü (0110 1111 1101 . 0001 0011 0100)2 = (6FD.134)16

from table

1’s and 2’s Complements 4 1’s complement of N = (2n-1) – N (N is a binary #) 1’s complement can be formed by changing 1’s to 0’s and 0’s to 1’s 2’s complement of a number is obtained by leaving all least significant 0’s and the first 1 unchanged, and replacing 1’s with 0’s and 0’s with 1 in all higher significant digits. ü The 1’s complement of 1101011 = 0010100 ü The 2’s complement of 0110111 = 1001001 q Find the 1’s and 2’s-complement of 10000000 Answer: 01111111 and 10000000

Subtraction Using Complements 4 Subtraction with digital hardware using complements: Subtraction of two n-digit unsigned numbers M – N base r: 1. Add M to the r’s complement of N: M + (rn – N) 2. If M ≤ N, the sum will produce an end carry and is equal to rn that can be discarded. The result is then M – N. 3. If M ≥ N, the sum will not produce an end carry and is equal to rn – (N – M)

Binary Subtraction using complements 4 Binary subtraction is done using the same procedure. ü Subtract 1010100 – 1000011 using 2’s complement: A= 2’s complement of B = + Sum = Discard end carry = – Answer =

1010100 0111101 10010001 10000000 0010001

end carry

q Subtract 1000011 – 1010100 using 2’s complement: Answer = – 0010001

Binary Subtraction using complements ü Subtract 1010100 – 1000011 using 1’s complement: A= 1010100 1’s complement of B = + 0111100 Sum = 10010000 End-around carry = + 1 Answer = 0010001

q Subtract 1000011 – 1010100 using 1’s complement: Answer = – 0010001

Arithmetic addition Negative numbers must be initially in 2’s complement form and if the obtained sum is negative, it is in 2’s complement form. +6 +13 +19

00000110 00001101 00010011

–6 +13 +7

11111010 00001101 00000111

q Add –6 and –13

Answer = 11101101

Transfer of Information with Registers

J

Binary Information Processing

Loading...