⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chipdef.java

📁 一种将c高级语言转化给VHDL的编译器
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            }          }	}      }    }        //check for too many reads:    if(ALoad.conforms(instr)) {      Operand array = ALoad.getPrimalSource(instr);      Memory mBlock = findMemoryBlock(array);      if(mBlock.addLoadTestCnt(bNode, cycle, array) > 1) {        HashSet list = schedule.getAllAtTime((float)cycle);	for (Iterator it1 = ((HashSet)list.clone()).iterator(); it1.hasNext();) {	  MSchedHash.MSchedInstObject instObj = 	                                (MSchedHash.MSchedInstObject)it1.next();	  if(ALoad.conforms(instObj.inst)) {	    Operand prim = ALoad.getPrimalSource(instr);	    Memory otherMem = findMemoryBlock(prim);	    if(mBlock == otherMem) {	      schedule.unscheduleInst(instObj);	      unscheduled.add(instObj);	    }	  }	}      }    }    if(_isDummyBoard) return unscheduled;        //check for too many uses of an operator:    //initialize if necessary:    if(!(((HashMap)_opUseCntHM.get(_node)).containsKey(new Integer(cycle))))      ((HashMap)_opUseCntHM.get(_node)).put(new Integer(cycle), new HashMap());    if(!(((HashMap)(((HashMap)_opUseCntHM.get(_node)).get(new Integer(cycle)))).containsKey(operator)))      ((HashMap)(((HashMap)_opUseCntHM.get(_node)).get(new Integer(cycle)))).put(operator,                                                           new Integer(0));        //find old usage:    HashMap opCntMap = ((HashMap)(((HashMap)_opUseCntHM.get(_node))                                             .get(new Integer(cycle))));    int opUseCnt = ((Integer)opCntMap.get(operator)).intValue();        if(opUseCnt+1 > getNumAvailableForOp(operator)) {        HashSet list = schedule.getAllAtTime((float)cycle);	for (Iterator it1 = ((HashSet)list.clone()).iterator(); it1.hasNext();) {        	  MSchedHash.MSchedInstObject instObj = 	                                (MSchedHash.MSchedInstObject)it1.next();	  if(instObj.inst.operator() == instr.operator()) {	    //opCntMap.put(operator, new Integer(--opUseCnt));	    schedule.unscheduleInst(instObj);	    unscheduled.add(instObj);	  }		}    }        return unscheduled;            }    public void removeFromTime(BlockNode bNode, Instruction instr, int cycle) {      if(cycle >= 0) {      if(AStore.conforms(instr)) {        Operand array = AStore.getPrimalDestination(instr);        Memory mBlock = findMemoryBlock(array);        mBlock.subStoreCnt(bNode, cycle, array);      }      if(ALoad.conforms(instr)) {        Operand array = ALoad.getPrimalSource(instr);        Memory mBlock = findMemoryBlock(array);        mBlock.subLoadCnt(bNode, cycle, array);      }    }        if(_isDummyBoard) return;    Operator operator = instr.operator();    if((((HashMap)_opUseCntHM.get(_node)).containsKey(new Integer(cycle)))&&    	(((HashMap)(((HashMap)_opUseCntHM.get(_node)).get(new Integer(cycle))))        			   .containsKey(operator))) {      int opUseCntOld = ((Integer)(((HashMap)(((HashMap)_opUseCntHM.get(_node))        		   .get(new Integer(cycle))))        				.get(operator)))        				      .intValue();      if(opUseCntOld >= 0)    	((HashMap)(((HashMap)_opUseCntHM.get(_node)).get(new Integer(cycle))))        	.put(operator, new Integer(opUseCntOld - 1));    }    }    /** saves when the instruction is being executed and which module is doing it.     *    * @param instr instruction to schedule   * @param cycle desired time to schedule it   */  public void saveNewHardwareUsage(BlockNode bNode, Instruction instr,                                    int cycle) {    int maxRanktmp = (int)instr.getExecTime();    Operator operator = instr.operator();    if(!(_isDummyBoard)) {       if((((HashMap)_opUseCntHM.get(_node)).containsKey(new Integer(maxRanktmp)))&&    	  (((HashMap)(((HashMap)_opUseCntHM.get(_node)).get(new Integer(maxRanktmp))))        			     .containsKey(operator))) {	int opUseCntOld = ((Integer)(((HashMap)(((HashMap)_opUseCntHM.get(_node))        		     .get(new Integer(maxRanktmp))))        				  .get(operator)))        					.intValue();	if(opUseCntOld >= 0)    	  ((HashMap)(((HashMap)_opUseCntHM.get(_node)).get(new Integer(maxRanktmp))))        	  .put(operator, new Integer(opUseCntOld - 1));      }    }    if(maxRanktmp != -1) {      if(AStore.conforms(instr)) {        Operand array = AStore.getPrimalDestination(instr);        Memory mBlock = findMemoryBlock(array);        mBlock.subStoreCnt(bNode, maxRanktmp, array);      }      if(ALoad.conforms(instr)) {        Operand array = ALoad.getPrimalSource(instr);        Memory mBlock = findMemoryBlock(array);        mBlock.subLoadCnt(bNode, maxRanktmp, array);      }    }        if(!(_isDummyBoard)) {       HashMap operatorCntsAtTime = ((HashMap)(((HashMap)_opUseCntHM.get(_node)).get(new                                                        	Integer(cycle))));      if(operatorCntsAtTime == null) {	operatorCntsAtTime = new HashMap();	((HashMap)_opUseCntHM.get(_node)).put(new Integer(cycle), operatorCntsAtTime);      }      int opUseCnt = 0;      if(operatorCntsAtTime.get(operator) != null)	opUseCnt = ((Integer)operatorCntsAtTime.get(operator)).intValue();      operatorCntsAtTime.put(operator, new Integer(opUseCnt+1));    }          if(AStore.conforms(instr)) {      Operand array = AStore.getPrimalDestination(instr);      Memory mBlock = findMemoryBlock(array);      mBlock.addStoreCnt(bNode, cycle, array);    }        if(ALoad.conforms(instr)) {      Operand array = ALoad.getPrimalSource(instr);      Memory mBlock = findMemoryBlock(array);      mBlock.addLoadCnt(bNode, cycle, array);    }        //save this instruction to the individual instantiation of the operator:    if(!(_isDummyBoard)) {       int cntr = -1;      for(int j = 0; j<((ArrayList)(((HashMap)_opUseListsHM.get(_node)).get(operator))).size();j++) {	if(((HashSet)(((ArrayList)(((HashMap)_opUseListsHM.get(_node)).get(operator))).get(j)))                                                            .contains(instr))    	  ((HashSet)(((ArrayList)(((HashMap)_opUseListsHM.get(_node)).get(operator)))        					.get(j))).remove(instr);      }      sort(((ArrayList)(((HashMap)_opUseListsHM.get(_node)).get(instr.operator()))));	       do{	cntr++;	while(((ArrayList)(((HashMap)_opUseListsHM.get(_node)).get(operator))).size() <= cntr)    	  ((ArrayList)(((HashMap)_opUseListsHM.get(_node)).get(operator))).add(new HashSet());      //assign to an operator that is unused at this clock tick      }while(!noDuplicateTimes(((HashSet)(((ArrayList)(((HashMap)_opUseListsHM.get(_node))    				   .get(operator))).get(cntr))),         		       cycle));      ((HashSet)(((ArrayList)(((HashMap)_opUseListsHM.get(_node)).get(operator)))    						.get(cntr))).add(instr);    }  }  /** initialize the hashmaps.     *    */  public void completeInitialize() {    _opUseCntHM = new HashMap();    _opUseListsHM = new HashMap();  }  /** initialize the hashmaps.     *    */  public void initializeForOneNode(BlockNode node) {    _opUseListsHM.put(node, new HashMap());    _opUseCntHM.put(node, new HashMap());  }  /** initialize the hashmap.     *    */  public void initOpUseLists(Operator op) {    if(!((HashMap)_opUseListsHM.get(_node)).containsKey(op))      ((HashMap)_opUseListsHM.get(_node)).put(op, new ArrayList());  }  /** groups instructions together that are sharing an operator and saves to    *  the instruction objects.     *    */  public void saveNode(BlockNode node) {    _node = node;    if(!_opUseListsHM.containsKey(_node))      _opUseListsHM.put(_node, new HashMap());    if(!_opUseCntHM.containsKey(_node))      _opUseCntHM.put(_node, new HashMap());  }    /** groups instructions together that are sharing an operator and saves to    *  the instruction objects.     *    */  public void saveSharedOps() {    if(_isDummyBoard) return;    for (Iterator itsPrint = ((Set)(((HashMap)_opUseListsHM.get(_node)).keySet())).iterator();     	  itsPrint.hasNext(); ) {      Operator op = (Operator)itsPrint.next();      for(int n_int=0; n_int<((ArrayList)(((HashMap)_opUseListsHM.get(_node)).get(op)))        						   .size(); n_int++) {    	if(((HashSet)(((ArrayList)(((HashMap)_opUseListsHM.get(_node)).get(op)))        					   .get(n_int))).size() > 1) {    	  for (Iterator its2 = ((HashSet)(((ArrayList)(((HashMap)_opUseListsHM.get(_node))        			   .get(op))).get(n_int))).iterator();        		       its2.hasNext(); ) {    	    Instruction inst = (Instruction)its2.next();    	    inst.setIsShared(true);    	    inst.setShareSet(((HashSet)(((ArrayList)(((HashMap)_opUseListsHM.get(_node)).get(op)))	                                                         .get(n_int))));    	  }    	}      }    }  }    /** this method has something to do with the resource limitations checking,    *  but unfortunately, I can't remember exactly what.   *    * @param instrList list of instructions from the hyperblock   * @param maxRank time to search for matches with in the       *	 instruction list   * @return true if there are no times equal to maxRank   */  private boolean noDuplicateTimes(HashSet instrList, float maxRank) {    for (Iterator its = ((HashSet)instrList.clone()).iterator();       its.hasNext(); ) {      Instruction inst = (Instruction)its.next();      if(inst.getExecTime() == maxRank)  	return false;  	          }    return true;       }  /** sort lists of instructions or hashsets...   *    * @param o_list a list which needs sorting   */  private void sort(ArrayList o_list) {    class DoubleCompare implements Comparator {            /** compare function used by sort.  sorts hashmaps based on their size        *  and instructions in a list depending on the size of their execution        *  windows.         *        * @param o1 input 1       * @param o2 input 2       * @return -1, 0, or 1 depending on if o1 or o2 is greater or if they are        *     equal       */      public int compare(Object o1, Object o2) {	  	if (o1 instanceof HashSet	        	&& o2 instanceof HashSet) {	       	  HashSet p1 = (HashSet)o1;	       	  HashSet p2 = (HashSet)o2;	       	  if( p1.size() < p2.size()) {  	    	    return -1;  	  	    } else if( p1.size() > p2.size() ){ 	     	    return 1;	        	    } else {		  	    return 0;	         	  }	     	} else {	      	  throw new ClassCastException("Not Instruction");	    	}            }        }	         Collections.sort(o_list, new DoubleCompare());    }  public String toString() {    String retval =  "ChipDef: \n";    retval = retval + " _sliceCnt: " + _sliceCnt + "\n";     retval = retval + " _percentUsage: " + _percentUsage + "\n";     retval = retval + " _memoryBlocks: " + " \n";     for (Iterator it = _memoryBlocks.iterator(); it.hasNext(); ) {      Memory memBlock = (Memory)it.next();      retval = retval + "    " + memBlock.toString() + "\n";    }    return retval;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -