示例#1
0
 private static Jiffi FindControlRegister(Register l1, Register l2, int[] indexes, string data, int regLength)
 {
     int maxK = 0;
     for (int i = 0; i < Math.Pow(2, regLength); i++)
     {
         int[] initialState = new int[regLength];
         int icopy = i;
         for (int j = 0; j < regLength; j++)
         {
             initialState[j] = icopy%2;
             icopy /= 2;
         }
         Register l = new Register(indexes, initialState);
         Jiffi jiffi = new Jiffi(l1, l2, l);
         int k = 0;
         for (; k < data.Length; k++)
         {
             int jNext = jiffi.GetNext();
             if (jNext != int.Parse(data[k].ToString()))
                 break;
         }
         maxK = Math.Max(maxK, k);
         if (k == data.Length)
             return new Jiffi(l1, l2, l);
     }
     throw new Exception("Control Register not found");
 }
示例#2
0
 public Jiffi(Register l1, Register l2, Register l3)
 {
     L1 = (Register) l1.Clone();
     L2 = (Register) l2.Clone();
     L3 = (Register) l3.Clone();
 }
示例#3
0
 private static Register FindRegister(int[] indexes, int c, string data, int dataLength, int regLength)
 {
     for (int i = 0; i < Math.Pow(2, regLength); i++)
     {
         int[] initialState = new int[regLength];
         int icopy = i;
         for (int j = 0; j < regLength; j++)
         {
             initialState[j] = icopy%2;
             icopy /= 2;
         }
         int r = 0;
         Register l = new Register(indexes, initialState);
         for (int j = 0; j < dataLength; j++)
         {
             int lnext = l.GetNext();
             r += (lnext + int.Parse(data[j].ToString()))%2;
         }
         if (r < c)
            return new Register(indexes, initialState);
     }
     throw new Exception("Register not found");
 }