Файл: Digital design with CPLD applications and VHDL (R. Dueck, 2000).pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 13.06.2025

Просмотров: 8036

Скачиваний: 6

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

8

C H A P T E R 1 • Basic Principles of Digital Systems

The sequence from 8 to 15 requires yet another bit: the 8’s bit. The three LSBs of this sequence repeat the 0 to 7 sequence. The binary equivalents of 8 to 15 are:

1000 ( 8 0 0 0)

1001 ( 8 0 0 1)

1010 ( 8 0 2 0)

1011 ( 8 0 2 1)

1100 ( 8 4 0 0)

1101 ( 8 4 0 1)

1110 ( 8 4 2 0)

1111 ( 8 4 2 1)

Practice writing out the binary sequence until it becomes familiar. In the 0 to 15 sequence, it is standard practice to write each number as a 4-bit value, as in Example 1.2, so that all numbers have the same number of bits. Numbers up to 7 have leading zeros to pad them out to 4 bits.

This convention has developed because each bit has a physical location in a digital circuit; we know a particular bit is logic 0 because we can measure 0 V at a particular point in a circuit. A bit with a value of 0 doesn’t go away just because there is not a 1 at a more significant location.

While you are still learning to count in binary, you can use a second method.

2.Follow a simple repetitive pattern. Look at Tables 1.1 and 1.3 again. Notice that the least significant bit follows a pattern. The bits alternate with every line, producing the pattern 0, 1, 0, 1, . . . . The 2’s bit alternates every two lines: 0, 0, 1, 1, 0, 0, 1, 1, . . . . The 4’s bit alternates every four lines: 0, 0, 0, 0, 1, 1, 1, 1, . . . . This pattern can be expanded to cover any number of bits, with the number of lines between alternations doubling with each bit to the left.

Decimal-to-Binary Conversion

There are two methods commonly used to convert decimal numbers to binary: sum of powers of 2 and repeated division by 2.

Sum of Powers of 2

You can convert a decimal number to binary by adding up powers of 2 by inspection, adding bits as you need them to fill up the total value of the number. For example, convert 5710 to binary.

6410 5710 3210

We see that 32 ( 25) is the largest power of two that is smaller than 57. Set the 32’s bit to 1 and subtract 32 from the original number, as shown below.

57 32 25

The largest power of two that is less than 25 is 16. Set the 16’s bit to 1 and subtract 16 from the accumulated total.

25 16 9

8 is the largest power of two that is less than 9. Set the 8’s bit to 1 and subtract 8 from the total.

9 8 1

4 is greater than the remaining total. Set the 4’s bit to 0.

2 is greater than the remaining total. Set the 2’s bit to 0.

1.3 • The Binary Number System

9

1 is left over. Set the 1’s bit to 1 and subtract 1.

11 0

Conversion is complete when there is nothing left to subtract. Any remaining bits should be set to 0.

32

16

8

4

2

1

– 32 = 25

1

57

32

16

8

4

2

1

1

1

57

– (32

+ 16) = 9

32

16

8

4

2

1

1

1

1

57 – (32

+ 16 + 8) = 1

32

16

8

4

2

1

1

1

1

0

0

1

57 – (32

+ 16 + 8 + 1) = 0

5710 = 1110012

EXAMPLE 1.3

Convert 9210 to binary using the sum-of-powers-of-2 method.

SOLUTION

128 92 64

64

32

16

8

4

2

1

1

92 – 64 = 28

64

32

16

8

4

2

1

1

0

1

92 – (64 + 16) = 12

64

32

16

8

4

2

1

1

0

1

1

92 – (64 + 16 + 8) = 4

64

32

16

8

4

2

1

1

0

1

1

1

0

0

92 – (64 + 16 + 8 + 4) = 0

9210 = 10111002

Repeated Division by 2

Any decimal number divided by 2 will leave a remainder of 0 or 1. Repeated division by 2 will leave a string of 0s and 1s that become the binary equivalent of the decimal number. Let us use this method to convert 4610 to binary.

1. Divide the decimal number by 2 and note the remainder.

46/2 23 remainder 0 (LSB)

The remainder is the least significant bit of the binary equivalent of 46.

2.Divide the quotient from the previous division and note the remainder. The remainder is the second LSB.

23/2 11 remainder 1


10

C H A P T E R 1 • Basic Principles of Digital Systems

3.Continue this process until the quotient is 0. The last remainder is the most significant bit of the binary number.

11/2 5

remainder 1

5/2 2

remainder 1

2/2 1

remainder 0

1/2 0

remainder 1

(MSB)

To write the binary equivalent of the decimal number, read the remainders from the bottom up.

4610 1011102

EXAMPLE 1.4

Use repeated division by 2 to convert 11510 to a binary number.

SOLUTION

115/2 57 remainder 1 (LSB)

57/2

28 remainder 1

28/2

14

remainder 0

14/2 7

remainder 0

7/2 3

remainder 1

3/2 1

remainder 1

1/2 0 remainder 1 (MSB)

Read the remainders from bottom to top: 1110011.

11510 11100112

In any decimal-to-binary conversion, the number of bits in the binary number is the exponent of the smallest power of 2 that is larger than the decimal number.

For example, for the numbers 9210 and 4610,

27 128 92

7 bits: 1011100

26 64 46

6 bits: 101110

Fractional Binary Numbers

K E Y T E R M S

Radix point The generalized form of a decimal point. In any positional number system, the radix point marks the dividing line between positional multipliers that are positive and negative powers of the system’s number base.

Binary point A period (“.”) that marks the dividing line between positional multipliers that are positive and negative powers of 2 (e.g., first multiplier right of binary point 2 1; first multiplier left of binary point 20).

In the decimal system, fractional numbers use the same digits as whole numbers, but the digits are written to the right of the decimal point. The multipliers for these digits are negative powers of 10—10 1 (1/10), 10 2 (1/100), 10 3 (1/1000), and so on.

So it is in the binary system. Digits 0 and 1 are used to write fractional binary numbers, but the digits are to the right of the binary point—the binary equivalent of the decimal point. (The decimal point and binary point are special cases of the radix point, the general name for any such point in any number system.)


1.3 •

The Binary Number System

11

Each digit is multiplied by a positional factor that is a negative power of 2. The first

four multipliers on either side of the binary point are:

binary

point

23

22

21

20

2 1

2 2

2 3

2 4

8

4

2

1

1/2

1/4

1/8

1/16

EXAMPLE 1.5

Write the binary fraction 0.101101 as a decimal fraction.

SOLUTION

1 1/2 1/2

0 1/4 0

1 1/8 1/8

1

1/16 1/16

0

1/32 0

1

1/64 1/64

1/2 1/8 1/16 1/64 32/64 8/64 4/64 1/64

45/64

0.70312510

Fractional-Decimal-to-Fractional-Binary Conversion

Simple decimal fractions such as 0.5, 0.25, and 0.375 can be converted to binary fractions by a sum-of-powers method. The above decimal numbers can also be written 0.5 1/2, 0.25 1/4, and 0.375 3/8 1/4 1/8. These numbers can all be represented by negative powers of 2. Thus, in binary,

0.510 0.12

0.2510 0.012

0.37510 0.0112

The conversion process becomes more complicated if we try to convert decimal fractions that cannot be broken into powers of 2. For example, the number 1/5 0.210 cannot be exactly represented by a sum of negative powers of 2. (Try it.) For this type of number, we must use the method of repeated multiplication by 2.

Method:

1.Multiply the decimal fraction by 2 and note the integer part. The integer part is either 0 or 1 for any number between 0 and 0.999. . . . The integer part of the product is the first digit to the left of the binary point.

0.2 2 0.4

Integer part: 0

2.Discard the integer part of the previous product. Multiply the fractional part of the previous product by 2. Repeat step 1 until the fraction repeats or terminates.

0.4 2 0.8

Integer part: 0

0.8 2 1.6

Integer part: 1

0.6 2 1.2

Integer part: 1

0.2 2 0.4

Integer part: 0

(Fraction repeats; product is same as in step 1)


12

C H A P T E R 1 • Basic Principles of Digital Systems

Read the above integer parts from top to bottom to obtain the fractional binary number. Thus, 0.210 0.00110011 . . .2 0.00112. The bar shows the portion of the digits that repeats.

EXAMPLE 1.6

Convert 0.9510 to its binary equivalent.

SOLUTION

0.95 2 1.90

Integer part: 1

0.90 2 1.80

Integer part: 1

0.80 2 1.60

Integer part: 1

0.60 2 1.20

Integer part: 1

0.20 2 0.40

Integer part: 0

0.40 2 0.80

Integer part: 0

0.80 2 1.60 Fraction repeats last four digits

0.9510

0.1111002

SECTION 1.3 REVIEW PROBLEMS

1.2.How many different binary numbers can be written with 6 bits?

1.3.How many can be written with 7 bits?

1.4.Write the sequence of 7-bit numbers from 1010000 to 1010111.

1.5.Write the decimal equivalents of the numbers written for Problem 1.4.

1.4

TABLE 1.4 Hex Digits and

Their Binary and Decimal

Equivalents

Hex

Decimal

Binary

0

0

0000

1

1

0001

2

2

0010

3

3

0011

4

4

0100

5

5

0101

6

6

0110

7

7

0111

8

8

1000

9

9

1001

A

10

1010

B

11

1011

C

12

1100

D

13

1101

E

14

1110

F

15

1111

Hexadecimal Numbers

After binary numbers, hexadecimal (base 16) numbers are the most important numbers in digital applications. Hexadecimal, or hex, numbers are primarily used as a shorthand form of binary notation. Since 16 is a power of 2 (24 16), each hexadecimal digit can be converted directly to four binary digits. Hex numbers can pack more digital information into fewer digits.

Hex numbers have become particularly popular with the advent of small computers, which use binary data having 8, 16, or 32 bits. Such data can be represented by 2, 4, or 8 hexadecimal digits, respectively.

Counting in Hexadecimal

The positional multipliers in the hex system are powers of sixteen: 160 1, 161 16, 162 256, 163 4096, and so on.

We need 16 digits to write hex numbers; the decimal digits 0 through 9 are not sufficient. The usual convention is to use the capital letters A through F, each letter representing a number from 1010 through 1510. Table 1.4 shows how hexadecimal digits relate to their decimal and binary equivalents.

N O T E

Counting Rules for Hexadecimal Numbers:

1.Count in sequence from 0 to F in the least significant digit.

2.Add 1 to the next digit to the left and start over.

3.Repeat in all other columns.

For instance, the hex numbers between 19 and 22 are 19, 1A, 1B, 1C, 1D, 1E, 1F, 20, 21, 22. (The decimal equivalents of these numbers are 2510 through 3410.)