Program: 31089
Project: 31089
Buggy source:
private boolean GenerateNetlist(FPGAReport Reporter,String HDLIdentifier){
  GridBagConstraints gbc=new GridBagConstraints();
  JFrame panel=new JFrame("String_Node_Str" + MyCircuit.getName());
  panel.setResizable(false);
  panel.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  GridBagLayout thisLayout=new GridBagLayout();
  panel.setLayout(thisLayout);
  JLabel LocText=new JLabel("String_Node_Str" + MyCircuit.getName());
  gbc.gridx=0;
  gbc.gridy=0;
  gbc.fill=GridBagConstraints.HORIZONTAL;
  panel.add(LocText,gbc);
  JProgressBar progres=new JProgressBar(0,7);
  progres.setValue(0);
  progres.setStringPainted(true);
  gbc.gridx=0;
  gbc.gridy=1;
  gbc.fill=GridBagConstraints.HORIZONTAL;
  panel.add(progres,gbc);
  panel.pack();
  panel.setLocation(Projects.getCenteredLoc(panel.getWidth(),panel.getHeight()));
  panel.setVisible(true);
  CircuitName=MyCircuit.getName();
  wires.clear();
  wires.addAll(MyCircuit.getWires());
  while (wires.size() != 0) {
    Net NewNet=new Net();
    GetNet(null,NewNet);
    if (!NewNet.isEmpty()) {
      MyNets.add(NewNet);
    }
  }
  Set<Component> components=MyCircuit.getNonWires();
  Set<Location> OutputsList=new HashSet<Location>();
  Set<Location> InputsList=new HashSet<Location>();
  Set<Component> TunnelList=new HashSet<Component>();
  Set<Component> SplitterList=new HashSet<Component>();
  for (  Component com : components) {
    if (!(com.getFactory() instanceof SplitterFactory) && !(com.getFactory() instanceof Tunnel) && !(com.getFactory() instanceof PortIO)&& !(com.getFactory() instanceof ReptarLocalBus)) {
      List<EndData> ends=com.getEnds();
      for (      EndData end : ends) {
        if (end.isInput() && end.isOutput()) {
          Reporter.AddFatalError("String_Node_Str" + com.getFactory().getName() + "String_Node_Str"+ MyCircuit.getName()+ "String_Node_Str");
          this.clear();
          panel.dispose();
          return false;
        }
        if (end.isOutput()) {
          OutputsList.add(end.getLocation());
        }
 else {
          InputsList.add(end.getLocation());
        }
      }
    }
 else {
      if (com.getFactory() instanceof SplitterFactory) {
        SplitterList.add(com);
      }
 else       if (com.getFactory() instanceof Tunnel) {
        TunnelList.add(com);
      }
    }
  }
  progres.setValue(1);
  Rectangle ProgRect=progres.getBounds();
  ProgRect.x=0;
  ProgRect.y=0;
  progres.paintImmediately(ProgRect);
  Set<Location> ZeroLengthNets=new HashSet<Location>();
  for (  Component com : components) {
    if ((com.getFactory() instanceof SplitterFactory) || (com.getFactory() instanceof Tunnel)) {
      List<EndData> ends=com.getEnds();
      for (      EndData end : ends) {
        if (InputsList.contains(end.getLocation()) || OutputsList.contains(end.getLocation())) {
          boolean connected=false;
          for (          Net net : MyNets) {
            connected|=net.contains(end.getLocation());
          }
          if (!connected) {
            ZeroLengthNets.add(end.getLocation());
          }
        }
        for (        Component tun : TunnelList) {
          if (!tun.equals(com)) {
            List<EndData> tends=tun.getEnds();
            for (            EndData thisend : tends) {
              if (thisend.getLocation().equals(end.getLocation())) {
                boolean connected=false;
                for (                Net net : MyNets) {
                  connected|=net.contains(end.getLocation());
                }
                if (!connected) {
                  ZeroLengthNets.add(end.getLocation());
                }
              }
            }
          }
        }
        for (        Component tun : SplitterList) {
          if (!tun.equals(com)) {
            List<EndData> tends=tun.getEnds();
            for (            EndData thisend : tends) {
              if (thisend.getLocation().equals(end.getLocation())) {
                boolean connected=false;
                for (                Net net : MyNets) {
                  connected|=net.contains(end.getLocation());
                }
                if (!connected) {
                  ZeroLengthNets.add(end.getLocation());
                }
              }
            }
          }
        }
      }
    }
 else {
      List<EndData> ends=com.getEnds();
      for (      EndData end : ends) {
        if (end.isInput() && OutputsList.contains(end.getLocation())) {
          boolean connected=false;
          for (          Net net : MyNets) {
            connected|=net.contains(end.getLocation());
          }
          if (!connected) {
            ZeroLengthNets.add(end.getLocation());
          }
        }
      }
    }
  }
  InputsList.clear();
  OutputsList.clear();
  for (  Location Loc : ZeroLengthNets) {
    Net NewNet=new Net(Loc);
    MyNets.add(NewNet);
  }
  progres.setValue(2);
  ProgRect=progres.getBounds();
  ProgRect.x=0;
  ProgRect.y=0;
  progres.paintImmediately(ProgRect);
  boolean TunnelsPresent=false;
  for (  Component com : TunnelList) {
    List<EndData> ends=com.getEnds();
    for (    EndData end : ends) {
      for (      Net ThisNet : MyNets) {
        if (ThisNet.contains(end.getLocation())) {
          ThisNet.addTunnel(com.getAttributeSet().getValue(StdAttr.LABEL));
          TunnelsPresent=true;
        }
      }
    }
  }
  if (TunnelsPresent) {
    Iterator<Net> NetIterator=MyNets.listIterator();
    while (NetIterator.hasNext()) {
      Net ThisNet=NetIterator.next();
      if (ThisNet.HasTunnel() && (MyNets.indexOf(ThisNet) < (MyNets.size() - 1))) {
        boolean merged=false;
        Iterator<Net> SearchIterator=MyNets.listIterator(MyNets.indexOf(ThisNet) + 1);
        while (SearchIterator.hasNext() && !merged) {
          Net SearchNet=SearchIterator.next();
          for (          String name : ThisNet.TunnelNames()) {
            if (SearchNet.ContainsTunnel(name) && !merged) {
              merged=true;
              SearchNet.merge(ThisNet);
            }
          }
        }
        if (merged) {
          NetIterator.remove();
        }
      }
    }
  }
  progres.setValue(3);
  ProgRect=progres.getBounds();
  ProgRect.x=0;
  ProgRect.y=0;
  progres.paintImmediately(ProgRect);
  for (  Component com : components) {
    List<EndData> ends=com.getEnds();
    for (    EndData end : ends) {
      if (end.getWidth().getWidth() > 1) {
        for (        Net ThisNet : MyNets) {
          if (ThisNet.contains(end.getLocation())) {
            ThisNet.setBus(end.getWidth().getWidth());
          }
        }
      }
    }
  }
  progres.setValue(4);
  ProgRect=progres.getBounds();
  ProgRect.x=0;
  ProgRect.y=0;
  progres.paintImmediately(ProgRect);
  Iterator<Component> MySplitters=SplitterList.iterator();
  while (MySplitters.hasNext()) {
    Component com=MySplitters.next();
    List<EndData> ends=com.getEnds();
    EndData CombinedEnd=ends.get(0);
    int RootNet=-1;
    for (int i=0; i < MyNets.size() && RootNet < 0; i++) {
      if (MyNets.get(i).contains(CombinedEnd.getLocation())) {
        RootNet=i;
      }
    }
    if (RootNet < 0) {
      Reporter.AddFatalError("String_Node_Str" + MyCircuit.getName() + "String_Node_Str");
      this.clear();
      panel.dispose();
      return false;
    }
    ArrayList<Integer> Connections=new ArrayList<Integer>();
    for (int i=1; i < ends.size(); i++) {
      EndData ThisEnd=ends.get(i);
      int ConnectedNet=-1;
      for (int j=0; j < MyNets.size() && ConnectedNet < 1; j++) {
        if (MyNets.get(j).contains(ThisEnd.getLocation())) {
          ConnectedNet=j;
        }
      }
      Connections.add(ConnectedNet);
    }
    for (int i=1; i < ends.size(); i++) {
      int ConnectedNet=Connections.get(i - 1);
      if (ConnectedNet >= 0) {
        if (!MyNets.get(ConnectedNet).setParent(MyNets.get(RootNet))) {
          MyNets.get(ConnectedNet).ForceRootNet();
        }
        byte[] BusBitConnection=((Splitter)com).GetEndpoints();
        for (byte b=0; b < BusBitConnection.length; b++) {
          if (BusBitConnection[b] == i) {
            MyNets.get(ConnectedNet).AddParrentBit(b);
          }
        }
      }
    }
  }
  progres.setValue(5);
  ProgRect=progres.getBounds();
  ProgRect.x=0;
  ProgRect.y=0;
  progres.paintImmediately(ProgRect);
  for (  Net ThisNet : MyNets) {
    if (ThisNet.IsRootNet()) {
      ThisNet.InitializeSourceSinks();
    }
  }
  for (  Component comp : components) {
    if (comp.getFactory() instanceof SubcircuitFactory) {
      if (!ProcessSubcircuit(comp,Reporter)) {
        this.clear();
        panel.dispose();
        return false;
      }
    }
 else     if ((comp.getFactory() instanceof Pin) || (comp.getFactory().getIOInformation() != null) || (comp.getFactory().getHDLGenerator(HDLIdentifier,comp.getAttributeSet()) != null)) {
      if (!ProcessNormalComponent(comp,Reporter)) {
        this.clear();
        panel.dispose();
        return false;
      }
    }
  }
  progres.setValue(6);
  ProgRect=progres.getBounds();
  ProgRect.x=0;
  ProgRect.y=0;
  progres.paintImmediately(ProgRect);
  for (  Net thisnet : MyNets) {
    if (thisnet.IsForcedRootNet()) {
      for (int bit=0; bit < thisnet.BitWidth(); bit++) {
        for (        Component comp : SplitterList) {
          List<EndData> ends=comp.getEnds();
          EndData CombinedEnd=ends.get(0);
          int ConnectedBus=-1;
          for (int i=0; i < MyNets.size() && ConnectedBus < 0; i++) {
            if (MyNets.get(i).contains(CombinedEnd.getLocation())) {
              ConnectedBus=i;
            }
          }
          if (ConnectedBus < 0) {
            Reporter.AddFatalError("String_Node_Str");
            this.clear();
            panel.dispose();
            return false;
          }
          for (int endid=1; endid < ends.size(); endid++) {
            if (thisnet.contains(ends.get(endid).getLocation())) {
              byte[] BusBitConnection=((Splitter)comp).GetEndpoints();
              ArrayList<Byte> IndexBits=new ArrayList<Byte>();
              for (byte b=0; b < BusBitConnection.length; b++) {
                if (BusBitConnection[b] == endid) {
                  IndexBits.add(b);
                }
              }
              byte ConnectedBusIndex=IndexBits.get(bit);
              Net Rootbus=MyNets.get(ConnectedBus);
              while (!Rootbus.IsRootNet()) {
                ConnectedBusIndex=Rootbus.getBit(ConnectedBusIndex);
                Rootbus=Rootbus.getParent();
              }
              ConnectionPoint SolderPoint=new ConnectionPoint();
              SolderPoint.SetParrentNet(Rootbus,ConnectedBusIndex);
              Boolean IsSink=true;
              if (!thisnet.hasBitSource(bit)) {
                if (HasHiddenSource(Rootbus,ConnectedBusIndex,SplitterList,comp,new HashSet<String>())) {
                  IsSink=false;
                }
              }
              if (IsSink) {
                thisnet.addSinkNet(bit,SolderPoint);
              }
 else {
                thisnet.addSourceNet(bit,SolderPoint);
              }
            }
          }
        }
      }
    }
  }
  progres.setValue(7);
  ProgRect=progres.getBounds();
  ProgRect.x=0;
  ProgRect.y=0;
  progres.paintImmediately(ProgRect);
  panel.dispose();
  return true;
}

Fixed version (ground truth):
private boolean GenerateNetlist(FPGAReport Reporter,String HDLIdentifier){
  GridBagConstraints gbc=new GridBagConstraints();
  JFrame panel=new JFrame("String_Node_Str" + MyCircuit.getName());
  panel.setResizable(false);
  panel.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  GridBagLayout thisLayout=new GridBagLayout();
  panel.setLayout(thisLayout);
  JLabel LocText=new JLabel("String_Node_Str" + MyCircuit.getName());
  gbc.gridx=0;
  gbc.gridy=0;
  gbc.fill=GridBagConstraints.HORIZONTAL;
  panel.add(LocText,gbc);
  JProgressBar progres=new JProgressBar(0,7);
  progres.setValue(0);
  progres.setStringPainted(true);
  gbc.gridx=0;
  gbc.gridy=1;
  gbc.fill=GridBagConstraints.HORIZONTAL;
  panel.add(progres,gbc);
  panel.pack();
  panel.setLocation(Projects.getCenteredLoc(panel.getWidth(),panel.getHeight()));
  panel.setVisible(true);
  CircuitName=MyCircuit.getName();
  wires.clear();
  wires.addAll(MyCircuit.getWires());
  while (wires.size() != 0) {
    Net NewNet=new Net();
    GetNet(null,NewNet);
    if (!NewNet.isEmpty()) {
      MyNets.add(NewNet);
    }
  }
  Set<Component> components=MyCircuit.getNonWires();
  Set<Location> OutputsList=new HashSet<Location>();
  Set<Location> InputsList=new HashSet<Location>();
  Set<Component> TunnelList=new HashSet<Component>();
  Set<Component> SplitterList=new HashSet<Component>();
  for (  Component com : components) {
    if (com.getFactory() instanceof PortIO || com.getFactory() instanceof ReptarLocalBus)     continue;
 else     if (com.getFactory() instanceof SplitterFactory)     SplitterList.add(com);
 else     if (com.getFactory() instanceof Tunnel)     TunnelList.add(com);
 else {
      List<EndData> ends=com.getEnds();
      for (      EndData end : ends) {
        if (end.isInput() && end.isOutput()) {
          Reporter.AddFatalError("String_Node_Str" + com.getFactory().getName() + "String_Node_Str"+ MyCircuit.getName()+ "String_Node_Str");
          this.clear();
          panel.dispose();
          return false;
        }
        if (end.isOutput()) {
          OutputsList.add(end.getLocation());
        }
 else {
          InputsList.add(end.getLocation());
        }
      }
    }
  }
  progres.setValue(1);
  Rectangle ProgRect=progres.getBounds();
  ProgRect.x=0;
  ProgRect.y=0;
  progres.paintImmediately(ProgRect);
  Set<Location> ZeroLengthNets=new HashSet<Location>();
  for (  Component com : components) {
    if ((com.getFactory() instanceof SplitterFactory) || (com.getFactory() instanceof Tunnel)) {
      List<EndData> ends=com.getEnds();
      for (      EndData end : ends) {
        if (InputsList.contains(end.getLocation()) || OutputsList.contains(end.getLocation())) {
          boolean connected=false;
          for (          Net net : MyNets) {
            connected|=net.contains(end.getLocation());
          }
          if (!connected) {
            ZeroLengthNets.add(end.getLocation());
          }
        }
        for (        Component tun : TunnelList) {
          if (!tun.equals(com)) {
            List<EndData> tends=tun.getEnds();
            for (            EndData thisend : tends) {
              if (thisend.getLocation().equals(end.getLocation())) {
                boolean connected=false;
                for (                Net net : MyNets) {
                  connected|=net.contains(end.getLocation());
                }
                if (!connected) {
                  ZeroLengthNets.add(end.getLocation());
                }
              }
            }
          }
        }
        for (        Component tun : SplitterList) {
          if (!tun.equals(com)) {
            List<EndData> tends=tun.getEnds();
            for (            EndData thisend : tends) {
              if (thisend.getLocation().equals(end.getLocation())) {
                boolean connected=false;
                for (                Net net : MyNets) {
                  connected|=net.contains(end.getLocation());
                }
                if (!connected) {
                  ZeroLengthNets.add(end.getLocation());
                }
              }
            }
          }
        }
      }
    }
 else {
      List<EndData> ends=com.getEnds();
      for (      EndData end : ends) {
        if (end.isInput() && OutputsList.contains(end.getLocation())) {
          boolean connected=false;
          for (          Net net : MyNets) {
            connected|=net.contains(end.getLocation());
          }
          if (!connected) {
            ZeroLengthNets.add(end.getLocation());
          }
        }
      }
    }
  }
  InputsList.clear();
  OutputsList.clear();
  for (  Location Loc : ZeroLengthNets) {
    Net NewNet=new Net(Loc);
    MyNets.add(NewNet);
  }
  progres.setValue(2);
  ProgRect=progres.getBounds();
  ProgRect.x=0;
  ProgRect.y=0;
  progres.paintImmediately(ProgRect);
  boolean TunnelsPresent=false;
  for (  Component com : TunnelList) {
    List<EndData> ends=com.getEnds();
    for (    EndData end : ends) {
      for (      Net ThisNet : MyNets) {
        if (ThisNet.contains(end.getLocation())) {
          ThisNet.addTunnel(com.getAttributeSet().getValue(StdAttr.LABEL));
          TunnelsPresent=true;
        }
      }
    }
  }
  if (TunnelsPresent) {
    Iterator<Net> NetIterator=MyNets.listIterator();
    while (NetIterator.hasNext()) {
      Net ThisNet=NetIterator.next();
      if (ThisNet.HasTunnel() && (MyNets.indexOf(ThisNet) < (MyNets.size() - 1))) {
        boolean merged=false;
        Iterator<Net> SearchIterator=MyNets.listIterator(MyNets.indexOf(ThisNet) + 1);
        while (SearchIterator.hasNext() && !merged) {
          Net SearchNet=SearchIterator.next();
          for (          String name : ThisNet.TunnelNames()) {
            if (SearchNet.ContainsTunnel(name) && !merged) {
              merged=true;
              SearchNet.merge(ThisNet);
            }
          }
        }
        if (merged) {
          NetIterator.remove();
        }
      }
    }
  }
  progres.setValue(3);
  ProgRect=progres.getBounds();
  ProgRect.x=0;
  ProgRect.y=0;
  progres.paintImmediately(ProgRect);
  for (  Component com : components) {
    List<EndData> ends=com.getEnds();
    for (    EndData end : ends) {
      if (end.getWidth().getWidth() > 1) {
        for (        Net ThisNet : MyNets) {
          if (ThisNet.contains(end.getLocation())) {
            ThisNet.setBus(end.getWidth().getWidth());
          }
        }
      }
    }
  }
  progres.setValue(4);
  ProgRect=progres.getBounds();
  ProgRect.x=0;
  ProgRect.y=0;
  progres.paintImmediately(ProgRect);
  Iterator<Component> MySplitters=SplitterList.iterator();
  while (MySplitters.hasNext()) {
    Component com=MySplitters.next();
    List<EndData> ends=com.getEnds();
    EndData CombinedEnd=ends.get(0);
    int RootNet=-1;
    for (int i=0; i < MyNets.size() && RootNet < 0; i++) {
      if (MyNets.get(i).contains(CombinedEnd.getLocation())) {
        RootNet=i;
      }
    }
    if (RootNet < 0) {
      Reporter.AddFatalError("String_Node_Str" + MyCircuit.getName() + "String_Node_Str");
      this.clear();
      panel.dispose();
      return false;
    }
    ArrayList<Integer> Connections=new ArrayList<Integer>();
    for (int i=1; i < ends.size(); i++) {
      EndData ThisEnd=ends.get(i);
      int ConnectedNet=-1;
      for (int j=0; j < MyNets.size() && ConnectedNet < 1; j++) {
        if (MyNets.get(j).contains(ThisEnd.getLocation())) {
          ConnectedNet=j;
        }
      }
      Connections.add(ConnectedNet);
    }
    for (int i=1; i < ends.size(); i++) {
      int ConnectedNet=Connections.get(i - 1);
      if (ConnectedNet >= 0) {
        if (!MyNets.get(ConnectedNet).setParent(MyNets.get(RootNet))) {
          MyNets.get(ConnectedNet).ForceRootNet();
        }
        byte[] BusBitConnection=((Splitter)com).GetEndpoints();
        for (byte b=0; b < BusBitConnection.length; b++) {
          if (BusBitConnection[b] == i) {
            MyNets.get(ConnectedNet).AddParrentBit(b);
          }
        }
      }
    }
  }
  progres.setValue(5);
  ProgRect=progres.getBounds();
  ProgRect.x=0;
  ProgRect.y=0;
  progres.paintImmediately(ProgRect);
  for (  Net ThisNet : MyNets) {
    if (ThisNet.IsRootNet()) {
      ThisNet.InitializeSourceSinks();
    }
  }
  for (  Component comp : components) {
    if (comp.getFactory() instanceof SubcircuitFactory) {
      if (!ProcessSubcircuit(comp,Reporter)) {
        this.clear();
        panel.dispose();
        return false;
      }
    }
 else     if ((comp.getFactory() instanceof Pin) || (comp.getFactory().getIOInformation() != null) || (comp.getFactory().getHDLGenerator(HDLIdentifier,comp.getAttributeSet()) != null)) {
      if (!ProcessNormalComponent(comp,Reporter)) {
        this.clear();
        panel.dispose();
        return false;
      }
    }
  }
  progres.setValue(6);
  ProgRect=progres.getBounds();
  ProgRect.x=0;
  ProgRect.y=0;
  progres.paintImmediately(ProgRect);
  for (  Net thisnet : MyNets) {
    if (thisnet.IsForcedRootNet()) {
      for (int bit=0; bit < thisnet.BitWidth(); bit++) {
        for (        Component comp : SplitterList) {
          List<EndData> ends=comp.getEnds();
          EndData CombinedEnd=ends.get(0);
          int ConnectedBus=-1;
          for (int i=0; i < MyNets.size() && ConnectedBus < 0; i++) {
            if (MyNets.get(i).contains(CombinedEnd.getLocation())) {
              ConnectedBus=i;
            }
          }
          if (ConnectedBus < 0) {
            Reporter.AddFatalError("String_Node_Str");
            this.clear();
            panel.dispose();
            return false;
          }
          for (int endid=1; endid < ends.size(); endid++) {
            if (thisnet.contains(ends.get(endid).getLocation())) {
              byte[] BusBitConnection=((Splitter)comp).GetEndpoints();
              ArrayList<Byte> IndexBits=new ArrayList<Byte>();
              for (byte b=0; b < BusBitConnection.length; b++) {
                if (BusBitConnection[b] == endid) {
                  IndexBits.add(b);
                }
              }
              byte ConnectedBusIndex=IndexBits.get(bit);
              Net Rootbus=MyNets.get(ConnectedBus);
              while (!Rootbus.IsRootNet()) {
                ConnectedBusIndex=Rootbus.getBit(ConnectedBusIndex);
                Rootbus=Rootbus.getParent();
              }
              ConnectionPoint SolderPoint=new ConnectionPoint();
              SolderPoint.SetParrentNet(Rootbus,ConnectedBusIndex);
              Boolean IsSink=true;
              if (!thisnet.hasBitSource(bit)) {
                if (HasHiddenSource(Rootbus,ConnectedBusIndex,SplitterList,comp,new HashSet<String>())) {
                  IsSink=false;
                }
              }
              if (IsSink) {
                thisnet.addSinkNet(bit,SolderPoint);
              }
 else {
                thisnet.addSourceNet(bit,SolderPoint);
              }
            }
          }
        }
      }
    }
  }
  progres.setValue(7);
  ProgRect=progres.getBounds();
  ProgRect.x=0;
  ProgRect.y=0;
  progres.paintImmediately(ProgRect);
  panel.dispose();
  return true;
}