anchor.diff:              gencounter <= 15;
               as = A1Stable;
               end
  -        else
  -            begin
  -            let mc = maxcount;
  -            if (maxcount[10] == 1)
  -                begin
  -                cric = 2'b00;
  -                as = ADelay;
  -                end
  -            else
  -                begin
  -                cric = 2'b11;
  -                mc = mc - 1;
  -                end
  -            maxcount <= mc;
  +        else if (maxcount[10] == 1)
  +            as = ADelay;
  +        else
  +            begin
  +            cric = 2'b11;
  +            maxcount <= maxcount - 1;
               end
           astate <= as;
           serdes_start.enq(cric);
  
positive.code:         serdes_start.enq(cric);
      endrule
      rule afsmfound_rule if (bvi_resets_reg.read() != 0 && astate == AFound);
          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;
      endrule
      rule afsmalign_rule if (bvi_resets_reg.read() != 0 && astate == AAlign);
          serdes_end.deq();
  
negative.code: 
  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);
  