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 LABS B 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. Now for Lab B, your code must handle any of the following function numbers for operation 2 by placing on the output line (this.aluControl) the given (string) value 0x27 = 39 -> nor aluControl = 3 0x26 = 38 -> xor aluControl = 4 0x4 = 4 -> sllv aluControl = 5 0x7 = 7 -> srav aluControl = 8 0x6 = 6 -> srlv aluControl = 9 To accomplish your task, you will need to use the method setValue belonging to the DataLine class as described next. 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 3 on the line, we make the call this.aluControl.setValue("3"); **********************************************************************/ super.execute(); } }