📄 getnetlist.java
字号:
private ExtNode extractAddNode(ExtNode simNode, SCNiTree node, SCNiPort port) { ExtPort newPort = new ExtPort(); if (simNode == null) { simNode = new ExtNode(); simNode.firstPort = newPort; simNode.flags = 0; simNode.ptr = null; simNode.name = null; newPort.node = node; newPort.port = port; if (port != null) port.extNode = simNode; newPort.next = null; simNode.next = curSCCell.exNodes; curSCCell.exNodes = simNode; } else { newPort.node = node; newPort.port = port; if (port != null) port.extNode = simNode; newPort.next = simNode.firstPort; simNode.firstPort = newPort; } return simNode; } /** * Method to find the implicit power and ground ports. * Does a search of the instance tree and adds to the appropriate port list. * Skips over the dummy ground and power instances and special cells. */ private void extractFindPower(SCCell cell, SCCell vars) { for (SCNiTree ntp : cell.niList) { // process node if (ntp.number > PWR) { switch (ntp.type) { case COMPLEXCELL: break; case SPECIALCELL: break; case LEAFCELL: for (SCNiPort port = ntp.ground; port != null; port = port.next) { ExtPort pList = new ExtPort(); pList.node = ntp; pList.port = port; port.extNode = vars.ground; pList.next = vars.ground.firstPort; vars.ground.firstPort = pList; } for (SCNiPort port = ntp.power; port != null; port = port.next) { ExtPort pList = new ExtPort(); pList.node = ntp; pList.port = port; port.extNode = vars.power; pList.next = vars.power.firstPort; vars.power.firstPort = pList; } break; default: break; } } } } /**************************************** PLACEMENT ****************************************/ /** * Method to flatten all complex cells in the current cell. * It does this by creating instances of all instances from the * complex cells in the current cell. To insure the uniqueness of all * instance names, the new instances have names "parent_inst.inst" * where "parent_inst" is the name of the instance being expanded and * "inst" is the name of the subinstance being pulled up. */ private String pull() { // check if a cell is currently selected if (curSCCell == null) return "No cell selected"; // remember the original ones and delete them later List<SCNiTree> cellList = new ArrayList<SCNiTree>(); for (SCNiTree inst : curSCCell.niList) { if (inst.type == COMPLEXCELL) cellList.add(inst); } // expand all instances of complex cell type for (SCNiTree inst : cellList) { String err = pullInst(inst, curSCCell); if (err != null) return err; } // now remove the original ones List<SCNiTree> deleteList = new ArrayList<SCNiTree>(); for (SCNiTree inst : curSCCell.niList) { if (inst.type == COMPLEXCELL) deleteList.add(inst); } for (SCNiTree inst : deleteList) { curSCCell.niList.remove(inst); } return null; } /** * Method to pull the indicated instance of a complex cell into the indicated parent cell. * @param inst instance to be pulled up. * @param cell parent cell. */ private String pullInst(SCNiTree inst, SCCell cell) { SCCell subCell = (SCCell)inst.np; // first create components for (SCNiTree subInst : subCell.niList) { if (subInst.type != SPECIALCELL) { List<String> createPars = new ArrayList<String>(); createPars.add("create"); createPars.add("instance"); createPars.add(inst.name + "." + subInst.name); if (subInst.type == LEAFCELL) { createPars.add(((Cell)subInst.np).getName()); } else { createPars.add(((SCCell)subInst.np).name); } String err = create(createPars); if (err != null) return err; } } // create connections among these subinstances by using the // subCell's extracted node list. Also resolve connections // to the parent cell instances by using exported port info. for (ExtNode eNode = subCell.exNodes; eNode != null; eNode = eNode.next) { ExtNode bNode = null; // check if the extracted node is an exported node for (SCNiPort iPort = inst.ports; iPort != null; iPort = iPort.next) { if (((SCPort)(iPort.port)).node.ports.extNode == eNode) { bNode = iPort.extNode; break; } } if (bNode == null) { // this is a new internal node bNode = new ExtNode(); bNode.name = null; bNode.firstPort = null; bNode.ptr = null; bNode.flags = 0; bNode.next = cell.exNodes; cell.exNodes = bNode; } // add ports to extracted node bNode for (ExtPort ePort = eNode.firstPort; ePort != null; ePort = ePort.next) { // only add leaf cells or complex cells if (ePort.node.type != SPECIALCELL) { ExtPort nport = new ExtPort(); nport.node = findNi(cell, inst.name + "." + ePort.node.name); // add reference to extracted node to instance port list for (SCNiPort iPort = nport.node.ports; iPort != null; iPort = iPort.next) { if (iPort.port == ePort.port.port) { nport.port = iPort; iPort.extNode = bNode; nport.next = bNode.firstPort; bNode.firstPort = nport; break; } } } } } // add power ports for new instances for (ExtPort ePort = subCell.power.firstPort; ePort != null; ePort = ePort.next) { if (ePort.node.type == SPECIALCELL) continue; ExtPort nport = new ExtPort(); nport.node = findNi(cell, inst.name + "." + ePort.node.name); // add reference to extracted node to instance port list SCNiPort iPort; for (iPort = nport.node.ports; iPort != null; iPort = iPort.next) { if (iPort.port == ePort.port.port) { nport.port = iPort; iPort.extNode = cell.power; break; } } if (iPort == null) { for (iPort = nport.node.power; iPort != null; iPort = iPort.next) { if (iPort.port == ePort.port.port) { nport.port = iPort; iPort.extNode = cell.power; break; } } } nport.next = cell.power.firstPort; cell.power.firstPort = nport; } // remove references to original instance in power list ExtPort nPort = cell.power.firstPort; for (ExtPort ePort = cell.power.firstPort; ePort != null; ePort = ePort.next) { if (ePort.node == inst) { if (ePort == nPort) { cell.power.firstPort = ePort.next; nPort = ePort.next; } else { nPort.next = ePort.next; } } else { nPort = ePort; } } // add ground ports for (ExtPort ePort = subCell.ground.firstPort; ePort != null; ePort = ePort.next) { if (ePort.node.type == SPECIALCELL) continue; nPort = new ExtPort(); nPort.node = findNi(cell, inst.name + "." + ePort.node.name); // add reference to extracted node to instance port list SCNiPort iPort; for (iPort = nPort.node.ports; iPort != null; iPort = iPort.next) { if (iPort.port == ePort.port.port) { nPort.port = iPort; iPort.extNode = cell.ground; break; } } if (iPort == null) { for (iPort = nPort.node.ground; iPort != null; iPort = iPort.next) { if (iPort.port == ePort.port.port) { nPort.port = iPort; iPort.extNode = cell.ground; break; } } } nPort.next = cell.ground.firstPort; cell.ground.firstPort = nPort; } // remove references to original instance in ground list nPort = cell.ground.firstPort; for (ExtPort ePort = cell.ground.firstPort; ePort != null; ePort = ePort.next) { if (ePort.node == inst) { if (ePort == nPort) { cell.ground.firstPort = ePort.next; nPort = ePort.next; } else { nPort.next = ePort.next; } } else { nPort = ePort; } } // remove references to instance in exported node list for (ExtNode eNode = cell.exNodes; eNode != null; eNode = eNode.next) { nPort = eNode.firstPort; for (ExtPort ePort = eNode.firstPort; ePort != null; ePort = ePort.next) { if (ePort.node == inst) { if (ePort == nPort) { eNode.firstPort = ePort.next; nPort = ePort.next; } else { nPort.next = ePort.next; } } else { nPort = ePort; } } } // find the value of the largest generically named extracted node int oldNum = 0; for (ExtNode eNode = cell.exNodes; eNode != null; eNode = eNode.next) { if (eNode.name != null) { int sPtr = 0; char firstCh = eNode.name.charAt(0); if (Character.toUpperCase(firstCh) == 'N') { sPtr++; while (sPtr < eNode.name.length()) { if (!Character.isDigit(eNode.name.charAt(sPtr))) break; sPtr++; } if (sPtr >= eNode.name.length()) { int newnum = TextUtils.atoi(eNode.name.substring(1)); if (newnum > oldNum) oldNum = newnum; } } } } // set the name of any unnamed nodes for (ExtNode eNode = cell.exNodes; eNode != null; eNode = eNode.next) { if (eNode.name == null) { eNode.name = "n" + (++oldNum); } } // flatten any subinstances which are also complex cells for (SCNiTree subInst : subCell.niList) { if (subInst.type == COMPLEXCELL) { SCNiTree ninst = findNi(cell, inst.name + "." + subInst.name); String err = pullInst(ninst, cell); if (err != null) return err; } } return null; }//// /***********************************************************************// Module: Sc_extract_print_nodes// ------------------------------------------------------------------------// Description:// Print the common nodes found.// ------------------------------------------------------------------------// *///// void Sc_extract_print_nodes(SCCell *vars)// {// int i;// ExtNode *simNode;// ExtPort *pList;// CHAR *portname;//// i = 0;// if (vars->ground)// {// ttyputmsg(M_("Node %d %s:"), i, vars->ground->name);// for (pList = vars->ground->firstPort; pList; pList = pList->next)// {// switch (pList->node->type)// {// case SPECIALCELL:// portname = M_("Special");// break;// case COMPLEXCELL:// portname = ((SCPort *)(pList->port->port))->name;// break;// case LEAFCELL:// portname = Sc_leaf_port_name(pList->port->port);// break;// default:// portname = M_("Unknown");// break;// }// ttyputmsg(x_(" %-20s %s"), pList->node->name, portname);// }// }// i++;//// if (vars->power)// {// ttyputmsg(M_("Node %d %s:"), i, vars->power->name);// for (pList = vars->power->firstPort; pList; pList = pList->next)// {// switch (pList->node->type)// {// case SPECIALCELL:// portname = M_("Special");// break;// case COMPLEXCELL:// portname = ((SCPort *)(pList->port->port))->name;// break;// case LEAFCELL:// portname = Sc_leaf_port_name(pList->port->port);// break;// default:// portname = M_("Unknown");// break;// }// ttyputmsg(x_(" %-20s %s"), pList->node->name, portname);// }// }// i++;//// for (simNode = vars->exNodes; simNode; simNode = simNode->next)// {// ttyputmsg(M_("Node %d %s:"), i, simNode->name);// for (pList = simNode->firstPort; pList; pList = pList->next)// {// switch (pList->node->type)// {// case SPECIALCELL:// portname = M_("Special");// break;// case COMPLEXCELL:// portname = ((SCPort *)(pList->port->port))->name;// break;// case LEAFCELL:// portname = Sc_leaf_port_name(pList->port->port);// break;// default:// portname = M_("Unknown");// break;// }// ttyputmsg(x_(" %-20s %s"), pList->node->name, portname);// }// i++;// }// }// /** * Method to collect the unconnected ports and create an extracted node for each. */ private void extractCollectUnconnected(SCCell cell) { for (SCNiTree nPtr : cell.niList) { // process node switch (nPtr.type) { case COMPLEXCELL: case LEAFCELL: for (SCNiPort port = nPtr.ports; port != null; port = port.next) { if (port.extNode == null) { ExtNode ext = new ExtNode(); ext.name = null; ExtPort ePort = new ExtPort(); ePort.node = nPtr; ePort.port = port; ePort.next = null; ext.firstPort = ePort; ext.flags = 0; ext.ptr = null; ext.next = cell.exNodes; cell.exNodes = ext; port.extNode = ext; } } break; default: break; } } } /** * Method to return the type of the leaf port. * @param leafPort pointer to leaf port. * @return type of port. */ static int getLeafPortType(Export leafPort) { if (leafPort.isPower()) return PWRPORT; if (leafPort.isGround()) return GNDPORT; if (leafPort.getCharacteristic() == PortCharacteristic.BIDIR) return BIDIRPORT; if (leafPort.getCharacteristic() == PortCharacteristic.OUT) return OUTPORT; if (leafPort.getCharacteristic() == PortCharacteristic.IN) return INPORT; return UNPORT; } /** * Method to return the directions that a port can be attached to. * Values can be up, down, left, right. */ static int getLeafPortDirection(PortProto port) { return PORTDIRUP | PORTDIRDOWN; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -