Package edu.byu.ece.rapidSmith.design

Examples of edu.byu.ece.rapidSmith.design.Instance


            parts = newParts;
          }
          currElement.setType(parts[2]);
          //System.out.println("line="+line+", parts=" + parts.length);
          if(design != null){
            Instance instance = design.getInstance(parts[4]);
            ((LogicPathElement)currElement).setInstance(instance);
            if(instance == null){
              MessageGenerator.briefErrorAndExit("This instance \"" + parts[4] +
              "\" is null.");
            }
            Pin p = instance.getPin(pinName);
            if(p == null){
              //System.out.println("Problem Getting Pin: " + parts[1]);
              //System.out.println("Line: " + line);
              //System.exit(1);
            }
View Full Code Here


    return isValidlyPlaced;
  }

 
  public void setAnchorOffset() {
    Instance anchorInst = null;
    if (moduleInstance.getInstances().get(0).isPlaced()) {
      anchorInst  = moduleInstance.getAnchor();
    } else {
      anchorInst = moduleInstance.getModule().getAnchor();
    }
    //int x = anchorInst.getTile().getColumn();
    //int y = anchorInst.getTile().getRow();
    int x = scene.getDrawnTileX(anchorInst.getTile());
    int y = scene.getDrawnTileY(anchorInst.getTile());
    this.anchorOffset = (new QPointF(x*scene.tileSize,y*scene.tileSize)).subtract(this.pos());
  }
 
View Full Code Here

              break;
            }
          }
        }
        if(!foundBadInstance){
          Instance newSLICE = createRegisterSlice(inst.getName());
          placeStaticSlice(newSLICE, false);
          newSLICE.setNetList(inst.getNetList());
          instancesToRemove.add(inst);
          instancesToAdd.add(newSLICE);
          for(Net net : inst.getNetList()){
            net.getPIPs().clear();
            for(Pin pin : net.getPins()){
              if(pin.getInstance().equals(inst)){
                pin.setInstance(newSLICE);
                String pinName = pin.getName();
                if(design.getExactFamilyName().contains("virtex4")){
                  if(pinName.equals("CE1")) pin.setPinName("CE");
                  if(pinName.equals("D")) pin.setPinName("BY");
                  if(pinName.equals("Q1")) pin.setPinName("YQ");
                }else if(design.getExactFamilyName().contains("virtex5")){
                  //TODO V5
                  if(pinName.equals("CE1")) pin.setPinName("CE");
                  if(pinName.equals("D")) pin.setPinName("DX");
                  if(pinName.equals("Q1")) pin.setPinName("DQ");
                }
              }
            }
          }
        }
      }
      else if(inst.getType().equals(PrimitiveType.OLOGIC)){
        boolean foundBadInstance = false;
        if(inst.getName().contains("XDL_DUMMY_IOI")){
          for(Attribute attr : inst.getAttributes()){
            if(attr.getPhysicalName().equals("_NO_USER_LOGIC")){
              foundBadInstance = true;
              instancesToRemove.add(inst);
              break;
            }
          }
        }
        if(!foundBadInstance){
          Instance newSLICE = createRegisterSlice(inst.getName());
          placeStaticSlice(newSLICE, false);
          newSLICE.setNetList(inst.getNetList());
          instancesToRemove.add(inst);
          instancesToAdd.add(newSLICE);
          for(Net net : inst.getNetList()){
            net.getPIPs().clear();
            for(Pin pin : net.getPins()){
View Full Code Here

   * Creates a register slice
   * @param name
   * @return the newly created slice instance
   */
  private Instance createRegisterSlice(String name){
    Instance inst = new Instance();
    inst.setName(name);
    inst.setType(PrimitiveType.SLICEL);
    if(design.getExactFamilyName().contains("virtex4")){
      inst.getAttributes().add(new Attribute("DYMUX","","BY"));
      inst.getAttributes().add(new Attribute("FFY","","#FF"));
      inst.getAttributes().add(new Attribute("FFY_INIT_ATTR","","INIT0"));
      inst.getAttributes().add(new Attribute("FFY_SR_ATTR","","SRLOW"));
      inst.getAttributes().add(new Attribute("SYNC_ATTR","","SYNC"));
    }else if(design.getExactFamilyName().contains("virtex5")){
      //TODO V5
      //might need?: inst.getAttributes().add(new Attribute("CEUSED","","0"));
      inst.getAttributes().add(new Attribute("DFFMUX","","DX"));
      inst.getAttributes().add(new Attribute("DFF","","#FF"));
      inst.getAttributes().add(new Attribute("DFFINIT","","INIT0"));
      inst.getAttributes().add(new Attribute("DFFSR","","SRLOW"));
      inst.getAttributes().add(new Attribute("SYNC_ATTR","","SYNC"));
    }
    return inst;
  }
View Full Code Here

          }
          instancesToRemove.add(pin.getInstance());
         
          // Create New Net and static SLICE source with Pin connected to static SLICE
          Net newNet = new Net(pin.getInstance().getName() +"_"+ net.getType(), NetType.WIRE);
          Instance inst = createStaticSliceSource(net.getType());
          placeStaticSlice(inst, true);
          Pin newPin = null;
          if(design.getExactFamilyName().contains("virtex4")){
             newPin = new Pin(true,"Y",inst);
          }else if(design.getExactFamilyName().contains("virtex5")){
            //TODO V5
            newPin = new Pin(true,"D",inst);
          }
          newNet.replaceSource(newPin);
          netsToAdd.add(newNet);
          instancesToAdd.add(inst);
          Port newPort = new Port(pin.getInstance().getName()+"_outport",newPin);
          hardMacro.getPorts().add(newPort);
          newPin.setPort(newPort);
        }
      }
    }
    else{ // This is just a single IOB
      // There should only be 1 pin
      Pin pin = pins.get(0);
      // Remove IOB
      if(isTriState(pin.getInstance())){
        failGracefully("Sorry, this design contains tri-state IO.  Tri-state IO is not yet supported by the HMG.");
      }
      instancesToRemove.add(pin.getInstance());
      net.getPins().remove(pin);
      net.getPIPs().clear();
     
      if(pin.isOutPin()){
        // Check if this net drives the BUFG, if so, we don't want to create any ports
        // We'll do that with the output of the BUFG
        for(Pin p : net.getPins()){
          if(p.getInstance().getType().equals(PrimitiveType.BUFG)){
            netsToRemove.add(net);
            return;
          }
        }
        // CASE 1:
        // CASE 2:
        // Now create a port, we just choose an arbitrary one if there are more than one
        Pin p = net.getPins().get(0);
        //XDL_Pin p = pins.get(0); -- This is wrong here because we already removed this pin
        Port newPort = new Port(pin.getInstance().getName()+"_inport",p);
        hardMacro.addPort(newPort);
        p.setPort(newPort);
      }
      else{
        // Check if this is a static net
        if(net.isStaticNet()){
          if(!net.getSource().getInstance().getType().equals(PrimitiveType.TIEOFF)){
            failAndExit("2. This case is unexpected. Talk to Chris about getting it implemented.");
          }
         
          instancesToRemove.add(net.getSource().getInstance());
          netsToRemove.add(net);
         
          // Create New Net and static SLICE source with Pin connected to static SLICE
          Net newNet = new Net(pin.getInstance().getName() + "_" + net.getType(),NetType.WIRE);
          Instance inst = createStaticSliceSource(net.getType());
          placeStaticSlice(inst, true);
          Pin newPin = null;
          if(design.getExactFamilyName().contains("virtex4")){
             newPin = new Pin(true,"Y",inst);
          }else if(design.getExactFamilyName().contains("virtex5")){
View Full Code Here

   
    for(Pin pin : pins){
      // For each output IOB, create a new LUT and net
      if(!pin.isOutPin()){
        Net newOutputNet = new Net();
        Instance newLUT = createPassThruSlice();
        placeStaticSlice(newLUT, true);
        instancesToAdd.add(newLUT);
        newOutputNet.setName(net.getName() + "_OUTPUT");
        Pin newLUTPin = null;
        if(design.getExactFamilyName().contains("virtex4")){
View Full Code Here

   * the type
   * @param netType Valid types are "gnd" and "vcc"
   * @return The newly create instance
   */
  private Instance createStaticSliceSource(NetType netType){
    Instance inst = new Instance();
    inst.setName("RS_DUMMY_CLB");
    inst.setType(PrimitiveType.SLICEL);
    if(design.getExactFamilyName().contains("virtex4")){
      inst.getAttributes().add(new Attribute("G","","#LUT:D=" + (netType.equals(NetType.GND) ? "0" :"1")));
      inst.getAttributes().add(new Attribute("YUSED","","0"));
    }else if(design.getExactFamilyName().contains("virtex5")){
      //TODO V5
      inst.getAttributes().add(new Attribute("DUSED","","0"));
      inst.getAttributes().add(new Attribute("D6LUT","","#LUT:O6=" + (netType.equals(NetType.GND) ? "0" :"1")));
    }
    return inst;
  }
View Full Code Here

  /**
   * Creates a slice for a signal to pass through
   * @return the slice
   */
  private Instance createPassThruSlice(){
    Instance inst = new Instance();
    inst.setName("XDL_LUT");
    inst.setType(PrimitiveType.SLICEL);
    if(design.getExactFamilyName().contains("virtex4")){
      inst.getAttributes().add(new Attribute("YUSED","","0"));
      inst.getAttributes().add(new Attribute("G","","#LUT:D=A1"));     
    }else if(design.getExactFamilyName().contains("virtex5")){
      //TODO V5
      inst.getAttributes().add(new Attribute("DUSED","","0"));
      inst.getAttributes().add(new Attribute("D6LUT","","#LUT:O6=A1"));
    }
    return inst;
  }
View Full Code Here

          }
          //check instList
          HashMap<String,Instance> instanceMap = xdl2.getInstanceMap();
          for(Instance inst1:xdl1.getInstances()){
            if(instanceMap.containsKey(inst1.getName())){
              Instance inst2 = instanceMap.remove(inst1.getName());
              if(inst1.toString().compareTo(inst2.toString()) != 0){
                status("Instance "+inst1.getName()+" from design " + xdl1.getName() + " was configured differently in design " + xdl2.getName() + ".");
                status(inst1.toString());
                status(inst2.toString());
                return false;
              }
            }else{
              status("Instance "+inst1.getName()+" from design " + xdl1.getName() + " was not found in design " + xdl2.getName() + ".");
              return false;
View Full Code Here

          else design.addAttribute(attribute);
        }
        break;
      case XDL_STATEMENT:
        if(token.equals(INST)|| token.equals(INSTANCE)){
          currInstance = new Instance();
          state = ParserState.INSTANCE_NAME;
        }
        else if(token.equals(NET)){
          currNet = new Net();
          state = ParserState.NET_NAME;
        }
        else if(token.equals(MODULE)){
          currModule = new Module();
          modPinMap = new HashMap<String, Pin>();
          portNames = new ArrayList<String>();
          portInstanceNames = new ArrayList<String>();
          portPinNames = new ArrayList<String>();
          state = ParserState.MODULE_NAME;
        }
        else if(token.equals(ENDMODULE)){
          state = ParserState.END_MODULE_NAME;
        }
        else{
          expect("inst, net, module or endmodule", token, ParserState.XDL_STATEMENT);
        }
        break;
      case INSTANCE_NAME:
        currInstance.setName(pool.getUnique(token));
        currInstance.setDesign(design);
        if(currModule == null){
          design.addInstance(currInstance);
        }
        else{
          currModule.addInstance(currInstance);
          currInstance.setModuleTemplate(currModule);
          if(currInstance.getName().equals(currModuleAnchorName)){
            currModule.setAnchor(currInstance);
          }
        }
        state = ParserState.INSTANCE_TYPE;
        break;
      case INSTANCE_TYPE:
          PrimitiveType t = Utils.createPrimitiveType(token);
          if(t == null){
            MessageGenerator.briefErrorAndExit("XDL Design Parser Error in file: "+ fileName +", Failed parsing Instance type: \"" + token + "\"");
          }
          currInstance.setType(t);
          state = ParserState.INSTANCE_PLACED;
        break;
      case INSTANCE_PLACED:
        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);
        state = ParserState.PIP_WIRE0;
        break;
      case PIP_WIRE0:
        int wire0 = we.getWireEnum(token);
        if(wire0 == -1) {
          MessageGenerator.briefErrorAndExit("ERROR: Invalid wire: " +
              token + " found on line " + lineNumber);
        }
        currPIP.setStartWire(wire0);
        state = ParserState.PIP_CONN_TYPE;
        break;
      case PIP_CONN_TYPE:
        if(token.equals(PIP0) || token.equals(PIP1) || token.equals(PIP2) || token.equals(PIP3)){
          state = ParserState.PIP_WIRE1;
        }
        else{
          expect("->, =-, ==, or =>", token, ParserState.PIP_CONN_TYPE);
        }
        break;
      case PIP_WIRE1:
        int wire1 = we.getWireEnum(token);
        if(wire1 == -1) {
          MessageGenerator.briefErrorAndExit("XDL Design Parser Error in file: "+ fileName +", Invalid wire: " +
              token + " found on line " + lineNumber);
        }
        currPIP.setEndWire(wire1);
        state = ParserState.NET_STATEMENT;
        break;
      case MODULE_NAME:
        currModule.setName(pool.getUnique(token));
        state = ParserState.MODULE_ANCHOR_NAME;
        break;
      case MODULE_ANCHOR_NAME:
        currModuleAnchorName = pool.getUnique(token);
        state = ParserState.CFG_STRING;
        break;
      case MODULE_STATEMENT:
        if(token.equals(PORT)){
          state = ParserState.PORT_NAME;
        }
        if(token.equals(INST)|| token.equals(INSTANCE)){
          currInstance = new Instance();
          state = ParserState.INSTANCE_NAME;
        }
        else if(token.equals(NET)){
          currNet = new Net();
          state = ParserState.NET_NAME;
View Full Code Here

TOP

Related Classes of edu.byu.ece.rapidSmith.design.Instance

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.