CS 3853 Fall 2010, Homework 2

Due at 11:59pm, February 18, 2010.
  1. Textbook problems: Do problems 1.12, 1.13, and 1.14 from pp. 61--62 in the textbook. Also, do the following problem:

    Consider two machines, machine A and machine B. For both machines, all instructions except for mispredicted branches take one cycle. Mispredicted branches take one cycle plus an additional misprediction latency. Machine A has a clock rate of 1.0 GHz and a misprediction penalty of 5 cycles. Machine B has a clock rate of 2.0 GHz and a misprediction penalty of 20 cycles. Branches are 25% of all instructions.

    1. With static branch prediction, 80% of branches are predicted correctly.

      Which machine is faster, machine A or B? What is the speedup?

    2. With dynamic branch prediction, 95% of branches are predicted correctly.

      Which machine is faster, machine A or B? What is the speedup?

  2. RISC processor emulation: Simulation is a very important part of computer architecture research. Architecture concepts are often too high-level to allow for a simple implementation in hardware, so we simulate our ideas in high-level languages like C and Java with varying levels of detail. The most simple level of detail is functional simulation also known as emulation, where we simulate an instruction-set architecture by executing each instruction in a program one by one, updating emulated memory locations and registers.

    For this problem, modify the xocolatl emulator to include several new MIPS-like RISC instructions. For this problem, you will take the following steps:

    1. Download the xocolatl emulator for the MC6809 processor. Unpack it into your home directory on one of the UTCS machines with tar -xvzf xocolatl.tar.gz .
    2. Modify the file xocolatl/src/projects/risc_isa.java to emulate the RISC MIPS-like ISA described below. (The current version of that file reads one instruction at a time, printing its hexadecimal value.) The emulator should fetch and execute instructions through the program counter one by one, incrementing the program counter by 4 after each fetch (and also updating the program counter correctly for branches).
    3. Compile xocolatl with your modifications and run it with two script files: fib.txt and phi.txt. These files will test your emulation of the RISC instructions. The first file computes the Fibonacci numbers using 32-bit integers, then prints them out. The second file computes the Fibonacci numbers and an approximation of the Golden Ratio, then prints them out.
    4. Turn in your code and the output generated by running each script.
    Your code should produce no output; it should only move values around in memory and do computation. If you like to have debug output, please disable it in the code you use to turn in your assignment.

    Compiling and running xocolatl

    To compile xocolatl together with the code you have written in xocolatl/src/projects/risc_isa.java, change to the directory xocolatl/src and type make. The first time through, it will make a number of extra programs and files related to the run-time environment of the emulator.

    You can run the scripts for this assignment by copying them to your xocolatl/src/ directory and typing the following at the command line:

    java -cp .:projects xoco -s fib.txt -heof
    java -cp .:projects xoco -s phi.txt -heof
    
    The -cp option for the java JVM tells it to look for compiled class files in the current directory as well as the projects/ directory, where your code will be compiled.

    Note: If you are running the emulator after having logged in remotely, you might need to set your DISPLAY environment variable to ":0.0" to fool the JVM into believing it has a screen before it can run. See the README file in xocolatl/ for information about using the video display option.

    For this problem, you will be implementing a MIPS-like RISC instruction set architecture.

    Your interface to xocolatl

    xocolatl is a somewhat complex emulator with RAM, ROM, input, output, and the full 6809 instruction set. Nevertheless, for this assignment our interface to the xocolatl emulator is small, since all we need to be able to do is load a byte, store a byte, and know where to begin fetching instructions. When a certain opcode is executed by the emulator, it hands control over to your code. These elements of the emulator are relevant to your assignment: Once your emulation is finished, make sure the value of xoco.pc is set to one byte beyond the last instruction your emulation executed, so control can return back to the proper address in the emulated 6809 program.

    Instruction Set Architecture

    The MIPS-like RISC ISA has the following properties:

    Hints

You may not work together on this assignment with other classmates or receive assistance from any person other than your professor.

Turn in your assignment by 11:59pm, February 18, 2010 as a single email to the teaching assistant with the following attachments:

  1. Your answers the the problems in the first part as a PDF file (no Word documents).
  2. Your Java code for the second part as risc_isa.java.
Your Java code will be graded not only for whether or not it works, but also for clarity and documentation.

Late assignments will not be accepted.