public void readRef(ObjectInputStream s) throws IOException {
        for (int a = 0; a < 8; a++) {
            int portIndex = s.readInt();
            if (portIndex >= 0) {
                portSignals[a].internalSignal = mySignals.elementAt(portIndex);
            }
        }
        for (int a = 0; a < myGates.size(); a++) {
            Gate gate = myGates.elementAt(a);
            gate.portSignals = new PortSignal[8];
            for (int b = 0; b < 8; b++) {
                gate.portSignals[b] = new PortSignal();
                int sigIndex = s.readInt();
                if (sigIndex >= 0) {
                    gate.portSignals[b].externalSignal = mySignals.elementAt(sigIndex);
                }
                gate.portSignals[b].type = s.readInt();
            }
            gate.readRef(s);
        }
    }