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);