MCS-284 Chapter 5 Homework (Fall 2007)

When turning in a homework problem, be sure to indicate the exercise number. These will be the reference numbers I use in reporting back your standing on the homework.
• Do exercise 5.20 from the "For More Practice" portion of the CD materials. There is an error in the problem statement: the reference to Figure 5.25 on page 318 should actually refer to Figure 5.24 on page 314. Moreover, Figure 5.24 itself has two errors: (1) there is a missing vertical line segment at the far right of the diagram, connecting the two loose ends. (2) The control signal from the AND-gate (which combines Branch and Zero) is connected to the bottom of the wrong MUX; instead of the new rightmost MUX in the top row, it should go to the previous, gray MUX. In addition to these errors, please note the following:

In the datapath, there are several places where a mux (multiplexor) is used to select which of two sources should provide a value. When you modify the datapath to add the `jal` instruction, you may find yourself wanting to change one or more of these two-way choices to a three-way choice. There are two options for how you can do this; either is fine. One option is to add a second two-way mux, with the output from one of the two-way muxes feeding into one of the inputs of the other. Then you will have a new control signal controlling the new mux. The other option is to modifying the existing two-way mux to be a three-way mux, with a new input labeled 2 (in addition to the existing inputs 0 and 1). If you do this, you'll need to widen the mux's control signal from a one-bit control (capable of selecting 0 or 1) to a two-bit control (capable of selecting 0 (binary 00), 1 (binary 01), or 2 (binary 10). The fourth possibility, binary 11, wouldn't be used.

In the datapath, you may find yourself wanting to inject a constant value in at some point. You can do this just by writing the constant with an arrow leading from it, as in the example of the 4 that feeds into the adder that computes PC+4.

In the control table from page 308 (Figure 5.18), you will definitely need to add a row, for the `jal` instruction. However, you may also need to add one or more more columns, for any newly added or widened control signals that you introduce in the datapath. If so, you will need to show the values of these new control signals in the existing rows as well as in the new row. Be sure to also add a "Jump" column, which the textbook implicitly added in the last paragraph of page 313. Be sure to use X where possible, rather than needlessly specifying 0 or 1.

• Do exercise 5.24 from the "For More Practice" portion of the CD materials. ("Both datapaths" means the single-cycle and multi-cycle datapaths.)

• Exercise 5.x1: Show how to modify the multicycle processor to include the `addi` instruction. Add any necessary datapaths and control signals to the multicycle datapath of Figure 5.28 on page 323 and show the necessary modifications to the finite state machine of Figure 5.38 on page 339. (Note that the latter diagram is buggy; in state 4, RegDst should be 0 and MemtoReg should be 1.) You can show your modifications on photocopies of the figures.

• Do exercise 5.52 from the "For More Practice" portion of the CD materials.

Instructor: Max Hailperin