?? extendedalucontrol.java
字號:
import java.awt.*;
/***********************************************************************
* File: ExtendedALUControl.java
* Aurthor: Dr. Dalton R. Hunkins
* Computer Science Department
* St. Bonaventure University
* Date: 17 January 2006
*
* 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 and 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. 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
And for lab C, your code must handle any of the following
operatons by placing on the output line (this.aluControl)
the appropriate value (you should be able to determine these
aluControl values from the MIPS operators already implemented
in PathSim).
addi -> 3
andi -> 4
ori -> 5
Last for lab C, your code must 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 lab B and/or lab C, you will
need to use the method setValue belonging to the DataLine
class and the inherited utility method signedToHexString.
The two methods are described as follows:
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
protected String signedToHexString(int number,
int numberOfDigits) {
precondition:
number is any 32 bit integer
numberOfDigits is any positive integer
postcondition:
a String of numberOfDigits (e.g. 8 digit) is returned. The
string is a sequence of hex digits that is equivalent to
the 32 bit integer
For development/debugging purposes, you may also wish to use the
the following method:
parent.displayMessage(String message)
precondition:
message is any string
postcondition:
the message is displayed in an alert box
**********************************************************************/
super.execute();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -