anchor.diff:      let isActiveLine = (lineCount >= deLineCountMinimum && lineCount < deLineCountMaximum);
       let dataEnable = (pixelCount >= dePixelCountMinimum && pixelCount < dePixelCountMaximum && isActiveLine);
   
  -    function LinePixelCount newCounts(Bit#(11) lc, Bit#(12) pc);
  -        let newLineCount = lc;
  -        let newPixelCount = pc;
  -        if (pc == numberOfPixels-1)
  -           begin
  -           newPixelCount = 0; 
  -           if (lc == numberOfLines-1)
  -               newLineCount = 0;
  -           else
  -               newLineCount = lc+1;
  -           end
  -        else
  -            newPixelCount = pc + 1;
  -        return LinePixelCount { line: newLineCount, pixel: newPixelCount };
  -    endfunction
  -
       // vsyncPulse is a SyncHandshake to a slow clock domain
       // so it is not ready every cycle.
       // Therefore, we send to it from a different rule so it does not block the fbRule
  
positive.code:         //patternRegs[1] <= 32'h80ff80ff; // yuv422 white
          //patternRegs[2] <= 32'h2c961596; // yuv422 green
          //patternRegs[3] <= 32'hff1d6b1d; // yuv422 red
      endrule
  
      rule data if (testPatternEnabled);
          LinePixelCount counts = newCounts(lineCount, pixelCount);
          lineCount <= counts.line;
          pixelCount <= counts.pixel;
          if (lineCount == 0 && pixelCount == 0)
          begin
              $display("testPatternEnabled %d", shadowTestPatternEnabled);
              testPatternEnabled <= shadowTestPatternEnabled;
          end
  
          Bit#(2) index = {pack(lineCount >= lineMidpoint), pack(pixelCount >= pixelMidpoint)};
          //if (pixelCount >= pixelMidpoint)
              //index[0] = 1;
          //if (lineCount >= lineMidpoint)
              //index[1] = 1;
          //Bit#(32) data = patternRegs[index];
  
          if (hsync == 1)
              dataCount <= 0;
          else if (dataEnable)
              dataCount <= dataCount + 1;
          bramOutStageFifo.enq(Rgb888Stage { vsync: vsync, hsync: hsync, de: dataEnable, pixel: unpack(truncate(patternRegs[index]))});
          lineBuffer.readAddr(0);
      endrule
  
      rule fbRule if (!testPatternEnabled);
          LinePixelCount counts = newCounts(lineCount, pixelCount);
          lineCount <= counts.line;
          pixelCount <= counts.pixel;
  
          if (lineCount == 0 && pixelCount == 0)
          begin
              $display("testPatternEnabled %d", shadowTestPatternEnabled);
              testPatternEnabled <= shadowTestPatternEnabled;
          end
  
          if (hsync == 1)
              dataCount <= 0;
          else if (dataEnable)
              dataCount <= dataCount + 1;
          bramOutStageFifo.enq(Rgb888Stage { vsync: vsync, hsync: hsync, de: dataEnable, pixel: Rgb888{r:0,g:0,b:0}});
          lineBuffer.readAddr(dataCount);
      endrule
  
      rule bramOutStage;
          bramOutStageFifo.deq;
          let d <- lineBuffer.readData;
          let stageData = bramOutStageFifo.first;
  
          if (!testPatternEnabled)
  
negative.code:     rule yuv444Stage;
          let previous = yuv444IntermediatesStageReg;
          yuv444StageReg <= Yuv444Stage {
              vsync: previous.vsync, hsync: previous.hsync, de: previous.de,
              data: (previous.de) ? yuvIntermediatesToYuv444(previous.data) : unpack(0)
          };
      endrule
  