CS 208: Computer Organization & Architecture

Takehome Exam #2

Submit via Moodle as exam.pdf

This is a an exam. You may consult your notes, any book, and the Internet. You may not speak with any person other than Jeff Ondich, electronically or otherwise, about the content of this exam. If you obtain relevant information from any source other than yourself, cite your sources clearly.

This exam was designed to produce short answers for each question, although the justification of your answers (showing your work, showing a diagram if relevant, etc.) is still important. With that in mind, your submission should have the following structure:

Some answers don't require much explanation. However, when you get an answer wrong, showing your work can lead to significant partial credit if your reasoning is sound but you made a small mistake.

  1. (6 points)

    1. What is the 32-bit IEEE 754 representation of the number -39.375? Give your answer as a single 8-digit hexadecimal number.
    2. To what number does the 32-bit IEEE 754 representation 0x40855555 correspond? Please express your answer as a fraction. (Note: since the significand appears to have a repeating pattern, you may find that extending that pattern infinitely gives you a simpler fraction than the rounded off version stored in this 32-bit float.)
  2. (10 points) Character encoding in Python 3. (That's Python 3, not Python 2--they're quite different for this material.)

    You might find the Unix command hexdump -C filename handy in this problem, just for checking to make sure your files look right.

    1. If you do the assignment statement
      s = 'résumé'
      what Python 3 type is the variable s? Excessively helpful hint: the answer to this question is str, which you can verify with print(type(s)).
    2. Of what does an object of type str consist? (Go to the official Python documentation for this one, and keep your answer to one sentence. A link or citation would be appropriate here.)
    3. What is an encoding of an object of type str?
    4. What is a BOM?
    5. Use a text editor to save a file (including some non-ASCII characters) in the UTF-8 encoding with no BOM. (This can be done with lots of text editors, like Atom, Brackets, Sublime, BBEdit, etc. But note that MS Word is not a text editor, and does not save just the text in a file--it saves lots of formatting information as well. Also watch out for editors like macOS's TextEdit, which want to default to saving in Rich Text Format (.rtf). That's also not what you want.)

      What code would you use to open your saved file and read its contents into a variable of type str? (This can be done in one short line of code, or two if you are stylistically picky.)

    6. Same question as in part (e), but for UTF-16 little endian.
    7. What code would you use to write a str variable to a file using the UTF-16 big endian encoding with no BOM?
  3. (2 points) Please recommend a podcast or blog for me, or, if you prefer, tell me a joke. Thank you.

  4. (10 points) Consider our favorite datapath, Figure 4.17.

    1. Suppose PC is pointing to an address containing the instruction "li $a1, -45". I was an idiot and specified a pseudo-instruction here. You may complete this problem assuming either addiu $a1, $zero, -45 or ori $a1, $zero, -45 List the values for RegDst, Branch, MemRead, MemToReg, MemWrite, ALUSrc, and RegWrite. You may specify each as 0, 1 or DC (for "don't care").
    2. As we have noted in class, this datapath does not support the bne instruction. Suppose we replace the Branch control line with a 2-bit BranchType line BT_1 BT_0, whose value is 00 if the instruction is not a branch, 01 for beq, and 10 for bne. Give logic formulas for BT_1 and BT_0 In terms of the opcode I_31 I_30 I_29 I_28 I_27 I_26 (i.e., the highest-order six bits of the instruction). Make sure, of course, that your formulas never generate 11.
    3. Let's call the control line going into the multiplexer in the upper right of the diagram PCSrc. Now that we have replaced the Branch control with BranchType, give a formula for PCSrc in terms of BT_1, BT_0, and Zero. If we replace the existing AND gate with this new formula, we will now have a datapath that supports both beq and bne.
  5. (6 points) As you learned during the most recent homework assignment, any digital circuit has a propagation delay. For our purposes, propagation delay works like this. Imagine that all the inputs to the circuit become stable at time T1. There is, then, a minimum time T2 at which the outputs of the circuit are guaranteed to be stable for as long as the inputs remain stable. The propagation delay is the difference T2 - T1. (A circuit's propagation delay is dependent on its physical properties, and for our purposes, we're going to consider those properties a big mystery. Want to clear up the mystery? Talk to a physicist.)

    Let's do a much simpler propagation exercise than #2 from the homework. Consider this circuit (a D flipflop): which contains two of these (D latches): Assume that NOR, AND, and NOT gates have propagation delays of 3ns, 4ns, and 2ns, respectively. Then what's the propagation delay of the flipflop?