Register Interface(Register.java),
then those register class implement the Register Interface:
- Condition Code(4bits) set when arithmetic/logical operations are executed(CC.java)
- Divider Register to store the divider of the DVD instruction(DR.java)
- General Program Register(GPR.java)
- Internal Address Register(IAR.java)
- Instruction Register(IR.java)
- Internal Result Register which is used to temporarily store calculation results(IRR.java)
- Memory Address Register(MAR.java)
- Memory Buffer Register(MBR.java)
- Reserved Register MFR, Only one instance ofthis class exist in computer(MFR.java)
- Multiplicand Register MLR(MLR.java)
- Program Counter Register(12 bits) contains the address of the nextinstruction to be executed(PC.java)
- Register which stores the product in instruction "MLT"(PR.java)
- Quotient Register(QR.java)
- Remainder Register(RR.java)
- Shift and Rotate Register(16bits, be used in shift and rotate data) implemented in SRR.java
- Index Register(X.java)
- Temporary Register to store operands forcalculation in ALU(Y.java)
- Z Register to store the result calculated in ALU(Z.java)
Addressing function implemented in the Addressing.java, provide the way to calculate the effective address.
Core Functions:
public class Addressing {
...
public static void getEffectiveAddress(String x, String i, String address){
...
// direct addressing
if (I=="0"){
// no indexing
if X=="00", EA = Address
// indexing
if X==1..3, EA = c(X) + A
}
// indirect addressing
else if (I=="1"){
// no indexing
if X=="00", EA = c(Address)
// indexing
if X==1..2, EA = c(c(X)+address)
}
}
public static void sendStepInformation(){
// Send Information to GUI
}
}
Arithmetic logic unit is implemented in the ALU.java, provide addition, minus, compareTwo, logical OR, logical AND and logical NOT.
The class Cache implemented in Cache.java represents A Fully Associated Cache in the Computer.
//fully associated cache
public class Cache {
...
// According to address ,return data
public String getdata(String address){
...
}
//if miss, then get data from memory
public String getIfMiss(String address){
...
}
// fetch word from cache or memory by address
public void cacheToMBR(String address){
...
}
//write back data to Cache and Memory
public void writeBack(String address,String data){
...
}
}
The class CacheLine in CacheLine.java is used to present one line in the Cache.
Ued to control the process in the system which is implemented in controler.java
It includes all registers, ALU, Memory, cycle and Cache implemented in CPU.java
Implemented in Decoder.java, and aim to decode the instruction sent by I/O.
Partition the binary command to four part: opcode(LDR, STR, LDA, LDX, STX…), X(Index Register), R(General Purpose Register), I(direct or indirect addresing).
Multi-thread to block to main thread(in ordert to parition the process of one instuction to several parts and show the procedure on the GUI).
I/O has separated i/o memory space implement in IOmemory.java
ISA implementd in ISA.java is used to get the make decision which instuction is executed. And other instuctions extend it. There are the Instruction set:
-
Arithmetic instructions include add, substract, multiply and divide(ArithmeticInstructions.java)
-
I/O Instructions include IN and OUT implemented in IOInstructions.java
-
Load and store instruction implemented in LoadAndStore.java
-
Logical instruction implemented in LogicalInstruction.java
-
Micellaneous Instructions(Miscellaneous Instruction.java)
-
Shift and Rotate Instructions implemented in ShiftAndRotate.java
-
Transfer Instruction implemented in TransferInstruction.java
There is a Memory class using HashMap<address, data> to represents memory implemented in Memory.java
package core;
import java.util.HashMap;
public class Memory {
//use HashMap to represent memory,key represents address,value represents data
private HashMap<String ,String> memorySpace=new HashMap<String, String>();
...
//get the content from memory
public String getContent(String address){
...
}
//store value to the address
public void setContent(String address,String value){
...
}
//add one to the address to help build the HashMap
public String addressAddone(String s1){
...
}
//clear all memory unit
public void clear() {
...
}
}