anchor.diff:          serdes_start.enq(cric);
       endrule
       rule afsmfound_rule if (bvi_resets_reg.read() != 0 && astate == AFound);
  +        serdes_end.deq();
           let gc = gencounter;
  -        serdes_end.deq();
           if (gencounter >= 'h8000)
               begin
  -            let as = ADone;
  +            let as = AIdle;
               if (ctrl_data != training)
                   begin
                   gc = 8;
  
positive.code:             let cric = 2'b00;
              if (edge_init != edge_int)
                  begin
                  let mc = maxcount;
                  retrycounter <= retrycounter - 1;
                  if (maxcount[10] == 1)
                      as = ADelay;
                  else
                      begin
                      cric = 2'b11;
                      mc = mc - 1;
                      gc = 14;
                      as = AEdge;
                      end
                  maxcount <= mc;
                  end
              else
                  gc = gc - 1;
  
negative.code:             else
                  begin
                  retrycounter <= retrycounter - 1;
                  gc = 14;
                  as = ACEdge;
                  end
              serdes_start.enq(cric);
              end
          else if (ctrl_data == trainrot[gencounter])
              begin
              let csamplein = 3'b001;
              if (gencounter == 9)
                  csamplein = 3'b010;
              else if (gencounter == 8)
                  csamplein = 3'b100;
              ctrl_sample <= csamplein;
              as = A1Changed;
              serdes_start.enq(2'b11);
              end
          astate <= as;
          gencounter <= gc;
          maxcount <= maxcount - 1;
      endrule
      rule afsm1changed_rule if (bvi_resets_reg.read() != 0 && astate == A1Changed);
          serdes_end.deq();
  