• 大小: 21KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-03
  • 语言: Java
  • 标签: MIPS  模拟  

资源简介

国外大学实现的MIPS模拟器,使用Java编写。国外大学实现的MIPS模拟器,使用Java编写。国外大学实现的MIPS模拟器,使用Java编写。国外大学实现的MIPS模拟器,使用Java编写。国外大学实现的MIPS模拟器,使用Java编写。国外大学实现的MIPS模拟器,使用Java编写。

资源截图

代码片段和文件信息

import java.util.*;
import java.lang.*;
import java.awt.*;

/**
 * Decode handles the operation for the decode stage of pipelined execution.
 */
class Decode extends Stage {
/**
 * holds the Rd of the last three instruction to detect hazards
 */
    private Vector hazardList;
    /**
 * placeholder for an instruction that is stalled.
 */
    private Instruction instructionSave;
    /**
 * saves the program counter for an instruction that is stalled.
 */
    private int savePC;
    /**
 * indicates that a stall has been issued.
 */
    public boolean isStall;
    /**
 * indicates that a stall has been detected.
 */
    public boolean stallflag;
    /**
 * indicates whether branches are assumed taken (not used).
 */
    public boolean assumeBranchTaken;
    /**
 * indicates whether a branch instruction was taken on its last execution.
 */
    public boolean branchPrediction;
    /**
 * indicates whether forwarding is used.
 */
    public boolean forwarding;
    /**
 * table used to predict branches (unused).
 */
    public Vector branchTable; 

    /**
 * initialzes the fields of the object
 */
    public Decode() {
       super();
       instructionSave = new Instruction(“NOP“);
       isStall = false;
       assumeBranchTaken = true;   // assume branches always taken (when prediction disabled)
       hazardList = new Vector(3);
       branchTable = new Vector();
       hazardList.addElement(new Integer(0));
       hazardList.addElement(new Integer(0));
       hazardList.addElement(new Integer(0));
    }

    /**
 * process the current instruction.  Implements the functionality of the decode stage of a pipeline.
 * Uses a vector of instructions each of the other pipeline stages the register file and the
 * ListBoxes object.
 * @see Instruction
 * @see Fetch
 * @see Execute
 * @see Memory
 * @see WriteBack
 * @see MemoryType
 * @see Listboxes
 */
    public void step(Vector Instructions MemoryType regFile 
                     Memory myMemory WriteBack myWriteBack
                     Fetch myFetch Execute myExecute ListBoxes lb) {

         String str;

        // if last instruction was stalled recall stalled instruction

        if (PC==Instructions.size())
           PC = -9;  // this is actually a NOP received from Fetch

        if (isStall == true) {                             
            myInstruction = instructionSave;   
            PC = savePC;
        }
        
        //--Check for RAW hazards in pipeline; ignore NOP instructions-----

        // check RAW hazard for rs

        stallflag = false;
        if ( ( ( (myExecute.myInstruction.opcode != 0) && 
               (myExecute.myInstruction.flush == false) &&
               (myInstruction.rs==
                ((Integer) hazardList.elementAt(0) ).intValue() )) ||  
              ( (myMemory.myInstruction.opcode != 0) && 
               (myMem

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件       10904  2000-08-11 10:11  Decode.java
     文件        6595  2000-08-11 10:11  Execute.java
     文件        1819  2000-08-11 10:11  Fetch.java
     文件       10524  2000-08-11 10:12  GUI.java
     文件        2602  2000-08-11 10:12  Help.java
     文件        9895  2000-08-11 10:12  Instruction.java
     文件        4451  2000-08-11 10:12  ListBoxes.java
     文件        2737  2000-08-11 10:12  Memory.java
     文件        1168  2000-08-11 10:13  MemoryType.java
     文件        4202  2000-08-11 10:13  Simulator.java
     文件         843  2000-08-11 10:13  Stage.java
     文件        5679  2000-08-11 10:13  Stages.java
     文件        2578  2000-08-11 10:13  UI.java
     文件        3772  2000-08-11 10:13  WriteBack.java
     文件        7187  2000-09-07 12:08  mips.html

评论

共有 条评论