《数字电子技术英文.pptx》由会员分享,可在线阅读,更多相关《数字电子技术英文.pptx(67页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、2-1 DECIMAL NUMBERS十进制数第1页/共67页 Introductory ParagraphYou are familiar with the decimal number system because you use decimal numbers every day.Although decimal numbers are commonplace,their weighted structure is often not understood.In this section,the structure of decimal numbers is reviewed.Their
2、 review will help you more easily understand the structure of the binary number system,which is important in computers and digital electronics.第2页/共67页Decimal ReviewNumbers consist of a bunch of digits,each with a weight.These weights are all powers of the base,which is 10.We can rewrite this:To fin
3、d the decimal value of a number,multiply each digit by its weight and sum the products.第3页/共67页Nothing Special about 10!Decimal system(and the idea of“0”)was invented in India around 100-500AD.Why did they use 10?Anything special about it?Not really.Probably the fact that we have 10 fingers influenc
4、ed this.Will a base other than 10 work?Sure.What about base 2?第4页/共67页2-2 BINARY NUMBERS二进制数第5页/共67页 Introductory ParagraphThe binary number system is simply another way to represent quantities.The binary system is less complicated than the decimal system because it has only two digits.It may seem m
5、ore difficult at first because it is unfamiliar to you.The decimal system with its ten digits is a base-ten system;the binary system with its two digits is a base-two system.The two digits(bits)are 1 and 0.The position of a 1 or 0 in a binary number indicates its weight,or value within the number,ju
6、st as the position of a decimal digit determines the value of that digit.The weights in a binary number are based on powers of two.第6页/共67页 Counting in BinaryA binary count of 0 through 15 is shown below.As you will see,4 bits are required to count from 0 to 15.第7页/共67页 Counting Tennis Balls Going i
7、nto a box from a Conveyor BeltThe counter counts the pulses from a sensor that detects the passing of a ball and produces a sequence of logic levels(digital waveforms)on each of its four parallel outputs.Each set of logic levels represent a 4-bit binary number.The decoder decodes each set of four bi
8、ts and converts it to the corresponding decimal number in the 7-segment display.第8页/共67页 The Weighting Structure of Binary NumbersA binary number is a weighted number(加权数).The right-most bit is the LSB(最低有效位)in a binary whole number and has a weight of 20=1.The weights increase from right to left by
9、 a power of two for each bit.The left-most bit is the MSB(最高有效位).Fractional numbers(小数)can also be represented in binary by placing bits to the right of the binary point.The left-most bit is the MSB in a binary fractional number and has a weight of 2-1=0.5.The fractional weights decreases from left
10、to right by a negative power of two for each bit.The weight structure of a binary number is第9页/共67页 Binary-to Decimal ConversionThe decimal value of any binary number can be found by adding the weights of all bits that are 1 and discarding the weights of all bits that are 0.第10页/共67页2-3 DECIMAL-TO-B
11、INARY CONVERSION第11页/共67页Repeated Division-by-2 MethodA systematic method of converting whole numbers from decimal to binary is the repeated devision-by-2 process.第12页/共67页Repeated Multiplication-by-2 MethodA systematic method of converting fractional numbers from decimal to binary is the repeated m
12、ultiplication-by-2 process.第13页/共67页2-4 BINARY ARITHMETIC第14页/共67页Binary AdditionThe four basic rules for adding binary digits(bits)are as follows:0+0=0 Sum of 0 with a carry of 00+1=1 Sum of 1 with a carry of 01+0=1 Sum of 1 with a carry of 01+1=0 Sum of 0 with a carry of 1Example Add 1111 and 1100
13、.第15页/共67页Binary SubtractionThe four basic rules for subtraction binary digits(bits)are as follows:0-0=0 Difference of 0 with a borrow of 00-1=1 Difference of 1 with a borrow of 11-0=1 Difference of 1 with a borrow of 01-1=0 Difference of 0 with a borrow of 0Example Subtract 100 from 111.第16页/共67页Bi
14、nary MultiplicationThe four basic rules for multiplication binary digits(bits)are as follows:Example Multiply 1101 by 1010.第17页/共67页Binary DivisionDivision in binary follows the same procedure as division in decimal.Example Divide 1100 by 100.第18页/共67页2-5 1S AND 2S COMPLEMENTS OF BINARY NUMBERS二进制的反
15、码和补码第19页/共67页Finding the 1s Complement of a Binary NumberThe 1s complement of a binary number is found by changing all 1s to 0s and all 0s to 1s.Example Find the 1s complement of binary number 10110010.第20页/共67页Finding the 2s Complement of a Binary NumberThe 2s complement of a binary number is found
16、 by adding 1 to the 1s complement.Example Find the 2s complement of binary number 10110010.第21页/共67页2-6 SIGNED NUMBERS带符号数第22页/共67页The Sign BitThe left-most bit in a signed binary number is the sign bit,which tells you whether the number is positive or negative.A 0 is for positive,and a 1 is for neg
17、ative.第23页/共67页Sign-Magnitude SystemWhen a signed binary number is represented in sign-magnitude,the left-most bit is the sign bit and the remaining bits are the magnitude bits.The magnitude bits are in true(uncomplemented)binary for both positive and negative numbers.The decimal values are determin
18、ed by summing the weights in all the magnitude bit positions where there are 1s.The sign is determined by examination of the sign bit.第24页/共67页Sign-Magnitude SystemExample 2-15 Determine the decimal value of this signed binary number expressed in sign-magnitude:10010101.第25页/共67页1s Complement System
19、Positive numbers in the 1s complement system are represented the same way as the positive sign-magnitude numbers.Negative numbers,however,are the 1s complements of the corresponding positive numbers.nThe decimal values of positive numbers are determined by summing the weights in all bit positions wh
20、ere there are 1s.The decimal values of negative numbers are determined by summing the weights in all bit positions where there are 1s,and adding 1 to the result.The weight of the sign bit is given a negative value.第26页/共67页1s Complement SystemWhy?第27页/共67页1s Complement SystemExample 2-16 Determine t
21、he decimal value of the signed binary numbers expressed in 1s complement:(a)00010111 (b)11101000.第28页/共67页2s Complement SystemPositive numbers in the 2s complement system are represented the same way as in sign-magnitude and 1s complement systems.Negative numbers are the 2s complements of the corres
22、ponding positive numbers.The decimal values are determined by summing the weights in all bit positions where there are 1s.The weight of the sign bit is given a negative value.第29页/共67页2s Complement SystemExample 2-17 Determine the decimal value of the signed binary numbers expressed in 2s complement
23、:(a)01010110 (b)10101010.第30页/共67页2s Complement AdvantageTo convert to decimalThe 2s complement system simply requires a summation of weights regardless of whether the number is positive or negative.The sign-magnitude system requires two steps sum the weights of the magnitude bits and examine the si
24、gn bit to determine if the number is positive or negative.The 1s complement system requires adding 1 to the summation of weights for negative numbers but not for positive numbers.Also,the 1s complement system is not used because two representations of zero(00000000 or 11111111)are possible.第31页/共67页
25、The DevelopmentThe 2s complement of an n-bit number x is defined byFor example,if n=8,then第32页/共67页The Developmentand1s complement第33页/共67页Range of Signed Integer NumbersThe number of different combinations of n bits isFor 2s complement signed numbers,the range of value for n-bit numbers is第34页/共67页
26、By the WayThe 8-bit grouping has been given the special name byte.Bit GroupingBit GroupingNameName4-bit4-bitNibbleNibble8-bit8-bitByteByte16-bit16-bitWordWord32-bit32-bitDouble wordDouble word第35页/共67页Floating-Point Numbers(浮点数)Not required!第36页/共67页2-7 ARITHMETIC OPERATIONS WITH SIGNED NUMBERS带符号数的
27、算术运算第37页/共67页Addition(加法)The two numbers in an addition are the addend(加数)and the augend(被加数).The results are the sum(和)and the carry(进位).The addition process is stated as follows:add the two numbers and discard any final carry bit.Example(a)00000111+00000100=?(b)00001111+11111010=?(c)00010000+11101
28、000=?(d)11111011+11110111=?第38页/共67页Overflow Condition(溢出条件)When two numbers are added and the number of bits required to represent the sum exceeds the number of bits in the two numbers,an overflow results as indicated by an incorrect sign bit.An overflow can occur only when both numbers are positiv
29、e or both numbers are negative.Example(a)01111101+00111010=?(b)10001000+11101101=?第39页/共67页Subtraction(减法)The two numbers in a subtraction are the subtrahend(减数)and the minuend(被减数).The results are the difference(差)and the borrow(借位).The subtraction process is stated as follows:take the 2s complemen
30、t of the subtrahend and add.Disiscard any final carry bit.Example(a)0001000-00000011=?(b)11100111-00010011=?第40页/共67页Multiplication(乘法)The two numbers in a multiplication are the multiplier(乘数)and the multiplicand(被乘数).The result is the product(积).The multiplication operation in most computers is ac
31、complished using partial product method(部分积方法).The basic steps in the process are as follows:Determine if the signs of the two numbers are the same.This determines what the sign of the product will be.Change any negative number to true(uncomplemented)form.Starting with the LSB of the multiplier,gene
32、rate the partial products.Shift each successive partial product one bit to the left.Add each partial product to the sum of the previous partial products to get the final product.If the sign of the product is negative,take the 2s complement of the product.Attach the sign bit to the product.第41页/共67页M
33、ultiplicationExample 2-22 Multiply the signed binary number 01010011 and 11000101.第42页/共67页Division(除法)The two numbers in a division are the divisor(除数)and the dividend(被除数).The results are the quotient(商)and the remainder(余数).The basic steps in a division the process are as follows:Determine if the
34、 signs of the two numbers are the same.This determines what the sign of the quotient will be.Initialize the quotient to zero and initialize the partial remainder to the dividend.Subtract the divisor from the partial remainder using 2s complement addition to get the next partial remainder.If the resu
35、lt is positive,add 1 to the quotient and repeat for the next partial remainder;otherwise,the division is complete.第43页/共67页DivisionExample 2-23 Divide 01100100 by 00011001.第44页/共67页2-8 HEXADECIMAL NUMBERS(十六进制数)第45页/共67页Why Hexadecimal?As you are probably aware,long binary numbers are difficult to r
36、ead and write because it is easy to drop or transpose a bit.Since computers and microprocessors understand only 1s and 0s,it is necessary to use these digits when you program in machine language.The hexadecimal number system has 16 digits and is used primarily as a compact way of displaying or writi
37、ng binary numbers because it is very easy to convert between binary and hexadecimal.10 numeric digits(0,1,2,3,4,5,6,7,8,9)and 6 alphabetic characters(A,B,C,D,E,F)make up the hexadecimal number system.第46页/共67页Relationship between hexadecimal and binaryEach hexadecimal digit represents a 4-bit binary
38、 number.第47页/共67页Binary-to-Hexadecimal ConversionVery straightforward!Simply break the binary number into 4-bit groups,starting at the right-most bit and replace each 4-bit group with the equivalent hexadecimal symbol.Example 2-24 Convert the following binary numbers to hexadecimal:第48页/共67页Hexadeci
39、mal-to-Binary ConversionVery straightforward!Simply replace each hexadecimal symbol with the equivalent 4-bit group.Example 2-25 Determine the binary numbers for the following hexadecimal numbers:(a)10A4h (b)CF8Eh (c)9742h第49页/共67页Hexadecimal-to-Decimal ConversionMultiply the decimal value of each h
40、exadecimal digit by its weight and then take the sum of these products.Example 2-27 Convert the following hexadecimal numbers to decimal:(a)E5h (b)B2F8h第50页/共67页Decimal-to-Hexadecimal ConversionRepeated division of a decimal number by 16 will produce the equivalent hexadecimal number.Example 2-28 Co
41、nvert the decimal number 650 to hexadecimal by repeated division by 16.第51页/共67页2-10 BINARY CODED DECIMAL(BCD)第52页/共67页Introductory ParagraphBinary coded decimal(BCD)is a way to express each of the decimal digits with a binary code.Since there are only ten code groups in the BCD system,it is very ea
42、sy to convert between decimal and BCD.Because we like to read and write in decimal,the BCD code provides an excellent interface to binary systems.Examples of such interfaces are keypad inputs and digital readouts.第53页/共67页The 8421 CodeThe 8421 code is a type of BCD code.BCD means that each decimal d
43、igit,0 through 9,is represented by a binary code of four bits.The designation 8421 indicates the binary weights of the four bits.1010,1011,1100,1101,1110,and 1111 are invalid codes.The 8421 code is the predominant BCD code,and when we refer to BCD,we always mean the 8421 code unless otherwise stated
44、.第54页/共67页The 8421 CodeTo express any decimal number in BCD,simply replace each decimal digit with the appropriate 4-bit code.Example 2-33 Convert each of the following decimal numbers to BCD.(a)35(b)98(c)170(d)2469To determine a decimal number from a BCD number,start at the right-most bit and break
45、 the code into groups of four bits,then write the decimal digit represented by each 4-bit group.Example 2-34 Convert each of the following BCD codes to decimal:第55页/共67页BCD AdditionBCD is a numerical code and can be used in arithmetic operations.Here is how to add two BCD numbers:Add the two BCD num
46、bers,using the rules for binary addition.If a 4-bit sum is equal to or less than 9,it is a valid BCD number.If 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 4-bit sum in order to skip the six invalid codes and returned the c
47、ode to 8421.If a carry results when 6 is added,simply add the carry to the next 4-bit group.Example Add the BCD numbers:00010110+00010101.第56页/共67页2-11 DIGITAL CODES AND PARITY数字编码和奇偶校验第57页/共67页Introductory ParagraphThere are many specialized codes used in digital systems.You have just learned about
48、 the BCD code;now lets look at a few others.Some codes are strictly numeric,like BCD,and others are alphanumeric;that is,they are used to represent numbers,letters,symbols,and instructions.The code introduced in this section are the Gray code and the ASCII code.Also,the detection of errors in codes
49、using a parity bit is covered.第58页/共67页The Gray Code(格雷码)The Gray code is unweighted and is not an arithmetic code;that is,there are no specific weights assigned to the bit positions.The important feature of the Gray code is that it exhibits only a single bit change from one code number to the next.
50、相邻码第59页/共67页Binary-to-Gray code ConversionThe MSB in the Gray code is the same as the corresponding MSB in the binary number.Going from left to right,add each adjacent pair of binary code bits to get the next Gray code bit.Discard carries.第60页/共67页Gray-to-Binary ConversionThe MSB in the binary code