Spring 2019 EE380 Assignment 4 Solution

  1. This MIPS/SPIM program includes a subroutine called myadd that performs x=(y+z);. In the space below, replace the myadd subroutine with one named posfmin that will make x = min(y,z) where x, y, and z are all positive normal floating-point numbers (not negative, not denormals, and not NaN nor Inf). Although these are all floating-point values, you only may use the MIPS integer instructions that we have discussed -- no MIPS floating-point instructions are allowed here.


  2. For this question, check all that apply. We discussed a variety of methods for performing binary addition. Which of the following ststements are true?
    Ripple Carry uses less circuitry than other methods
    Speculative Carry is always faster than carry select
    Carry Lookahead computes the carry for the Nth bit position in O(log N) time
    Carry Select implements K-bit addition using simultaneous (K/2)-bit additions
    Speculative Carry implements K-bit addition using simultaneous (K/2)-bit additions
  3. You know that to multiply a binary integer by 16, all you have to do is shift the value over by 4 bit positions -- which in hardware can literally be done without a function unit simply by connecting bus wires such that bit k goes to position k+4 and positions 0-3 are connected to ground. Well, it's harder to multiply by 28. However, by using Booth's algorithm, a single 32-bit add/subtract ALU is sufficient to implement multiply of a 32-bit number by 28 as a fast combinatorial circuit. Explain how this would be done by giving a formula for X*28 as a C expression (for example, X*5 would be (X<<2)+X).
  4. For this question, check all that apply. In mathematics, both addition and multiplication are associative; for example, a*(b*c) gives the same value as (a*b)*c. Assuming no values go out of range, are addition and multiplication are associative for 2's complement binary integers and for IEEE-format floating-point values? Mark all the operations that are associative.
    32-bit integer addition
    32-bit (single) floating-point addition
    64-bit (double) floating-point addition
    32-bit (single) floating-point multiplication
    64-bit (double) floating-point multiplication


  5. For this question, check all that apply. In the single-cycle design shown in the above (rather large and very familiar) figure, which of the following signals are "don't cares" when executing a MIPS sw instruction?
    Branch
    must be 0
    RegDst
    ALUSrc
    must be 1
    RegWrite
    must be 0
    MemWrite
    must be 1


  6. For this question, check all that apply. In the single-cycle design shown in the above (rather large and very familiar) figure, suppose that ALUSrc=0 and RegWrite=1. Which of the following MIPS instructions might be executing?
    sw $t0,4($t1)
    ALUSrc=1, RegWrite=0
    lw $t0,4($t1)
    ALUSrc=1, RegWrite=1
    beq $t0,$t1,l
    ALUSrc=0, RegWrite=0
    andi $t0,$t1,2
    ALUSrc=1, RegWrite=1
    add $t0,$t1,$t2
  7. What is the logic formula for Y?

  8. When determining the bit patterns to be used to represent instructions (or control signals in a circuit), one can use either horizontal or vertical encoding. Briefly describe one reason to prefer an encoding that is horizontal and one reason to prefer a vertical encoding.


EE380 Computer Organization and Design.