anchor.diff:      Reg#(Bit#(12)) numberOfPixels <- mkSyncReg(1920 + 192 + 44 + 44, axi_clock, axi_reset, defaultClock);
       Reg#(Bit#(11)) lineCount <- mkReg(0);
       Reg#(Bit#(12)) pixelCount <- mkReg(0);
  -    FIFOF#(Rgb888Stage) bramOutStageFifo <- mkSizedFIFOF(8);
  +    FIFOF#(Bit#(1)) bramOutStageFifo <- mkSizedFIFOF(8);
       Reg#(Bit#(12)) dataCount <- mkReg(0);
  -    Vector#(4, Reg#(Bit#(32))) patternRegs <- replicateM(mkSyncReg(32'h00FFFFFF, axi_clock, axi_reset, defaultClock));
  +    Vector#(4, Reg#(Bit#(24))) patternRegs <- replicateM(mkSyncReg(24'h00FFFFFF, axi_clock, axi_reset, defaultClock));
       Reg#(Bool) shadowTestPatternEnabled <- mkSyncReg(True, axi_clock, axi_reset, defaultClock);
       Reg#(Bool) testPatternEnabled <- mkReg(True);
       HdmiOut hdmioutput <- mkHdmiOut();
       Reg#(Bool) waitingForVsync <- mkSyncReg(False, axi_clock, axi_reset, defaultClock);
       SyncPulseIfc sendVsyncIndication <- mkSyncPulse(defaultClock, defaultReset, axi_clock);
  -
  -    let isActiveLine = (lineCount >= deLineCountMinimum && lineCount < deLineCountMaximum);
  -
  -    // 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
  -    rule sendVsyncPulse (lineCount == 0 && pixelCount == 0);
  -        $display("vsync pulse sent");
  -        vsyncPulse.send();
  -    endrule
  -    rule sendVsyncPulse2 (lineCount == 0 && pixelCount == 0);
  -        if (waitingForVsync)
  -        begin
  -            //waitingForVsync <= False;
  -            sendVsyncIndication.send();
  -        end
  -    endrule
  -
  -    rule sendHsyncPulse (isActiveLine && pixelCount == 0);
  -        //$display("hsync pulse sent");
  -        hsyncPulse.send();
  -    endrule
   
       rule vsyncReceived if (sendVsyncIndication.pulse());
           Bit#(64) v = 0;
  
positive.code:            end
          else
              pixelCount <= pixelCount + 1;
      //endrule
  
      //rule bramOutStage;
          bramOutStageFifo.deq();
          let d <- lineBuffer.readData();
          let stageData = bramOutStageFifo.first;
          Bit#(2) index = {pack(lineCount >= lineMidpoint), pack(pixelCount >= pixelMidpoint)};
  
          if (testPatternEnabled)
              stageData.pixel = unpack(truncate(patternRegs[index]));
          else
              stageData.pixel = unpack(d[23:0]);
          hdmioutput.rgb(Rgb888VideoData{active_video: pack(dataEnable),
              vsync: vsync, hsync: hsync,
              r: stageData.pixel.r, g: stageData.pixel.g, b: stageData.pixel.b });
      endrule
  
      interface hdmi = hdmioutput.hdmi;
      interface HdmiInternalRequest control;
      method Action setPatternColor(Bit#(32) v);
          patternRegs[0] <= v; 
      endmethod
      method Action setTestPattern(Bit#(1) v);
          shadowTestPatternEnabled <= (v != 0);
  
negative.code:     endrule
  
      rule init_pattern;
          patternRegs[1] <= 24'h00FF0000; // blue
          patternRegs[2] <= 24'h0000FF00; // green
          patternRegs[3] <= 24'h000000FF; // red
          //patternRegs[1] <= 32'h80ff80ff; // yuv422 white
          //patternRegs[2] <= 32'h2c961596; // yuv422 green
          //patternRegs[3] <= 32'hff1d6b1d; // yuv422 red
      endrule
  
      rule data;
          bramOutStageFifo.enq(0);
          lineBuffer.readAddr(dataCount);
      endrule
  
      rule inc_counters;
          bramOutStageFifo.deq();
          let vsync = (lineCount < vsyncWidth) ? 1 : 0;
          let hsync = (pixelCount < hsyncWidth) ? 1 : 0;
          let isActiveLine = (lineCount >= deLineCountMinimum && lineCount < deLineCountMaximum);
          let dataEnable = (pixelCount >= dePixelCountMinimum && pixelCount < dePixelCountMaximum && isActiveLine);
          if (hsync == 1)
              dataCount <= 0;
          else if (dataEnable)
              dataCount <= dataCount + 1;
  
          if (isActiveLine && pixelCount == 0)
              begin
              //$display("hsync pulse sent");
              hsyncPulse.send();
              end
          if (lineCount == 0 && pixelCount == 0)
              begin
              $display("vsync pulse sent");
              vsyncPulse.send();
              end
          if (lineCount == 0 && pixelCount == 0)
              begin
              if (waitingForVsync)
                  sendVsyncIndication.send();
              $display("testPatternEnabled %d", shadowTestPatternEnabled);
              testPatternEnabled <= shadowTestPatternEnabled;
              end
  