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.
Which machine is faster, machine A or B? What is the speedup?
Which machine is faster, machine A or B? What is the speedup?
For this problem, modify the xocolatl emulator to include several new MIPS-like RISC instructions. For this problem, you will take the following steps:
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 -heofThe -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.
|
|
|
L.D | 0x20 | Load 64-bit floating point (FP) rt register from address at (integer) register rs plus imm |
S.D | 0x21 | Store 64-bit FP register rt to address at (integer register) rs plus imm |
DIV.D | 0x24 | Divide FP register rs by FP register rt, placing result in FP register rd. |
MUL.D | 0x25 | Multiply FP register rs by FP register rt, placing result in FP register rd. |
ADD.D | 0x26 | Add FP register rs to FP register rt, placing result in FP register rd. |
SUB.D | 0x27 | Subtract FP register rt from FP register rs, placing result in FP register rd. |
ADDI.D | 0x28 | Add FP register rs to imm, placing result in FP register rd. |
ADDI | 0x30 | Add integer register rs to imm, placing result into integer register rd. |
ADD | 0x31 | Add integer register rs to integer register rt, placing result into integer register rd. |
SUB | 0x32 | Subtract integer register rt from integer register rs, placing result into integer register rd. |
SUBI | 0x33 | Subtract imm from integer register rs, placing result into integer register rd. |
XOR | 0x34 | Take the bitwise exclusive-OR of register rs and rt, placing the result into register rd. |
OR | 0x35 | Take the bitwise OR of register rs and rt, placing the result into register rd. |
AND | 0x36 | Take the bitwise AND of register rs and rt, placing the result into register rd. |
BACK | 0x41 | Halt processing RISC instructions, leaving the value of the program counter one instruction beyond this instruction. |
S | 0x50 | Store 32-bit integer register rt to address at rs plus imm. |
L | 0x51 | Load integer register rt from address at integer register rs plus imm. |
SHL | 0x60 | Shift the value in integer register rs left by a number of bits given by integer register rt, placing the result into integer register rd. |
SHLI | 0x61 | Shift the value in integer register rs left by a number of bits given by imm, placing the result into integer register rd. |
SHR | 0x62 | Shift the value in integer register rs right by a number of bits given by integer register rt, placing the result into integer register rd. |
SHRI | 0x63 | Shift the value in integer register rs right by a number of bits given by imm, placing the result into integer register rd. |
BEQ | 0x70 | If integer register rs is equal to integer register rt, then branch to the instruction whose address is the address of the next instruction plus 4 times imm, i.e., imm instructions past this instruction. |
BNE | 0x71 | If integer register rs is not equal to integer register rt, then branch to the instruction whose address is the address of the next instruction plus 4 times imm. |
BGE | 0x72 | If integer register rs is greater than or equal to to integer register rt, then branch to the instruction whose address is the address of the next instruction plus 4 times imm. |
BLE | 0x73 | If integer register rs is less than or equal to to integer register rt, then branch to the instruction whose address is the address of the next instruction plus 4 times imm. |
190 DATA 31,08,86,00 ' 1018That line, from fib.txt, has four hexadecimal numbers corresponding to the 4 bytes in a single RISC instruction. This particular instruction looks like this in binary:
bit # 33222222 22221 11111 1111 10987654 32109 87654 32109 876543210 -------- ----- ----- ----- --------- opcode rd rs rt imm value 00110001 00001 00010 00011 000000000So the opcode is binary 00110001, i.e. 0x31, so the instruction is an ADD instruction. The rd field is 1, the rs field is binary 00010 i.e. 2, and the rt field is binary 00011 i.e. 3, so this instruction says to add integer register 2 to integer register 3 and put the result back into integer register 1. You will need to be able to write Java code to parse these bit fields; make sure to get this working and see if you can tell what the program is supposed to be doing before you try anything else.
wget http://cava.cs.utsa.edu/xocolatl.tar.gz tar -xvzf xocolatl.tar.gz cd xocolatl cd src <your-favorite-editor> projects/risc_isa.java <insert-here-typing-to-do-the-assignment> make wget http://www.cs.utsa.edu/~dj/cs3853/hw2/fib.txt wget http://www.cs.utsa.edu/~dj/cs3853/hw2/phi.txt java -cp .:projects xoco -s fib.txt java -cp .:projects xoco -s phi.txt <more-commands-to-print-out-stuff>
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:
Late assignments will not be accepted.