计算机原理Chapter3
- 格式:pdf
- 大小:1.86 MB
- 文档页数:124
《计算机科学导论》课后练习(翻译)Chapter 1 练习复习题1.定义⼀个基于图灵模型的计算机。
答:Turing proposed that all kinds of computation could be performed by a special kind of a machine. He based the model on the actions that people perform when involved in computation. He abstracted these actions into a model for a computational machine that has really changed the world.图灵模型假设各种各样的运算都能够通过⼀种特殊的机器来完成,图灵机的模型是基于各种运算过程的。
图灵模型把运算的过程从计算机器中分离开来,这确实改变了整个世界。
2.定义⼀个基于冯·诺伊曼模型的计算机。
答:The von Neumann Model defines the components of a computer, which are memory, the arithmetic logic unit (ALU), the control unit and the input/output subsystems.冯·诺伊曼模型定义了计算机的组成,它包括存储器、算术逻辑单元、控制单元和输⼊/输出系统。
3.在基于图灵模型的计算机中,程序的作⽤是什么?答:Based on the Turing model a program is a set of instruction that tells the computer what to do.基于图灵模型的计算机中程序是⼀系列的指令,这些指令告诉计算机怎样进⾏运算。
4.在基于冯·诺伊曼模型的计算机中,程序的作⽤是什么?答:The von Neumann model states that the program must be stored in the memory. The memory of modern computers hosts both programs and their corresponding data. 冯·诺伊曼模型的计算机中,程序必须被保存在存储器中,存储程序模型的计算机包括了程序以及程序处理的数据。
Chapter3 THE DATA LINK LAYER2.The following data fragment occurs in the middle of a data stream for which thebyte-stuffing algorithm described in the text is used: A B ESC C ESC FLAG FLAG D. What is the output after stuffing?Answer:A B ESC C ESC FLAG FLAG D ==> A B ESC ESC C ESC ESC ESC FLAG ESC FLAG D3.What is the maximum overhead in byte-stuffing algorithm?Answer :This a frame delimited by flag bytes. (Ignore the header and trailer)Suppose that there is x bytes in payload field, and the worst case is that all of them are flag bytes or ESC, there should be 2x bytes in total. So the max overhead in byte-stuffing should be: 2+x x+1+111111lim=lim =lim +=+lim =2+2x 2x+122x+122x+12x x x x →∞→∞→∞→∞()()()() Or: (from 袁子超)if it has n bytes to send, and has m ESC. So the overhead is :.If the n bytes are all ESC, the overhead is maximum as :FLAG FLAG Payload field4.When bit stuffing is used, is it possible for the loss, insertion, or modification of a single bit to cause an error not detected by the checksum? If not, why not? If so, how? Does the checksum length play a role here?Answer:It is possible. Suppose that the original text contains the bit sequence 01111110 as data. After bit stuffing, this sequence will be rendered as 011111010. If the second 0 is lost due to a transmission error, what is received is 01111110, which the receiver sees as end of frame. It then looks just before the end of the frame for the checksum and verifies it. If the checksum is 16 bits, there is 1 chance in 216 that it will accidentally be correct, leading to an incorrect frame being accepted. The longer the checksum, the lower the probability of an error getting through undetected, but the probability is never zero.6.To provide more reliability than a single parity bit can give, an error-detecting coding scheme uses one parity bit for checking all the odd-numbered bits and a second parity bit for all the even-numbered bits. What is the Hamming distance of this code?Answer:Any single-bit error in the odd-numbered bits could change parity bit. It’s the same as the even-numbered bits. And both two errors occur in the odd-numbered bits or in the even-numbered bits will not change the parity bit. That is to say , this code could only detect single-bit errors, which means the Hamming distance is 2.7.An 8-bit byte with binary value 10101111 is to be encoded using an even-parity Hamming code. What is the binary value after encoding?According to rr m 2)1(≤++,m=8 r=4P1=B1⊕B3⊕B5⊕B7⊕B9⊕B11 =∑(0,1,0,0,1,1)=1P2=B2⊕B3⊕B6⊕B7⊕B10⊕B11=∑(0,1,1,0,1,1)=0P3=B4⊕B5⊕B6⊕B7 ⊕B12 =∑(0,0,1,0,1)=0P4=B8⊕B9⊕B10⊕B11⊕B12 =∑(0,1,1,1,1)=0So, Hamming code is: 10100100111113.Suppose that a message 1001 1100 1010 0011 is transmitted using Internet Checksum (4-bit word). What is the value of the checksum?Solution:100111001010+ 0011---------------------------------0010 (have 2 added bit),so:+1+1----------------------------------0100So, the Internet checksum is the ones complemnet of 0100, or 1011.14.What is the remainder obtained by dividing 751x x ++by the generator polynomial 31x +?42375745452424211111x x xx x x x x x x x x x x x xx x ++++++++++++++The remainder is 21x x ++.15.A bit stream 10011101 is transmitted using the standard CRC method described in the text. Thegenerator polynomial is ,. Show the actual bit string transmitted. Suppose that the third bit from the left is inverted during transmission. Show that this error is detected at the receiv er’s end. Give an example of bit errors in the bit string transmitted that will not be detected by the receiver.Solution:(1)→100110011101000 mod 1001 = 100The actual bit string transmitted: 10011101000+100=10011101100(2) The bit string receiver receives :10011101100→10111101100 10111101100 mod 1001 = 100 ≠ 0 →error!(3)example: 10011101100→1001111010110011110101 mod 1001 = 0So the receiver may think that the received bit string is right while it ’s wrong in fact.Data link protocols almost always put the CRC in a trailer than in a header. Why? Answer:CRC is calculated during sending. It could be appended to the data bit string as soon as the last data bit is send to the path. If it is put in the header, it must scan the whole frame in order to calculate CRC. It means that we should dispose the code 2 times. And CRC in the trailer could help to drop the half time.Or: (from 袁子超)CRC calculate during transmission. Once the last data sent out line, immediately put CRC code attached to the output stream from the back. If put CRC on the head of the frame, then we should check the frame to calculate CRC before sending. So that each byte has to deal with two times, the first is to calculate the check code, second times to send. Put CRC in the tail of the processing time can be halved.20.A 3000-km-long T1 trunk is used to transmit 64-byte frames using protocol 5. If the propagat ion speed is 6 μsec/km, how many bits should the sequence numbers be? Solution:delay= 3000-km* 6 μsec/km=18msBecause the bandwidth of T1 trunk = 1.544Mbps ,so:send time=64*8bits/1.544Mbps=0.33msthe time of send a frame and receive the acknowledge frame=18ms+0.33ms+18ms=36.33msthe number of frames: 36.33ms/0.33ms=11064=≤110≤=128sequence number should be 7 bitsFrames of 1000 bits are sent over a 1-Mbps channel using a geostationary satellite whose propagation time from the earth is 270 msec. Acknowledgements are always piggybacked onto data frames. The headers are very short. Three-bit sequence numbers are used. What is the maximum achievable channel utilization for(a) Stop-and-wait?(b) Protocol 5?(c) Protocol 6?Solution:Time for send a frame is: 1000bits/(1Mbps)=1msRound trip time: R=270ms*2=540msIt takes R+2=542ms to send a frame (be acknowledged).Therefore, a transmission cycle is 542ms. If the 542ms can send w frame, as a result of each frame transmission time is 1ms, the channel utilization rate is w/542.Three-bit sequence numbers are used, so the max window for (a),(b),(c) are :(a):W=1(b)1<W≤-1=7 →W=7(c)W≤=4→W=4So line utilization rate is: (a) 1*1ms/542ms * 100%=0.184%(b)7*1ms/542ms * 100%=1.292%(c)4*1ms/542ms*100%=0.738%30.Consider an error-free 64-kbps satellite channel used to send 512-byte data frames in one direction, with very short acknowledgements coming back the other way. What is the maximum throughput for window sizes of 1, 7, 15, and 127? The earth-satellite propagation time is 270 msec.Solution:Time for send a frame: 512*8bits/64kbps=64msSo, a transmission cycle: T=270ms*2+64ms=604ms and transmission window is:604ms/64ms=9.4,that’s mean: if w>9 the channel is full, the throughput cannot rise,(1)W=1: throughout=512*8b/604ms=6781bps=6.78kbps(2)W=7: throughout=7*512*8b/604ms=47.47kbps(3)(4) 15>9&&127>9, so throughout= 64kbps32.Give at least one reason why PPP uses byte stuffing instead of bit stuffing to prevent accidental flag bytes within the payload from causing confusion.Answer:(1) PPP was clearly designed to be implemented in software, not in hardware as HDLC nearly always is. With a software implementation, working entirely with bytes is muc h simpler than working with individual bits.(2) PPP was designed to be used with modems, and modems accept and transmit data in units of 1 byte, not 1 bit.33. What is the minimum overhead to send an IP packet using PPP? Count only the overhead introduced by PPP itself, not the IP header overhead. What is the maximum overhead?Solution:the PPP full frame format for unnumbered mode is:And Address and control could be ignored if sender and receiver have approve it.The minimum overhead=1+1+2+1=5bytesThe maximum overhead=1+1+1+2+4+1=10bytes。
Chapter 3 Boolean Algebra and Digital Logic•Understand the relationship between Boolean logic and digital computer circuits.•Learn how to design simple logic circuits.•Understand how digital circuits work together to form complex computer systems.23•In the latter part of the nineteenthcentury, George Boole incensedphilosophers and mathematiciansalike when he suggested that logicalthought could be representedthrough mathematical equations.How dare anyone suggest that human thought could be encapsulated and manipulated like an algebraic formula?4•Computers, as we know them today, are implementations of Boole’s Laws of Thought .–John Atanasoff and Claude Shannon were among the first tosee this connection.John Atanasoff Claude Shannon•In the middle of the twentieth century, computers were commonly known as “thinking machines” and “electronic brains.”–Many people were fearful of them.•Nowadays, we rarely ponder the relationship between electronic digital computers and human logic. Computers are accepted as part of our lives.–Many people, however, are still fearful of them.•In this chapter, you will learn the simplicity that constitutes the essence of the machine.5•Boolean algebra is a mathematical system for the manipulation of variables that can have one of two values.–In formal logic, these values are “true” and “false.”–In digital systems, these values are “on” and “off,”1 and 0, or “high” and “low.”•Boolean expressions are created by performing operations on Boolean variables.–Common Boolean operators include AND, OR, andNOT.67•The truth table for the Booleanoperators AND is shown at theright.•The AND operator is also knownas a Boolean product.• A Boolean operator can be completely described using a truth table.8•The truth table for the Booleanoperators OR is shown at theright.•The OR operator is the Booleansum.•The truth table for the Boolean NOT operator is Array shown at the right.•The NOT operation is most often designated by an overbar. It is sometimes indicated by a prime mark( ‘ ) or an “elbow” ( ).910• A Boolean function has:•At least one Boolean variable, •At least one Boolean operator, and •At least one input from the set {0,1}.•It produces an output that is also a member of the set {0,1}.Now you know why the binary numberingsystem is so handy in digital systems.11•The truth table for theBoolean function:is shown at the right.•To make evaluation of theBoolean function easier,the truth table containsextra (shaded) columns tohold evaluations ofsubparts of the function.12•As with commonarithmetic, Booleanoperations have rules ofprecedence.•The NOT operator hashighest priority, followedby AND and then OR.•This is how we chose the(shaded) functionsubparts in our table.•Digital computers contain circuits that implement Boolean functions.•The simpler that we can make a Boolean function, the smaller the circuit that will result.–Simpler circuits are cheaper to build, consume less power, and run faster than complex circuits.•With this in mind, we always want to reduce our Boolean functions to their simplest form.•There are a number of Boolean identities that help us to do this.1314•Most Boolean identities have an AND (product) form as well as an OR (sum) form. We give our identities using both forms. Our first group is ratherintuitive:15•Our second group of Boolean identities should be familiar to you from your study of algebra:16•Our last group of Boolean identities are perhaps the most useful.•If you have studied set theory or formal logic, these laws are also familiar to you.17•We can use Boolean identities to simplify the function:as follows:18•Sometimes it is more economical to build a circuit using the complement of a function (and complementing its result) than it is to implement the function directly.•DeMorgan’s law provides an easy way of finding the complement of a Boolean function.•Recall DeMorgan’s law states:1920•DeMorgan’s law can be extended to any number of variables.•Replace each variable by its complement and change all ANDs to ORs and all ORs to ANDs.•Thus, we find the the complement of:is:•Through our exercises in simplifying Boolean expressions, we see that there are numerous ways of stating the same Boolean expression.–These “synonymous” forms are logically equivalent.–Logically equivalent expressions have identical truthtables.•In order to eliminate as much confusion as possible, designers express Boolean functions in standardized or canonical form.2122•There are two canonical forms for Boolean expressions: sum-of-products and product-of-sums.–Recall the Boolean product is the AND operation and the Boolean sum is the OR operation.•In the sum-of-products form, ANDed variables are ORed together.–For example:•In the product-of-sums form, ORed variables are ANDed together:–For example:23•It is easy to convert a functionto sum-of-products form usingits truth table.•We are interested in the valuesof the variables that make thefunction true (=1).•Using the truth table, we listthe values of the variables thatresult in a true function value.•Each group of variables is thenORed together.24•The sum-of-products formfor our function is:We note that this function is not insimplest terms. Our aim is only torewrite our function in canonicalsum-of-products form.•We have looked at Boolean functions in abstract terms.•In this section, we see that Boolean functions are implemented in digital computer circuits called gates.• A gate is an electronic device that produces a result based on two or more input values.–In reality, gates consist of one to six transistors, but digitaldesigners think of them as a single unit.–Integrated circuits contain collections of gates suited to aparticular purpose.2526•The three simplest gates are the AND, OR, and NOT gates.•They correspond directly to their respective Boolean operations, as you can see by their truth tables.•Another very useful gate is the exclusive OR (XOR) gate.•The output of the XOR operation is true only when the values of the inputs differ.Note the special symbolfor the XOR operation.2728•NAND and NORare two veryimportant gates.Their symbols andtruth tables areshown at the right.29•NAND and NORare known asuniversal gatesbecause they areinexpensive tomanufacture andany Booleanfunction can beconstructed usingonly NAND or onlyNOR gates.•Gates can have multiple inputs and more than one output.–A second output can be provided for the complementof the operation.–We’ll see more of this later.3031•The main thing to remember is that combinations of gates implement Boolean functions.•The circuit below implements the Booleanfunction:We simplify our Boolean expressions sothat we can create simpler circuits.32•We have designed a circuit that implements the Boolean function:•This circuit is an example of a combinational logic circuit.•Combinational logic circuits produce a specified output (almost) at the instant when input values are applied.3334•Combinational logic circuitsgive us many useful devices.•One of the simplest is thehalf adder , which finds thesum of two bits.•We can gain some insight asto the construction of a halfadder by looking at its truthtable, shown at the right.35•As we see, the sum can befound using the XORoperation and the carryusing the AND operation.36•We can change our halfadder into to a full adderby including gates forprocessing the carry bit.•The truth table for a fulladder is shown at theright.37•How can we change thehalf adder shown belowto make it a full adder?38•Here’s our completed full adder.•Just as we combined half adders to make a full adder, full adders can connected in series.•The carry bit “ripples” from one adder to the next; hence, this configuration is called a ripple-carry adder.Today’s systems employ more efficient adders.39407480 Full Adder41•Decoders are another important type ofcombinational circuit.•Among other things, they are useful in selecting a memory location according a binary value placed on the address lines of a memory bus.•Address decoders with n inputs can select any of 2n locations.This is a blockdiagram for adecoder.•This is what a 2-to-4 decoder looks like on the inside.If x = 0 and y = 1,which output lineis enabled?4243• A multiplexer does just theopposite of a decoder.•It selects a single outputfrom several inputs.•The particular input chosenfor output is determined bythe value of the multiplexer’scontrol lines.•To be able to select among ninputs, log 2n control lines are needed.This is a block diagram for a multiplexer.•This is what a 4-to-1 multiplexer looks like on the inside.If S0= 1 and S1= 0,which input istransferred to theoutput?4445•A simple Arithmetic Logic Unit (ALU)00: (A+B)01:(NOTA)10:(A OR B)11: (A AND B)•Combinational logic circuits are perfect for situations when we require the immediate application of a Boolean function to a set of inputs. •There are other times, however, when we need a circuit to change its value with consideration to its current state as well as its inputs.–These circuits have to “remember” their current state.•Sequential logic circuits provide this functionality for us.4647•As the name implies, sequential logic circuits require a means by which events can be sequenced.•State changes are controlled by clocks.–A “clock” is a special circuit that sends electrical pulses through a circuit.•Clocks produce electrical waveforms such as theone shown below.48•State changes occur in sequential circuits only when the clock ticks.•Circuits can change state on the rising edge, falling edge, or when the clock pulse reaches itshighest voltage.49•Circuits that change state on the rising edge, or falling edge of the clock pulse are called edge-triggered.•Level-triggered circuits change state when theclock voltage reaches its highest or lowest level.50•To retain their state values, sequential circuits rely on feedback.•Feedback in digital circuits occurs when an output is looped back to the input.• A simple example of this concept is shown below.–If Q is 0 it will always be 0, if it is 1, it will always be 1.Why?。