Package edu.byu.ece.rapidSmith.device

Examples of edu.byu.ece.rapidSmith.device.Tile


*/
public class BrowseDevice{

  public static void run(Device dev, WireEnumerator we){
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    Tile t = null;
    while(true){
      System.out.println("Commands: ");
      System.out.println(" 1: Get wire connections in tile");
      System.out.println(" 2: Check if wire is a PIP wire");
      System.out.println(" 3: List RouteThrough wires");
      System.out.println(" 4: Follow wire connections");
      System.out.println(" 5: List primitives of a tile");
      System.out.println(" 6: Get tile of a primitive site");
      System.out.println(" 7: Exit");
      try {
        Integer cmd = Integer.parseInt(br.readLine().trim());
        switch(cmd){
          case 1:
            System.out.println("Enter tile name: ");
            t = dev.getTile(br.readLine().trim());
            System.out.println("Choosen Tile: " + t.getName());

            System.out.println("Enter wire name: ");
            String wire = br.readLine().trim();
            WireConnection[] wires = t.getWireConnections(we.getWireEnum(wire));
            if(wires != null){
              for(WireConnection w : wires){
                System.out.println("  " + w.toString(we));
              }
            }
            else{
              System.out.println(" No Connections");
            }
            break;
          case 2:
            System.out.println("Enter wire name:");
            String wire1 = br.readLine().trim();
            System.out.println("isPIP? " + we.isPIPWire(wire1));
            break;
          case 3:
            System.out.println("PIPRouteThroughs");
            for(WireConnection w : dev.getRouteThroughMap().keySet()){
              System.out.println("  " + w.toString(we) + " " + dev.getRouteThroughMap().get(w).toString(we));
            }
            break;
          case 4:
            System.out.println("Enter start tile name: ");
            t = dev.getTile(br.readLine().trim());
            System.out.println("Choosen start tile: " + t.getName());

            System.out.println("Enter start wire name: ");
            String startWire = br.readLine().trim();
           
            while(true){
              if(t.getWireHashMap() == null){
                System.out.println("This tile has no wires.");
                break;
              }
              if(t.getWireConnections(we.getWireEnum(startWire)) == null){
                System.out.println("This wire has no connections, it may be a sink");
                break;
              }
              WireConnection[] wireConnections = t.getWireConnections(we.getWireEnum(startWire));
              System.out.println(t.getName() + " " + startWire + ":");
              for (int i = 0; i < wireConnections.length; i++) {
                System.out.println("  " + i + ". " + wireConnections[i].getTile(t) +" " + we.getWireName(wireConnections[i].getWire()));
              }
              System.out.print("Choose a wire: ");
              int ndx;
              try{
                ndx = Integer.parseInt(br.readLine().trim());
                t = wireConnections[ndx].getTile(t);
                startWire = we.getWireName(wireConnections[ndx].getWire());
              }
              catch(Exception e){
                System.out.println("Did not understand, try again.");
                continue;
              }
             
            }
            break;
          case 5:
            System.out.println("Enter tile name: ");
            t = dev.getTile(br.readLine().trim());
            System.out.println("Choosen Tile: " + t.getName());

            if(t.getPrimitiveSites() == null){
              System.out.println(t.getName() + " has no primitive sites.");
            }
            else{
              for(PrimitiveSite p : t.getPrimitiveSites()){
                System.out.println("  " + p.getName());
              }
            }
         
            break;
View Full Code Here


    tileYMap = new HashMap<Tile, Integer>();
    for(int row = 0; row < rows; row++) {
      if(rowsToSkip.contains(row)) continue;
      for (int col = 0; col < cols; col++) {
        if(colsToSkip.contains(col)) continue;
        Tile tile = device.getTile(row, col);
        drawnTiles[i][j] = tile;
        tileXMap.put(tile, j);
        tileYMap.put(tile, i);
        j++;
      }
      i++;
      j=0;
    }
    rows = rows-rowsToSkip.size();
    cols = cols-colsToSkip.size();
   
    //Draw dashed lines where rows/columns have been removed
    QPen missingTileLinePen = new QPen(QColor.lightGray, 2, PenStyle.DashLine);
    painter.setPen(missingTileLinePen);
    i = 0;
    for(int col : colsToSkip){
      int realCol = col - i;
      painter.drawLine(tileSize*realCol-1, 0, tileSize*realCol-1, rows*tileSize-3);
      i++;
    }
    i=0;
    for(int row : rowsToSkip){
      int realRow = row - i;
      painter.drawLine(0,tileSize*realRow-1, cols*tileSize-3,tileSize*realRow-1);
      i++;
    }
   
    // Draw the tile layout
    int offset = (int) Math.ceil((lineWidth / 2.0));
   
    for(int y = 0; y < rows; y++){
      for(int x = 0; x < cols; x++){
        Tile tile = drawnTiles[y][x];
        TileType tileType = tile.getType();

        // Set pen color based on current tile
        QColor color = TileColors.getSuggestedTileColor(tile);
        painter.setPen(color);
       
View Full Code Here

 
  @Override
  public void mouseMoveEvent(QGraphicsSceneMouseEvent event) {
    QPointF mousePos = event.scenePos();
    if (device != null) {
      Tile tile = getTile(mousePos.x(), mousePos.y());
      if(tile != null){
        String tileName = device.getPartName() + " | " +  tile.getName() +
        " | " + tile.getType() + " (" + currX + "," + currY + ")";
        this.updateStatus.emit(tileName, tile);
        prevX = currX;
        prevY = currY;
      }
    }
View Full Code Here

    switchboxTypes = moduleInstance.getDesign().getDevice().getSwitchMatrixTypes();
    HashSet<Tile> occupiedTiles = new HashSet<Tile>();
    HashSet<Tile> tilesWithSLICEM = new HashSet<Tile>();
    Collection<Instance> instances = null;
    Collection<Net> nets = null;
    Tile anchorTile = null;
    int minRow = Integer.MAX_VALUE;
    int minCol = Integer.MAX_VALUE;
    int maxRow = -1;
    int maxCol = -1;
    if (moduleInstance.getInstances().get(0).isPlaced()) {
      instances = moduleInstance.getInstances();
      nets = moduleInstance.getNets();
      anchorTile = moduleInstance.getAnchor().getTile();
    } else {
      instances = moduleInstance.getModule().getInstances();
      nets = moduleInstance.getModule().getNets();
      anchorTile = moduleInstance.getModule().getAnchor().getTile();
    }

    for (Instance inst : instances) {
      Tile tile = inst.getTile();
      if(inst.getType().equals(PrimitiveType.SLICEM)){
        tilesWithSLICEM.add(tile);
      }
      if (!occupiedTiles.contains(tile)) {
        occupiedTiles.add(tile);
        //int col = tile.getColumn();
        //int row = tile.getRow();
        int col = scene.getDrawnTileX(tile);
        int row = scene.getDrawnTileY(tile);

        maxCol = (maxCol >= col) ? maxCol : col;
        maxRow = (maxRow >= row) ? maxRow : row;
        String tileTypeStr = tile.getType().toString();
        if (tileTypeStr.startsWith("BRAM")
            || tileTypeStr.startsWith("DSP")) {
          row = row - 3;
        }
        minCol = (minCol <= col) ? minCol : col;
        minRow = (minRow <= row) ? minRow : row;
      }
    }
    for (Net net : nets) {
      for (PIP pip : net.getPIPs()) {
        Tile tile = pip.getTile();
        if (!occupiedTiles.contains(tile) && !tile.getType().equals(TileType.INT_INTERFACE)) {
          occupiedTiles.add(tile);
          //int col = tile.getColumn();
          //int row = tile.getRow();
          int col = scene.getDrawnTileX(tile);
          int row = scene.getDrawnTileY(tile);
          minCol = (minCol <= col) ? minCol : col;
          minRow = (minRow <= row) ? minRow : row;
          maxCol = (maxCol >= col) ? maxCol : col;
          maxRow = (maxRow >= row) ? maxRow : row;
        }
      }
    }

    int widthInTiles = maxCol - minCol + 1;
    int heightInTiles = maxRow - minRow + 1;
    boolean[][] hmTileMap = new boolean[heightInTiles][widthInTiles];
    for (int i = 0; i < heightInTiles; i++) {
      for (int j = 0; j < widthInTiles; j++) {
        hmTileMap[i][j] = false;
      }
    }

    for (Tile tile : occupiedTiles) {
      //int tileX = tile.getColumn() - minCol;
      //int tileY = tile.getRow() - minRow;
      int tileX = scene.getDrawnTileX(tile) - minCol;
      int tileY = scene.getDrawnTileY(tile) - minRow;
      if (tile.getType().toString().startsWith("BRAM")
          || tile.getType().toString().startsWith("DSP")) {
        hmTileMap[tileY][tileX] = true;
        hmTileMap[tileY - 1][tileX] = true;
        hmTileMap[tileY - 2][tileX] = true;
        hmTileMap[tileY - 3][tileX] = true;

      } else if (tileX >= 0 && tileX < widthInTiles && tileY >= 0
          && tileY < heightInTiles) {
        hmTileMap[tileY][tileX] = true;
      }
     
      addHMTile(tile, tileX, tileY, tilesWithSLICEM.contains(tile), tile.equals(anchorTile));
    }

    QPolygonF hmPolygon = createOutline(hmTileMap);
    this.setPolygon(hmPolygon);
    this.moveBy(minCol * scene.tileSize, minRow * scene.tileSize);
 
View Full Code Here

    XilinxConfigurationSpecification spec = DeviceLookup.lookupPartV4V5V6(partName);

    FPGA fpga = new FPGA(spec);
   
    // Pick a tile...
    Tile tile = dev.getTile("CLBLL_X14Y65");
   
    // This class has some internal state
    Virtex5TileTranslation tileTranslator = new Virtex5TileTranslation();
   
    // In order to get the frame, the minor address is needed. 
View Full Code Here

        if(token.equals(PLACED)) state = ParserState.INSTANCE_TILE;
        else if(token.equals(UNPLACED)) state = ParserState.INSTANCE_BONDED;
        else expect("placed or unplaced", token, ParserState.INSTANCE_PLACED);
        break;
      case INSTANCE_TILE:
        Tile tile = dev.getTile(token);
        if(tile == null){
          MessageGenerator.briefErrorAndExit("XDL Design Parser Error in file: "+ fileName +", Invalid tile " +
              token + " on line " + lineNumber);
        }
        state = ParserState.INSTANCE_SITE;
        break;
      case INSTANCE_SITE:
        PrimitiveSite site = dev.getPrimitiveSite(token);
        if(site == null){
          MessageGenerator.briefErrorAndExit("XDL Design Parser Error in file: "+ fileName +", Invalid primitive site " +
              token + " on line " + lineNumber);
        }
        if(currModule != null){
          currInstance.setSite(dev.getPrimitiveSite(token));
        }else{
          currInstance.place(dev.getPrimitiveSite(token));         
        }
        state = ParserState.MODULE_INSTANCE_TOKEN;
        break;
      case INSTANCE_BONDED:
        if(token.equals(COMMA)){
          state = ParserState.MODULE_INSTANCE_TOKEN;
        }
        else if(token.equals(CFG)){
          state = ParserState.ATTRIBUTE;
        }
        else if(token.equals(MODULE)){
          state = ParserState.MODULE_INSTANCE_NAME;
        }
        else if(token.equals(BONDED)){
          currInstance.setBonded(true);
          state = ParserState.MODULE_INSTANCE_TOKEN;
        }
        else if(token.equals(UNBONDED)){
          currInstance.setBonded(false);
          state = ParserState.MODULE_INSTANCE_TOKEN;
        }
        else{
          expect("bonded, unbonded or ,", token, ParserState.INSTANCE_BONDED);
        }
        break;
      case MODULE_INSTANCE_TOKEN:
        if(token.equals(CFG)) state = ParserState.ATTRIBUTE;
        else if(token.equals(MODULE)) state = ParserState.MODULE_INSTANCE_NAME;
        else expect("cfg or module", token, ParserState.MODULE_INSTANCE_TOKEN);
        break;
      case MODULE_INSTANCE_NAME:
        currModuleInstanceName = pool.getUnique(token);
        state = ParserState.MODULE_TEMPLATE_NAME;
        break;
      case MODULE_TEMPLATE_NAME:
        currInstance.setModuleTemplate(design.getModule(token));
        state = ParserState.MODULE_TEMPLATE_INSTANCE_NAME;
        break;
      case MODULE_TEMPLATE_INSTANCE_NAME:
        currInstance.setModuleTemplateInstance(currInstance.getModuleTemplate().getInstance(token));
        ModuleInstance moduleInstance = design.addInstanceToModuleInstances(currInstance, currModuleInstanceName);
        if(currInstance.getModuleTemplateInstance().equals(currInstance.getModuleTemplate().getAnchor())){
          moduleInstance.setAnchor(currInstance);
        }
        state = ParserState.CFG_STRING;
        break;
      case NET_NAME:
        currNet.setName(pool.getUnique(token));
        if(currModule == null) design.addNet(currNet);
        else currModule.addNet(currNet);
        state = ParserState.NET_TYPE;
        break;
      case NET_TYPE:
        if(token.equals(COMMA) || token.equals(WIRE)){
          currNet.setType(NetType.WIRE);
        }
        else if(token.equals(CFG)){
          state = ParserState.ATTRIBUTE;
          break;
        }
        else if(token.equals(GND) || token.equals(GROUND)){
          currNet.setType(NetType.GND);
        }
        else if(token.equals(VCC) || token.equals(POWER)){
          currNet.setType(NetType.VCC);
        }
        else if(token.equals(INPIN)){
          currPin = new Pin();
          currPin.setIsOutputPin(false);
          currNet.addPin(currPin);
          state = ParserState.PIN_INSTANCE_NAME;
          break;
        }
        else if(token.equals(OUTPIN)){
          currPin = new Pin();
          currPin.setIsOutputPin(true);
          if(currNet.getSource() != null){
            MessageGenerator.briefErrorAndExit("XDL Design Parser Error in file: "+ fileName +", The net " +
              currNet.getName() + " has two or more outpins (line " +
              lineNumber + ")");
          }
          currNet.addPin(currPin);
          state = ParserState.PIN_INSTANCE_NAME;
          break;
        }
        else if(token.equals(INOUT)){
          currPin = new Pin();
          currPin.setPinType(PinType.INOUT);
          currNet.addPin(currPin);
          state = ParserState.PIN_INSTANCE_NAME;
          break;
        }
        else{
          expect("wire, vcc or power, gnd or ground or ,",token, ParserState.NET_TYPE);
        }
        state = ParserState.NET_STATEMENT;
        break;
      case NET_STATEMENT:
        if(token.equals(PIP)){
          currPIP = new PIP();
          currNet.addPIP(currPIP);
          state = ParserState.PIP_TILE;
        }
        else if(token.equals(INPIN)){
          currPin = new Pin();
          currPin.setIsOutputPin(false);
          currNet.addPin(currPin);
          state = ParserState.PIN_INSTANCE_NAME;
        }
        else if(token.equals(OUTPIN)){
          currPin = new Pin();
          currPin.setIsOutputPin(true);
          if(currNet.getSource() != null){
            MessageGenerator.briefErrorAndExit("XDL Design Parser Error in file: "+ fileName +", The net " +
              currNet.getName() + " has two or more outpins (line " +
              lineNumber + ")");
          }
          currNet.addPin(currPin);
          state = ParserState.PIN_INSTANCE_NAME;
        }
        else if(token.equals(INOUT)){
          currPin = new Pin();
          currPin.setPinType(PinType.INOUT);
          currNet.addPin(currPin);
          state = ParserState.PIN_INSTANCE_NAME;
          break;
        }
        else if(token.equals(SEMICOLON)){
          state = ParserState.XDL_STATEMENT;
        }
        else if(token.equals(CFG)){
          state = ParserState.ATTRIBUTE;
        }
        break;
      case PIN_INSTANCE_NAME:
        Instance inst;
        if(currModule == null) inst = design.getInstance(token);
        else inst = currModule.getInstance(token);
        if(inst == null){
          MessageGenerator.briefErrorAndExit("ERROR: Could not find instance " +
            token + " on line " + lineNumber);
        }
        currPin.setInstance(inst);
        inst.addToNetList(currNet);
        state = ParserState.PIN_NAME;
        break;
      case PIN_NAME:
        currPin.setPinName(pool.getUnique(token));
        currPin.getInstance().addPin(currPin);
        if(currModule != null){
            modPinMap.put(currPin.getInstanceName() + currPin.getName(), currPin);
        }
        state = ParserState.NET_STATEMENT;
        break;
      case PIP_TILE:
        Tile pipTile = dev.getTile(token);
        if(pipTile == null){
          MessageGenerator.briefErrorAndExit("Invalid tile " +
              token + " on line " + lineNumber);
        }
        currPIP.setTile(pipTile);
View Full Code Here

  /**
   * Moves the cursor to a new tile in the tile array.
   * @param tile The new tile to move the cursor to.
   */
  public void moveToTile(String tile){
    Tile t = design.getDevice().getTile(tile);
    int tileSize = scene.getTileSize();
    QSize size = this.frameSize();
    view.fitInView(scene.getDrawnTileX(t)*tileSize - size.width()/2,
        scene.getDrawnTileY(t)*tileSize - size.height()/2,
        size.width(), size.height(), AspectRatioMode.KeepAspectRatio);
View Full Code Here

      return false;
    }

    // Do some error checking on the newAnchorSite
    PrimitiveSite p = anchor.getPrimitiveSite();
    Tile t = proposedAnchorSite.getTile();
    PrimitiveSite newValidSite = Device.getCorrespondingPrimitiveSite(p, anchor.getType(), t);
    if(!proposedAnchorSite.equals(newValidSite)){
      return false;
    }
   
    //=======================================================//
    /* Check instances at proposed location                  */
    //=======================================================//
    for(Instance inst : getInstances()){
      PrimitiveSite templateSite = inst.getPrimitiveSite();
      Tile newTile = getCorrespondingTile(templateSite.getTile(), proposedAnchorSite.getTile(), dev);
      if(newTile == null){
        return false;
      }
      if(Device.getCorrespondingPrimitiveSite(templateSite, inst.getType(), newTile) == null){
        return false;
View Full Code Here

    int tileYOffset = templateTile.getTileYCoordinate() - anchor.getTile().getTileYCoordinate();
    int newTileX = newAnchorTile.getTileXCoordinate() + tileXOffset;
    int newTileY = newAnchorTile.getTileYCoordinate() + tileYOffset;
    String oldName = templateTile.getName();
    String newName = oldName.substring(0, oldName.lastIndexOf('X')+1) + newTileX + "Y" + newTileY;
    Tile correspondingTile = dev.getTile(newName);
    if(correspondingTile == null){
      if(templateTile.getType().equals(TileType.CLBLL)){
        correspondingTile = dev.getTile("CLBLM_X" + newTileX + "Y" + newTileY);
      }else if(templateTile.getType().equals(TileType.CLBLM)){
        correspondingTile = dev.getTile("CLBLL_X" + newTileX + "Y" + newTileY);
View Full Code Here

      return false;
    }
   
    // Do some error checking on the newAnchorSite
    PrimitiveSite p = module.getAnchor().getPrimitiveSite();
    Tile t = newAnchorSite.getTile();
    PrimitiveSite newValidSite = Device.getCorrespondingPrimitiveSite(p, module.getAnchor().getType(), t);
    if(!newAnchorSite.equals(newValidSite)){
      //MessageGenerator.briefError("New anchor site (" + newAnchorSite.getName() +
      //    ") is incorrect.  Should be " + newValidSite.getName());
      //this.unplace();
      return false;
    }
   
    // save original placement in case new placement is invalid
    HashMap<Instance, PrimitiveSite> originalSites;
    originalSites = isPlaced() ? new HashMap<Instance, PrimitiveSite>() : null;

    //=======================================================//
    /* Place instances at new location                       */
    //=======================================================//
    for(Instance inst : instances){
      PrimitiveSite templateSite = inst.getModuleTemplateInstance().getPrimitiveSite();
      Tile newTile = module.getCorrespondingTile(templateSite.getTile(), newAnchorSite.getTile(), dev);
      PrimitiveSite newSite = Device.getCorrespondingPrimitiveSite(templateSite, inst.getType(), newTile);

      if(newSite == null){
        //MessageGenerator.briefError("ERROR: No matching primitive site found." +
        //  " (Template Primitive:"  + templateSite.getName() +
        //  ", Template Tile:" + templateSite.getTile() +
        //  " => New Primitive:" + newSite + ", New Tile:" + newTile+")");
       
        // revert placement to original placement before method call
        if(originalSites == null){
          unplace();
          return false;
        }
        for(Instance i : originalSites.keySet()){
          design.getInstance(i.getName()).place(originalSites.get(i));
        }
        return false;
      }
     
      if(originalSites != null){
        originalSites.put(inst, inst.getPrimitiveSite());
      }
      inst.place(newSite);
    }
   
    //=======================================================//
    /* Place net at new location                             */
    //=======================================================//
    WireEnumerator we = design.getWireEnumerator();
    int mCout = we.getWireEnum("M_COUT");
    int llCout = we.getWireEnum("LL_COUT");
    int wl5beg_s0 = we.getWireEnum("WL5BEG_S0");
    for(Net net : nets){
      net.getPIPs().clear();
      Net templateNet = net.getModuleTemplateNet();
      for(PIP pip : templateNet.getPIPs()){
        Tile templatePipTile = pip.getTile();
        Tile newPipTile = module.getCorrespondingTile(templatePipTile, newAnchorSite.getTile(), dev);
        if(newPipTile == null){
          unplace();
          MessageGenerator.briefError("Warning: Unable to return module instance "+ name +" back to original placement.");
          return false;
        }
        PIP newPip = new PIP(newPipTile, pip.getStartWire(), pip.getEndWire());
        //if(!newPipTile.hasPIP(newPip)){
        //  return false;
        //}
        net.addPIP(newPip);
        // Special cases for Virtex 5
        if(newPip.getStartWire() == mCout && newPipTile.getType().equals(TileType.CLBLL)){
          newPip.setStartWire(llCout);
        }
        else if(newPip.getStartWire() == llCout && newPipTile.getType().equals(TileType.CLBLM)){
          newPip.setStartWire(mCout);
        }
        else if(newPip.getEndWire() == wl5beg_s0){
          TileType check = dev.getTile(newPipTile.getRow(), newPipTile.getColumn()-1).getType();
          TileType check2 = dev.getTile(newPipTile.getRow(), newPipTile.getColumn()-2).getType();
          if(check.equals(TileType.INT_BUFS_R) || check2.equals(TileType.INT_BUFS_R)){
            int currWire = wl5beg_s0;
            WireConnection[] wcs = newPipTile.getWireConnections(currWire);
            Tile currTile = newPipTile;
            while(wcs.length == 1){
              if(wcs[0].isPIP()){
                net.addPIP(new PIP(currTile, currWire, wcs[0].getWire()));
              }
              currTile = wcs[0].getTile(currTile);
              currWire = wcs[0].getWire();
              wcs = currTile.getWireConnections(currWire);
            }
          }
        }
       
      }
View Full Code Here

TOP

Related Classes of edu.byu.ece.rapidSmith.device.Tile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.