anchor.diff:          serdes_start.enq(cric);
       endrule
       rule afsmfound_rule if (bvi_resets_reg.read() != 0 && astate == AFound);
  +        let gc = gencounter;
           serdes_end.deq();
           if (gencounter >= 'h8000)
  -            astate <= AStart;
  -        else
  -            begin
  -            gencounter <= gencounter - 1;
  -            serdes_start.enq(2'b01);
  -            end
  -    endrule
  -    rule afsmresetman_rule if (bvi_resets_reg.read() != 0 && astate == AManual);
  -        serdes_end.deq();
  -        if (gencounter >= 'h8000)
  -            astate <= AStart;
  -        else
  -            begin
  -            gencounter <= gencounter - 1;
  -            serdes_start.enq(2'b11);
  -            end
  -    endrule
  -    rule afsmstart_rule if (bvi_resets_reg.read() != 0 && astate == AStart);
  -        let as = ADone;
  -        if (ctrl_data != training)
  -            begin
  -            gencounter <= 8;
  -            as = AAlign;
  -            serdes_start.enq(0);
  -            end
  -        astate <= as;
  +            begin
  +            let as = ADone;
  +            if (ctrl_data != training)
  +                begin
  +                gc = 8;
  +                as = AAlign;
  +                serdes_start.enq(0);
  +                end
  +            astate <= as;
  +            end
  +        else
  +            begin
  +            gc = gc - 1;
  +            serdes_start.enq({autoalign, 1'b1});
  +            end
  +        gencounter <= gc;
       endrule
       rule afsmalign_rule if (bvi_resets_reg.read() != 0 && astate == AAlign);
           serdes_end.deq();
  
positive.code: 
      rule qfsmall;
          fifo_reset_sync.send(pack(qstate != QIdle));
          astate_idle.send(pack(astate == ADelay || astate == AManual));
          astate_bitslip.send(pack(astate == AAlign));
      endrule
  
  
negative.code:             begin
              gencounter <= {6'b0, manual_tap};
              maxcount <= 31;
              as = AFound;
              end
          astate <= as;
          serdes_start.enq(0);
  