CS 207
Midterm 2
Ondich
Due 8:30 AM Wednesday, November 13, 2002

For this exam, you may use your textbook, your notes and assignments, your brain, the Math/CS computers, and any psychic powers you may possess. If you get stuck, talk to Jeff Ondich. Do not talk to anyone else about the exam.

Explain and justify your answers. Submit your answers on paper.

  1. (10 points) The following questions concern IEEE 754 32-bit floating point numbers. When I refer to a "representable number," I mean a number whose exact value is one of the values that has a 32-bit IEEE 754 representation.

  2. (10 points) Consider the circuit shown below. Obviously, it's memory of some kind, but your goal is to discover its behavior in more detail.

  3. (10 points) Consider the multi-cycle datapath shown in Figure 5.33 in Patterson and Hennessy. Suppose the PC starts with the value 5000, the instruction at location 5000 of memory is "add $4, $5, $6", and the contents of registers $4, $5, and $6 are 104, 105, and 106, respectively. Suppose further that we have executed this instruction up through the very end of its third clock cycle, but that the clock has not yet fallen to end the third cycle and begin the fourth. Print Figure 5.33 and show the values of as many lines on the datapath as possible. This includes control lines, lines whose values are used during this cycle, etc.

  4. (8 points) Still using Figure 5.33, suppose the propagation delays of the various elements are: 5 ns for memory and the ALU, 3ns for the registers, the Control, and the ALU Control, 2ns for each of the multiplexors, and 1 ns for the shift left, the sign extend, and the individual gates. Also, assume that the memory elements IR, PC, A, B, Memory data register, and ALUOut show the proper output 1ns after the trailing clock edge (assuming the appropriate write-enable lines are set).

    Consider the add instruction of the previous problem. For each of the four clock cycles it takes to complete this instruction, what amount of time is required to complete that cycle's work? Based only on R-format instructions, then, what is the fastest allowable clock rate?

  5. (3 points) I like to keep track of American pop culture a little bit, even though there's really no hope of my keeping up with or understanding it. Still, I'd like you to humor me by telling me what you think I should read or watch or listen to if I want to know what's happening in Popland these days.

  6. (6 points) Suppose you have a program containing the following code:

    
    char		str[] = "The moose frolicked merrily in the field.";
    
    ofstream	out( "moose.txt" );
    out << str << endl;
    out.close();
    
    long		i;
    ifstream	in( "moose.txt" );
    in.read( &i, sizeof(long) );
    cout << i << endl;
    

    If you compile and run your program on a Macintosh (with a Motorola PowerPC processor), what output does this code fragment produce? If you run it on a Windows machine (with an Intel 80x86 processor), what output does it produce? You may assume that sizeof(long) is 4, and that moose.txt opens successfully. Explain your answers.