import java.awt.*; /*********************************************************************** * File: ExtendedALUControl.java * Aurthor: Dr. Dalton R. Hunkins * Computer Science Department * St. Bonaventure University * Date: November 2008 * * Purpose: * The file is a stub that allows the reader/programmer to extend * the ALU Control Unit within the Data Path Simulator, PathSim, * to handle additional MIPS operators. The extension is * accomplished through adding java code to the method execute. * See the lab instruction comment given below. * * Class Modified by: ***********************************************************************/ class ExtendedALUControl extends ALUControl { private DataLine aluOp, func, aluControl; private DataPath parent; /*********************************************************************** The Data Lines are aluOp - the line coming from the Control unit func - the line holding the function field of the instruction (Instruction[5-0]) aluControl - the output line going to the ALU *****************************************************************************/ public ExtendedALUControl(double x, double y, double w, double h, Color c, String label1, String label2, String name, DataLine aluOp, DataLine func, DataLine aluControl, DataPath parent) { super(x, y, w, h, c, label1, label2, name, aluOp, func, aluControl); this.func = func; this.aluOp = aluOp; this.aluControl = aluControl; this.parent = parent; } public void execute() { int function = (int) hexStringToUnsigned(func.getValue()); int operation = (int) hexStringToUnsigned(aluOp.getValue()); /********************************************************************* function is the function field of the MIPS instruction and represented here as a decimal (base 10) number versus a hexadecimal number. operation is the value placed on the data line ALUOp by the (extended) control unit **********************************************************************/ /********************************************************************* INSTRUCTIONS FOR LAB C Currently, the method is implemented by the call super.execute() as seen with the code written below. However, the parent super does nothing with the extensions. Therefore, you must write your code here for those extensions. In particular, super handles the operation values 0 and 1 and the combination of operation 2 and function numbers 32, 34, 36, 37 and 42. For this lab, you must write code to handle any of the following operatons by placing on the output line (this.aluControl) the appropriate value (you can determine these aluControl values from the MIPS operators already implemented in PathSim). addi -> 3 andi -> 4 ori -> 5 Last, your code must also handle any of the following operations by placing on the output line (this.aluControl) the given (string) value xori -> 6 aluControl = 4 (why 4?) bne -> 7 aluControl = A To accomplish your task for this lab exercise, you will need to use the method setValue belonging to the DataLine class. public void setValue(String value) precondition: value is any String postcondition: value is put on the data line and appears with a mouse click on the line For example, if we want to place the value 10 on the line, we make the call this.aluControl.setValue("A"); Observe that calling setValue with the string "10" will be interpreted as the number 16. Why? **********************************************************************/ super.execute(); } }