Example #1
0
 private Global globalInst(ImmutableNodeInst n) {
   if (!(n.protoId instanceof PrimitiveNodeId)) {
     return null;
   }
   PrimitiveNode pn = techPool.getPrimitiveNode((PrimitiveNodeId) n.protoId);
   if (pn == Schematics.tech().groundNode) {
     return Global.ground;
   }
   if (pn == Schematics.tech().powerNode) {
     return Global.power;
   }
   if (pn == Schematics.tech().globalNode) {
     String globalName = n.getVarValue(Schematics.SCHEM_GLOBAL_NAME, String.class);
     if (globalName != null) {
       return Global.newGlobal(globalName);
     }
   }
   return null;
 }
Example #2
0
  private void initNodables() {
    Global.Buf globalBuf = new Global.Buf();
    Map<ImmutableNodeInst, Set<Global>> nodeInstExcludeGlobal = null;
    for (int i = 0; i < numNodes; i++) {
      ImmutableNodeInst n = nodes.get(i);
      //            NodeProto np = ni.getProto();
      //            NetCell netCell = null;
      //            if (ni.isCellInstance()) {
      //                netCell = networkManager.getNetCell((Cell) np);
      //            }
      if (n.protoId instanceof CellId
          && (((CellId) n.protoId).isIcon() || ((CellId) n.protoId).isSchematic())) {
        if (n.name.hasDuplicates()) {
          String msg = cellId + ": Node name <" + n.name + "> has duplicate subnames";
          System.out.println(msg);
          //                    networkManager.pushHighlight(ni);
          //                    networkManager.logError(msg, NetworkTool.errorSortNodes);
        }
      } else {
        if (n.name.isBus()) {
          String msg = cellId + ": Array name <" + n.name + "> can be assigned only to icon nodes";
          System.out.println(msg);
          //                    networkManager.pushHighlight(ni);
          //                    networkManager.logError(msg, NetworkTool.errorSortNodes);
        }
      }
      if (n.protoId instanceof CellId) {
        CellId subCellId = (CellId) n.protoId;
        if (!(subCellId.isIcon() || subCellId.isSchematic())) {
          continue;
        }
        if (isIconOfParent(n)) {
          continue;
        }
        EquivalentSchematicExports netEq = getEquivExports((CellId) n.protoId);
        EquivalentSchematicExports schemEq = netEq.implementation;
        assert schemEq != null && schemEq.getCellId() != cellId;
        Global.Set gs = schemEq.getGlobals();

        // Check for rebinding globals
        if (schemEq.implementation.globalPartitions != null) {
          int numPortInsts = getNumPorts(n.protoId);
          Set<Global> gb = null;
          for (int j = 0; j < numPortInsts; j++) {
            PortInst pi = new PortInst(n.nodeId, getPortIdByIndex(n.protoId, j));
            int piOffset = pi.getPortInstOffset();
            int drawn = drawns[piOffset];
            if (drawn < 0 || drawn >= numConnectedDrawns) {
              continue;
            }
            ImmutableExport e = netEq.exports.get(j);
            assert e.exportId == pi.portId;
            Name busName = e.name;
            for (int busIndex = 0; busIndex < busName.busWidth(); busIndex++) {
              Name exportName = busName.subname(busIndex);
              Global.Set globalsOnElement = schemEq.globalPartitions.get(exportName);
              if (globalsOnElement == null) {
                continue;
              }
              if (gb == null) {
                gb = new HashSet<Global>();
              }
              for (int l = 0; l < globalsOnElement.size(); l++) {
                Global g = globalsOnElement.get(l);
                gb.add(g);
              }
            }
          }
          if (gb != null) {
            // remember excluded globals for this NodeInst
            if (nodeInstExcludeGlobal == null) {
              nodeInstExcludeGlobal = new HashMap<ImmutableNodeInst, Set<Global>>();
            }
            nodeInstExcludeGlobal.put(n, gb);
            // fix Set of globals
            gs = gs.remove(gb.iterator());
          }
        }

        String errorMsg = globalBuf.addToBuf(gs);
        if (errorMsg != null) {
          String msg =
              "Network: " + cellId + " has globals with conflicting characteristic " + errorMsg;
          System.out.println(msg);
          //                        networkManager.logError(msg, NetworkTool.errorSortNetworks);
          // TODO: what to highlight?
          // log.addGeom(shared[i].nodeInst, true, 0, null);
        }
      } else {
        Global g = globalInst(n);
        if (g != null) {
          PortCharacteristic characteristic;
          if (g == Global.ground) {
            characteristic = PortCharacteristic.GND;
          } else if (g == Global.power) {
            characteristic = PortCharacteristic.PWR;
          } else {
            characteristic = PortCharacteristic.findCharacteristic(n.techBits);
            if (characteristic == null) {
              String msg =
                  "Network: "
                      + cellId
                      + " has global "
                      + g.getName()
                      + " with unknown characteristic bits";
              System.out.println(msg);
              //                            networkManager.pushHighlight(ni);
              //                            networkManager.logError(msg,
              // NetworkTool.errorSortNetworks);
              characteristic = PortCharacteristic.UNKNOWN;
            }
          }
          String errorMsg = globalBuf.addToBuf(g, characteristic);
          if (errorMsg != null) {
            String msg =
                "Network: " + cellId + " has global with conflicting characteristic " + errorMsg;
            System.out.println(msg);
            //                        networkManager.logError(msg, NetworkTool.errorSortNetworks);
            // log.addGeom(shared[i].nodeInst, true, 0, null);
          }
        }
      }
    }
    globals = globalBuf.getBuf();
    //        boolean changed = false;
    //        if (globals != newGlobals) {
    //            changed = true;
    //            globals = newGlobals;
    //            if (NetworkTool.debug) {
    //                System.out.println(cell + " has " + globals);
    //            }
    //        }
    int mapOffset = portOffsets[0] = globals.size();
    for (int i = 1; i <= numExports; i++) {
      ImmutableExport export = exports.get(i - 1);
      if (DEBUG) {
        System.out.println(export + " " + portOffsets[i - 1]);
      }
      mapOffset += export.name.busWidth();
      //            if (portOffsets[i] != mapOffset) {
      //                changed = true;
      portOffsets[i] = mapOffset;
      //            }
    }
    equivPortsN = new int[mapOffset];
    equivPortsP = new int[mapOffset];
    equivPortsA = new int[mapOffset];

    for (int i = 0; i < numDrawns; i++) {
      drawnOffsets[i] = mapOffset;
      mapOffset += drawnWidths[i];
      if (DEBUG) {
        System.out.println("Drawn " + i + " has offset " + drawnOffsets[i]);
      }
    }
    iconInsts = new IconInst[numNodes];
    iconInstExcludeGlobals = null;
    for (int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
      ImmutableNodeInst n = nodes.get(nodeIndex);
      if (!(n.protoId instanceof CellId)) {
        continue;
      }
      CellId subCellId = (CellId) n.protoId;
      if (!subCellId.isIcon() && !subCellId.isSchematic()) {
        continue;
      }
      IconInst iconInst = new IconInst(n, mapOffset);
      iconInsts[nodeIndex] = iconInst;
      if (isIconOfParent(n)) {
        continue;
      }
      EquivalentSchematicExports netEq = iconInst.eq;
      EquivalentSchematicExports schemEq = netEq.implementation;
      assert schemEq != null;
      Set<Global> gs =
          nodeInstExcludeGlobal != null
              ? nodeInstExcludeGlobal.get(n)
              : null; // exclude set of globals
      if (gs != null) {
        if (iconInstExcludeGlobals == null) {
          iconInstExcludeGlobals = new IdentityHashMap<IconInst, Set<Global>>();
        }
        iconInstExcludeGlobals.put(iconInst, gs);
      }

      assert iconInst.numExtendedExports == schemEq.equivPortsN.length;
      mapOffset += iconInst.numExtendedExports * n.name.busWidth();
    }
    netNamesOffset = mapOffset;
    if (DEBUG) {
      System.out.println("netNamesOffset=" + netNamesOffset);
    }
  }