1 / 51

Chapter 1 Binary Systems

Chapter 1 Binary Systems. 1-1 Digital Systems. 1-2 Binary Numbers. 1-3 Number Base Conversions. 1-4 Octal and Hexadecimal Numbers. 1-5 Complements. Chapter 1 Binary Systems. 1-6 Signed Binary Numbers. 1-7 Binary Codes. 1-8 Binary Storage and Registers. 1-9 Binary Logic.

Chapter 1 Binary Systems

E N D

Presentation Transcript

1. Chapter 1Binary Systems 1-1 Digital Systems 1-2 Binary Numbers 1-3 Number Base Conversions 1-4 Octal and Hexadecimal Numbers 1-5 Complements

2. Chapter 1Binary Systems 1-6 Signed Binary Numbers 1-7 Binary Codes 1-8 Binary Storage and Registers 1-9 Binary Logic

3. 1-1 Digital Systems Video Recordings Telephone System Digital Computers HDL (Hardware Description Language)

4. 1-1 Digital Systems Video and Audio Recordings

5. 1-1 Digital Systems Digital Computers

6. 1-1 Digital Systems Telephone System ZXJ10 digital SPC Switch

7. 1-1 Digital Systems HDL (Hardware Description Language) //Gate-level description of a 2-to-4-line //decoder Module decoder_g1 (A,B,E,D) input A,B,E; output [0:3] D; wire Anot,Bnot,Enot; not n1 (Anot,A), n2 (Bnot,B), n3 (Enot,E); nand n4 (D[0],Anot,Bnot,Enot), n5 (D[1],Anot,B,Enot), n6 (D[2],A,Bnot,Enot), n7 (D[3],A,B,Enot); endmodule

8. weight weight weight weight weight 1-2 Binary Numbers • Decimal Numerical Presentations =5102+4 101+3 100+ 2 10-1+1 10-2 (543.21)10 Each weight is a power of 10 corresponding to the digit’s position. 1) In such a positional-value system, a number is represented by a string of digits where each digit position has an associated weight.

9. 1-2 Binary Numbers • Decimal Numerical Presentations In general, a number D of the form d1d0.d-1d-2 has the value D = d1·101 + d0·100 + d–1·10–1 + d–2·10–2 Here, 10 is called the base or radix of the number system. In a general positional number system, the radix may be any integer r ≥2.

10. The coefficients aj range in value from 0 to r-1. 1-2 Binary Numbers • Base-r System A number expressed in a base-r system has coefficients multiplied by the corresponding power of the radix r: an · rn+an-1 · rn-1 +…+a1 ·r1 +a0 + a-1 · r-1 + …+a-m · r-m

11. 1-2 Binary Numbers • Binary Number System When dealing with binary and other nondecimal numbers, we use a subscript to indicate the radix of each number, unless the radix is clear from the context. The general form of a binary number is bp-1 bp-2 …b1 b0 . b-1 b-2 b-n And it value is (N)2=(Kn-1  K1 K0. K-1 K-m)2 =Kn-1 2n-1++K121+K020+K-1 2-1+K-m 2-m

12. 1-3 Number Base Conversions Conversions between Decimal and otherNumber Systems Decimal No-decimal No-decimal Decimal Conversions between Non-decimalNumber Systems Binary Octal and hexadecimal Octal and hexadecimal Binary

13. 1-3 Number Base Conversions • Decimal-to-Binary Conversion Repeated Division-by-2 Method: The conversion requires repeatedly dividing the decimal number by 2 and writing down the remainder after each division until a quotient of 0 is obtained. Note that the binary result is obtained by writing the first remainder as the LSB and the last remainder as the MSB.

14. 81 2 2 2 2 2 2 2 1-3 Number Base Conversions • Decimal-to-Binary Conversion Example：（81）10=（？）2 0 1 2 5 10 20 40 1 0 1 0 0 1 0 K6 K5 K4 K3 K2 K0 K1 Hence （81）10 =（1010001）2

15. 2 1 0 1 0 0 2 2 2 2 1-3 Number Base Conversions Conversion in the fractional part Example： （0.65）10 =( ? )2 precision limited to five digits. 0.65 0.3 0.6 0.2 0.4 0.8 Repeated Multiplication by 2 K-1 K-2 K-3 K-4 K-5 So：(0.65)10=(0.10100)2 Hence：(81.65)10=(1010001.10100)2

16. 359 8 8 8 1-3 Number Base Conversions Decimal-to-Octal Conversion Example：（359）10=（？）8 0 5 44 5 7 4 K2 K0 K1 Hence （359）10 =（547）8

17. 8 4 0 6 1 5 8 8 8 8 1-3 Number Base Conversions  Conversion in the fractional part Example： （0.65）10 =( ? )2 precision limited to five digits. 0.513 0.104 0.832 0.656 0.248 0.984 K-1 K-2 K-3 K-4 K-5 So：(0.513)10=(0.40651…)8 Hence：(359.513)10=(547.40651) 8

18. 1-3 Number Base Conversions  Non-Decimal to Decimal Conversions A non-decimal number can easily be converted to its decimal equivalent by multiplying each digit by its positional weight. method： (F8C.B)16 =F×162+8×161+C×160+B×16-1 =3840+128+12+0.6875 =3980.6875 Example：

19. 1-4 Octal and Hexadecimal Numbers • Binary-to-Octal Conversion The bits of the binary number are grouped into groups of three bits starting at the LSB in the integer part and at MSB in the fractional part. Then each group is converted to its octal equivalent. Note that a zero was placed to the left of the MSB of the integer part and two zeros were placed to the right of LSB of the fractional part to produce even groups of three bits. Example 11010111.0100111 B = ? (8) 11010111.0100111 B = 327.234(8)

20. 1-4 Octal and Hexadecimal Numbers  Binary-to-Hexadecimal Conversion The bits of the binary number are grouped into groups of four bits starting at the LSB in the integer part and at MSB in the fractional part. Then each group is converted to its hexadecimal equivalent. Example 9： 111011.10101 B = ? H 111011.10101 B = 3B.A8 H

21. 1-4 Octal and Hexadecimal Numbers Numbers with Different Bases

22. 1-5 Complements • 1’s Complement Form: The 1’s complement of a binary number is obtained by changing each 0 to a 1 and each 1 to a 0. In other words, changing each bit in the number to its complement. 101101 Original Number: 010010 1’s Complement

23. 1-5 Complements • 2’s Complement Form: The 2’ complement of a binary number is formed by taking 1’s complement of the number and adding 1 to the least-significant-bit position. 1101100 Original Number: 0010100 2’s Complement:

24. 1-5 Complements • Subtraction with Complements 1’s complement of -3 End-around carry + 4 0100 - + 3 + 1101 + 1 1 0001 + 4 0100 - + 3 + 1100 + 1 1 0000 + 1 Answer: 0001 Answer: 0001 2’s complement of -3 Discard end carry

25. 1-6 Signed Numbers • Signed Binary Numbers and Sign-Magnitude System Leftmost bit: “0” presents “+” “1” presents “-” X2 = - 1 1 0 1 1 0 1 X1 = + 1 1 0 1 1 0 1 In the Sign-Magnitude System, a negative number has the same magnitude bits as the corresponding number but the sign bit is a 1 rather than a zero.

26. signed-magnitude representation: • 10001001 signed -1’s-Complement representation: 11110110 signed -2’s-Complement representation: 11110111 1-6 Signed Numbers As an example, consider the number 9 represented in binary with eight bits. Although there is only one way to represent +9, there are three different ways to represent –9 with eight bits:

27. The 1’s complement 1-6 Signed Numbers Awkward ordinary arithmetic The signed-magnitude system computer arithmetic The following discussion of signed binary arithmetic deals exclusivelywith the signed 2’s complement presentation of negative numbers. Imposes some difficulties and is seldom used

28. “0” represented by 2’s-complement form [+00…0]2’s-complement = [-00…0] 2’s-complement = 0 000…0 • A n-magnitude-bit number in 2’s-complement systems: +(2n-1-1）≤[X] 2’s-complement ≤-2n-1 For instance, if n = 8，the binary code is from 01111111 to 10000000 (+127～-128 in decimal) • [X1]2’s-complement +[X2]2’s-complement = {X1+X2}2’s-complement 1-6 Signed Numbers Properties of 2’s-complement form

29. 1-6 Signed Numbers Example: Perform the following subtraction of the signed numbers: 00001000 -00000011 Solution: In this case, 8 – 3 = 8 + ( – 3) = 5 00001000 + 11111101 1 00000101 Minuend ( + 8) 2's complement of subtrahend ( -3) Difference ( + 5 ) Discard Carry

30. 1-6 Signed Numbers • Negation: In the 2’s-complement system, negation is performed simply by performing the 2’s-complement operation. Negation is the operation of converting a positive number to its negative equivalent or a negative number to its positive equiment. = +9 Start with: 01001 2’s complement (negation): 10111 = - 9 = +9 Negation again: 01001 Thus, we negate a signed binary number by 2’s complement it.

31. 1-7 Binary Codes • Binary Coded Decimal (BCD) Code The 8421 code is the predominant BCD code. When we refer to BCD, we always mean the 8421 code unless otherwise stated. The 8421 code is a type of BCD code. Binary coded decimal means that each decimal digit, 0 through 9, is represented by a binary code of four bits. The designation of 8421 indicates that binary weights of the four bits(23, 22, 21, 20)

32. 1-7 Binary Codes To express any decimal number in BCD, simply replace each decimal digit with the appropriate 4-bit code, as shown below. Example：（276.8）10 =（ ？ ）BCD 2 7 6 8 ↓ ↓ ↓ ↓ 0010 0111 0110 1000 （276.8）10 =（001001110110.1000)BCD

33. 1-7 Binary Codes • BCD Addition Here is how to add two BCD number Step 1: add the two BCD numbers, using the rules for binary addition. Step 2: if a 4-bit sum is equal to or less than 9, it is a valid BCD number. Step 3: if a a 4-bit sum is greater than 9, or if a carry out of the 4-bit group is generated, it is an invalid result. Add 6 (0110) to the sum in order to skip the six invalid states and return the code to 8421.

34. 1-7 Binary Codes Right group is invalid (>9), left group is valid. Add 6 to invalid code. Add carry, 0001, to next group. Invalid BCD number (>9) Example: add the following BCD numbers: (a) (b) 0111 0001 0110 + 0100 + 0001 0101 1011 0010 1011 + 0110 + 0110 0001 0011 0011 0001 Add 6 Valid BCD number Valid BCD number

35. 1-7 Binary Codes  Gray Code The Gray Code is unweighted and is not arithmetic code; There is only one bit difference between the adjacent numbers. This property is important in many applications, such as shaft position encoders, where error susceptibility increases with the number of bit changes between adjacent numbers in sequence.

36. 1-7 Binary Codes • Excess-3 code The excess-3 codetakes ten groups of binary codes which is obtained from the corresponding binary value plus 3. • ASCII Code (American Standard Code for Information Interchange) The ASCII code is a seven-bit code, so it has 128 possible code groups to represent letters, of the alphabet, punctuation marks, and other special characters as well as number.

37. 1-7 Binary Codes A given system operates with even or odd parity, but not both.  Error-Detecting Code Parity Method for Error Detection A parity bit is attached to a group of bits to make the total number of 1s in a group always even or always odd. The parity bit can be attached to the code at either the beginning or the end, depending on system design.

38. 1-7 Binary Codes Example: Now let us assume that an error occurs in the third bit from the left (the 1 becomes a 0) as follows, even parity bit Let us assume that we wish to transmit the BCD code 0101. The total code transmitted, including the even parity bit, is 00001 00101 When this code is received, the parity check circuitry determines that there is only a single 1 (odd number), when there should be an even number of 1s. Because an even number of 1s does not appear in the code when it is received , an error is indicated. BCD code Bit error

39. 1-8 Binary Storage and Registers • Registers A register is a group of binary cells that possesses two stable states and is capable of storing one bit of information. A register transfer operation is a basic operation in digital systems. It consists of a transfer of binary information from one set of registers into another set of registers.

40. 1-8 Binary Storage and Registers • Register Transfer Transfer of information with registers

41. 1-8 Binary Storage and Registers • Register Transfer Example of binary information processing

42. 1-9 Binary Logic • Definition of Binary Logic Boolean constants and variables have only two possible values, 0 or 1. Boolean 0 and 1 don’t present actual numbers but instead present two states that are contradictory to each other.

43. 1-9 Binary Logic • Definition of Binary Logic NOT: the NOT operation changes one logic level to the opposite logic level. AND: the AND operation produces a HIGH output only if all the inputs are HIGH. OR: the OR operation produces a HIGH output when any of the inputs is HIGH.

44. 1-9 Binary Logic Truth Table of Logic Operation

45. 1-9 Binary Logic • Logic Gates AND Gates OR Gates NOT Gates Logic level for typical CMOS logic circuits

46. AND gate symbol A B F 0 0 0 0 1 0 1 0 0 1 1 1 Boolean Expression F= A  B = AB 1-9 Binary Logic • AND Gates Truth table

47. A B F 0 0 0 0 1 1 1 0 1 1 1 1 Boolean Expression: F= A +B N Inputs： LogicSymbol 1-9 Binary Logic • OR Gates Truth Table F= A+B+ ...+ N

More Related