public int CalculateSequenceLength() {
        int length = 0;
        boolean[] BitsClone = Bits.clone();
        setNumberOfBits(NumberOfBits);
        initTimeOut(ACCEPTABLE_RUN_TIME);
        strobeClock();
        for (;;) {
            length++;
            strobeClock();
            if (isTimeOut())
                break;
            if ( (Gate == GateType.XOR) && areAllTrue(Bits) )
                break;
            if ( (Gate == GateType.XNOR) && areAllFalse(Bits) )
                break;
        } 
        Bits = BitsClone;
        SeqLength = length + 1;
        resetLFSR();
        return SeqLength;
    }