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

📄 memoryblock.java

📁 一种将c高级语言转化给VHDL的编译器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  public int getVarGroupingsSize() { return _listOfArrayVarGroupings.size();}  public ArrayList getVarGroupingsPtr() { return _listOfArrayVarGroupings;}  /** "@param L   */  public void saveVarGroupings(ArrayList l) {     _listOfArrayVarGroupings.addAll(l);  }     /** this function resents all the bus usage count information   */  public void resetBusUseCnts() {    if(_onlyOneAddy || (_numOfReadBus + _numOfWriteBus == 1)) {      _readBusUseCnts.add(new Integer(0));    }    else {      for(int i=0;i<_numOfReadBus;i++)        _readBusUseCnts.add(new Integer(0));      for(int i=0;i<_numOfWriteBus;i++)        _writeBusUseCnts.add(new Integer(0));    }            }  /** This method is for counting uses of the write bus independent of time.     *  The count is equal to the number of clock ticks it would take to perform    *  all requested writes on this memory.  It takes into account both the    *  number of AStore operations and the number of data write ports available    *  to carry out the task.   */  public void incWriteBusUseCnt() {    if((_onlyOneAddy && (_numOfReadBus == 1) && (_numOfWriteBus == 1))          || (_numOfReadBus + _numOfWriteBus == 1)) {      //for 1 port memories just increment the read bus count      int writeCntTmp = ((Integer)(_readBusUseCnts.get(0))).intValue();      _readBusUseCnts.set(0, new Integer(++writeCntTmp));    }    else {    //for multiple port memories, save a write count for each port.  For each    //write, save it to a different port, so that they are spread out.  The     //number of clock ticks needed for all writes is equal to the largest of    //these values      int writeCntTmp = ((Integer)(_writeBusUseCnts.get(_index))).intValue();      _writeBusUseCnts.set(_index, new Integer(++writeCntTmp));      _index++;      if(_index >= _numOfWriteBus)        _index = 0;    }  }  /** This method is for counting uses of the read bus independent of time.  The    *  count is equal to the number of clock ticks it would take to perform all    *  requested reads on this memory.  It takes into account both the number of    *  ALoad operations and the number of data read ports available to carry out    *  the task.   */  public void incReadBusUseCnt() {    //see comments in incWriteBusUseCnt    if((_onlyOneAddy && (_numOfReadBus == 1) && (_numOfWriteBus == 1))             || (_numOfReadBus + _numOfWriteBus == 1)) {      int readCntTmp = ((Integer)(_readBusUseCnts.get(0))).intValue();      _readBusUseCnts.set(0, new Integer(++readCntTmp));    }    else {      int readCntTmp = ((Integer)(_readBusUseCnts.get(_index))).intValue();      _readBusUseCnts.set(_index, new Integer(++readCntTmp));      _index++;      if(_index >= _numOfReadBus)        _index = 0;    }  }     /** This method is for getting the write bus count   *    * @return number of clock ticks to handle all memory writes   */  public int getWriteBusUseCnt() {    //return the count from the bus with the highest number.  This is equal to     //the number of clock ticks necessary to perform all the writes    int cnt = 0;    if((_onlyOneAddy && (_numOfReadBus == 1) && (_numOfWriteBus == 1))           || (_numOfReadBus + _numOfWriteBus == 1)) {      for (Iterator itsPrint = ((ArrayList)(_readBusUseCnts)).iterator();                 itsPrint.hasNext(); ) {        int cntTmp_int = ((Integer)itsPrint.next()).intValue();        if( cntTmp_int > cnt )          cnt = cntTmp_int;      }    }    else {      for (Iterator itsPrint = ((ArrayList)(_writeBusUseCnts)).iterator();                 itsPrint.hasNext(); ) {        int cntTmp_int = ((Integer)itsPrint.next()).intValue();        if( cntTmp_int > cnt )          cnt = cntTmp_int;      }    }    return cnt;  }  /** This method is for getting the read bus count   *    * @return number of clock ticks to handle all memory reads   */  public int getReadBusUseCnt() {      //once again, please see the write comments    int cnt = 0;    for (Iterator itsPrint = ((ArrayList)(_readBusUseCnts)).iterator();               itsPrint.hasNext(); ) {      int cntTmp_int = ((Integer)itsPrint.next()).intValue();      if( cntTmp_int > cnt )        cnt = cntTmp_int;    }    return cnt;  }  /** the next several methods are for measuring memory access over time.  This   *  method initializes the storage hashmaps used by all those methods.   */  public void resetBusCntsAtAllTimes() {    _writeIndexAtTime = new HashMap();    _readIndexAtTime = new HashMap();    _readBusUseCntAtTime = new HashMap();    _writeBusUseCntAtTime = new HashMap();  }  /** This method is for counting uses of the write bus at a given clock tick.     *  The count is equal to the number of clock ticks it would take to perform    *  all requested writes on this memory.  It takes into account both the    *  number of AStore operations and the number of data write ports available    *  to carry out the task.   *    * @param i clock tick to count a write at   */  public void incWriteBusUseCntAtTime(int i) {    //initialize hashmaps    if(!_readBusUseCntAtTime.containsKey(new Integer(i)))      _readBusUseCntAtTime.put(new Integer(i), new ArrayList());    if(!_writeBusUseCntAtTime.containsKey(new Integer(i)))      _writeBusUseCntAtTime.put(new Integer(i), new ArrayList());        //for one port memories, use the read bus count data bases:    //but see the comments in the else statement to see what I'm doing here    if((_onlyOneAddy && (_numOfReadBus == 1) && (_numOfWriteBus == 1))          || (_numOfReadBus + _numOfWriteBus == 1)) {      if(((ArrayList)(_readBusUseCntAtTime.get(new Integer(i)))).size() <= 0)        ((ArrayList)(_readBusUseCntAtTime	                             .get(new Integer(i)))).add(new Integer(0));      int writeCntTmp = ((Integer)(((ArrayList)(_readBusUseCntAtTime                                     .get(new Integer(i)))).get(0))).intValue();      ((ArrayList)(_readBusUseCntAtTime                      .get(new Integer(i)))).set(0, new Integer(++writeCntTmp));    }    else {      //more initialize stuff      if(!_writeIndexAtTime.containsKey(new Integer(i)))        _writeIndexAtTime.put(new Integer(i), new Integer(0));	      //find out the next port to write too at this time. This will      //alternate to spread out the writes.      int IndexTmp = ((Integer)(_writeIndexAtTime                                              .get(new Integer(i)))).intValue();      //more initializing:      while(((ArrayList)(_writeBusUseCntAtTime                                      .get(new Integer(i)))).size() <= IndexTmp)        ((ArrayList)(_writeBusUseCntAtTime	                             .get(new Integer(i)))).add(new Integer(0));      //increment the bus count for this bus at this time:      int writeCntTmp = ((Integer)(((ArrayList)(_writeBusUseCntAtTime                              .get(new Integer(i)))).get(IndexTmp))).intValue();      ((ArrayList)(_writeBusUseCntAtTime               .get(new Integer(i)))).set(IndexTmp, new Integer(++writeCntTmp));      //go on to the next bus, and save this, so that the next write at this       //time will happen on the next bus:      IndexTmp++;      if(IndexTmp >= _numOfWriteBus)        IndexTmp = 0;      _writeIndexAtTime.put(new Integer(i), new Integer(IndexTmp));    }  }  /** This method decrements the write count at a given clock tick   *    * @param i clock tick in which the write count should be decremented   */  public void decWriteBusUseCntAtTime(int i) {    //hopefully there won't be any decrements until there are increments, and so initializing the arrays is unnecessary    //once again, one port memories, use the read bus count for all usage     //calulations:    if((_onlyOneAddy && (_numOfReadBus == 1) && (_numOfWriteBus == 1))           || (_numOfReadBus + _numOfWriteBus == 1)) {      int writeCntTmp = ((Integer)(((ArrayList)(_readBusUseCntAtTime                                     .get(new Integer(i)))).get(0))).intValue();      ((ArrayList)(_readBusUseCntAtTime                      .get(new Integer(i)))).set(0, new Integer(--writeCntTmp));    }    else {      //find which bus was last written to      int IndexTmp = ((Integer)(_writeIndexAtTime                                              .get(new Integer(i)))).intValue();      //go to the bus before      IndexTmp--;      if(IndexTmp < 0)        IndexTmp = _numOfWriteBus-1;      //decrement the write count for this bus at this time      int writeCntTmp = ((Integer)(((ArrayList)(_writeBusUseCntAtTime                              .get(new Integer(i)))).get(IndexTmp))).intValue();      ((ArrayList)(_writeBusUseCntAtTime               .get(new Integer(i)))).set(IndexTmp, new Integer(--writeCntTmp));      //save the new bus      _writeIndexAtTime.put(new Integer(i), new Integer(IndexTmp));    }  }  /** This method is for counting uses of the read bus at a given clock tick.     *  The count is equal to the number of clock ticks it would take to perform    *  all requested reads on this memory.  It takes into account both the number   *  of ALoad operations and the number of data read ports available to carry    *  out the task.   *    * @param i clock tick to count a read at   */  public void incReadBusUseCntAtTime(int i) {    //please refer to the comments in the write bus count methods!    if(!_readBusUseCntAtTime.containsKey(new Integer(i)))      _readBusUseCntAtTime.put(new Integer(i), new ArrayList());    if((_onlyOneAddy && (_numOfReadBus == 1) && (_numOfWriteBus == 1))           || (_numOfReadBus + _numOfWriteBus == 1)) {      if(((ArrayList)(_readBusUseCntAtTime.get(new Integer(i)))).size() <= 0)        ((ArrayList)(_readBusUseCntAtTime	                             .get(new Integer(i)))).add(new Integer(0));      int readCntTmp = ((Integer)(((ArrayList)(_readBusUseCntAtTime                                     .get(new Integer(i)))).get(0))).intValue();      ((ArrayList)(_readBusUseCntAtTime                       .get(new Integer(i)))).set(0, new Integer(++readCntTmp));    }    else {      if(!_readIndexAtTime.containsKey(new Integer(i)))        _readIndexAtTime.put(new Integer(i), new Integer(0));      int IndexTmp = ((Integer)(_readIndexAtTime.get(new Integer(i))))                                                                    .intValue();      while(((ArrayList)(_readBusUseCntAtTime.get(new Integer(i)))).size()                        <= IndexTmp)        ((ArrayList)(_readBusUseCntAtTime.get(new Integer(i))))	                                                   .add(new Integer(0));      int readCntTmp = ((Integer)(((ArrayList)(_readBusUseCntAtTime                              .get(new Integer(i)))).get(IndexTmp))).intValue();      ((ArrayList)(_readBusUseCntAtTime.get(new Integer(i))))                                      .set(IndexTmp, new Integer(++readCntTmp));      IndexTmp++;      if(IndexTmp >= _numOfReadBus)        IndexTmp = 0;      _readIndexAtTime.put(new Integer(i), new Integer(IndexTmp));    }  }  /** This method decrements the read count at a given clock tick   *    * @param i clock tick in which the read count should be decremented   */  public void decReadBusUseCntAtTime(int i) {    if((_onlyOneAddy && (_numOfReadBus == 1) && (_numOfWriteBus == 1))          || (_numOfReadBus + _numOfWriteBus == 1)) {      int readCntTmp = ((Integer)(((ArrayList)(_readBusUseCntAtTime                                     .get(new Integer(i)))).get(0))).intValue();      ((ArrayList)(_readBusUseCntAtTime                       .get(new Integer(i)))).set(0, new Integer(--readCntTmp));    }    else {      int IndexTmp = ((Integer)(_readIndexAtTime                                              .get(new Integer(i)))).intValue();      IndexTmp--;      if(IndexTmp < 0)        IndexTmp = _numOfReadBus-1;      int readCntTmp = ((Integer)(((ArrayList)(_readBusUseCntAtTime                              .get(new Integer(i)))).get(IndexTmp))).intValue();      ((ArrayList)(_readBusUseCntAtTime.get(new Integer(i)))).set(IndexTmp,                                                      new Integer(--readCntTmp));      _readIndexAtTime.put(new Integer(i), new Integer(IndexTmp));    }  }     /** This method is for getting the write bus count at a given time   *    * @param i clock tick in which the write count should be returned from   * @return number of clock ticks to handle all memory writes   */  public int getWriteBusUseCntAtTime(int i) {    int cnt = 0;    if((_onlyOneAddy && (_numOfReadBus == 1) && (_numOfWriteBus == 1))       || (_numOfReadBus + _numOfWriteBus == 1)) {      if(!_readBusUseCntAtTime.containsKey(new Integer(i)))        return 0;      for (Iterator itsPrint = ((ArrayList)(_readBusUseCntAtTime                                              .get(new Integer(i)))).iterator();               itsPrint.hasNext(); ) {        int cntTmp_int = ((Integer)itsPrint.next()).intValue();        if( cntTmp_int > cnt )          cnt = cntTmp_int;      }    }    else {      if(!_writeBusUseCntAtTime.containsKey(new Integer(i)))        return 0;      for (Iterator itsPrint = ((ArrayList)(_writeBusUseCntAtTime                                              .get(new Integer(i)))).iterator();               itsPrint.hasNext(); ) {        int cntTmp_int = ((Integer)itsPrint.next()).intValue();        if( cntTmp_int > cnt )          cnt = cntTmp_int;      }    }    return cnt;  }  /** This method is for getting the read bus count at a given time   *    * @param i clock tick in which the read count should be returned from   * @return number of clock ticks to handle all memory reads   */  public int getReadBusUseCntAtTime(int i) {    int cnt = 0;    if(!_readBusUseCntAtTime.containsKey(new Integer(i)))      return 0;    for (Iterator itsPrint = ((ArrayList)(_readBusUseCntAtTime                                              .get(new Integer(i)))).iterator();               itsPrint.hasNext(); ) {      int cntTmp_int = ((Integer)itsPrint.next()).intValue();      if( cntTmp_int > cnt )        cnt = cntTmp_int;    }    return cnt;  }    public String toString() {    String retval = "MemoryBlock: \n";    retval = retval + " _name: " + _name + "\n";    retval = retval + " _isROM: " + _isROM + "\n";    retval = retval + " _onlyOneAddy: " + _onlyOneAddy + "\n";    retval = retval + " _wordSize: " + _wordSize + "\n";    retval = retval + " _initReadLatency: " + _initReadLatency + "\n";    retval = retval + " _normalReadLatency: " + _normalReadLatency + "\n";    retval = retval + " _initWriteLatency: " + _initWriteLatency + "\n";    retval = retval + " _normalWriteLatency: " + _normalWriteLatency + "\n";    retval = retval + " _memSize: " + _memSize + "\n";    retval = retval + " _numOfReadBus: " + _numOfReadBus + "\n";    retval = retval + " _numOfWriteBus: " + _numOfWriteBus + "\n";    retval = retval + " _addr: 0x"+Long.toHexString(_addr)+"\n";    return retval;  }}

⌨️ 快捷键说明

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