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: endinterface: IserdesDatadeser
  
  typedef enum { QIdle, QTrain, QOff} QState deriving (Bits,Eq);
  typedef enum { AIdle, ADelay, AEdge, ACEdge, AWait, ACompare,
       A1Changed, A1Stable, ASecond, AFound, AAlign, ADone } AState deriving (Bits,Eq);
  
  module mkIserdesDatadeser#(Clock serdes_clock, Reset serdes_reset, Clock serdest, Bit#(1) align_start,
      Bit#(1) autoalign, Bit#(10) training, Bit#(10) manual_tap, TrainRotate trainrot)(IserdesDatadeser);
  
negative.code:         serdes_end.deq();
          maxcount <= 31;
          gencounter <= 15;
          astate <= ACEdge;
          serdes_start.enq(0);
      endrule
      rule afsmcedge1_rule if (bvi_resets_reg.read() != 0 && astate == ACEdge
              && retrycounter < 'h8000);
          serdes_end.deq();
          astate <= AIdle;
      endrule
      rule afsmcedge2_rule if (bvi_resets_reg.read() != 0 && astate == ACEdge
              && retrycounter >= 'h8000);
          serdes_end.deq();
          let mc = maxcount;
          let cric = 2'b11;
          let as = ACEdge;
          retrycounter <= retrycounter - 1;
          if (edge_int != 0)
              begin
  