public CompositeGateClass(String gateName, HDLTokenizer input, PinInfo[] inputPinsInfo, PinInfo[] outputPinsInfo)
     throws HDLException {
        super(gateName, inputPinsInfo, outputPinsInfo);

        partsList = new Vector();
        internalPinsInfo = new Vector();
        connections = new ConnectionSet();
        isInputClocked = new boolean[inputPinsInfo.length];
        isOutputClocked = new boolean[outputPinsInfo.length];

        readParts(input);

        Graph graph = createConnectionsGraph();

        // runs the topological sort, starting from the "master parts" node,
        // which connects to all the parts. This will also check for circles.
        Object[] topologicalOrder = graph.topologicalSort(partsList);

        if (graph.hasCircle())
            throw new HDLException("This chip has a circle in its parts connections");

        // create the partsOrder array, by taking from the topologicalOrder
        // only the Integer objects, which represent the parts.
        partsOrder = new int[partsList.size()];
        int counter = 0;
        for (int i = 0; i < topologicalOrder.length; i++) {
            if (topologicalOrder[i] instanceof Integer)
                partsOrder[counter++] = ((Integer)topologicalOrder[i]).intValue();
        }

        // for each input pin, check if there is a path in the graph to an output pin
        // (actually to the "master output", which all outputs connect to).
        // If there is, the input is not clocked. Otherwise, it is.
        for (int i = 0; i < inputPinsInfo.length; i++)
            isInputClocked[i] = !graph.pathExists(inputPinsInfo[i], outputPinsInfo);

        // for each output pin, check if there is a path in the graph from any input pin
        // (actually from the "master input", which connects to all inputs) to this output pin.
        // If there is, the output is not clocked. Otherwise, it is.
        for (int i = 0; i < outputPinsInfo.length; i++)
            isOutputClocked[i] = !graph.pathExists(inputPinsInfo, outputPinsInfo[i]);
    }