anchor.diff:     Reset fmc_imageon_reset <- mkAsyncReset(2, defaultReset, fmc_imageon_clk1);
      Reset hdmi_reset <- mkAsyncReset(2, defaultReset, hdmi_clock);
      Reset imageon_reset <- mkAsyncReset(2, defaultReset, imageon_clock);
  +   SPI#(Bit#(26)) spiController <- mkSPI(1000);
      SyncPulseIfc vsyncPulse <- mkSyncHandshake(hdmi_clock, hdmi_reset, imageon_clock);
  -
  +   Reg#(Bit#(1)) i2c_mux_reset_n_reg <- mkReg(0);
  +
  +   // instantiate user portals
  +   ImageonSerdesIndicationProxy serdesIndicationProxy <- mkImageonSerdesIndicationProxy(ImageonSerdesIndication);
      ISerdes serdes <- mkISerdes(defaultClock, defaultReset, serdesIndicationProxy.ifc,
   			clocked_by imageon_clock, reset_by imageon_reset);
  -   SPI#(Bit#(26)) spiController <- mkSPI(1000);
  +   ImageonSerdesRequestWrapper serdesRequestWrapper <- mkImageonSerdesRequestWrapper(ImageonSerdesRequest,serdes.control);
  +
  +   HdmiInternalIndicationProxy hdmiIndicationProxy <- mkHdmiInternalIndicationProxy(HdmiInternalIndication);
      HdmiGenerator hdmiGen <- mkHdmiGenerator(defaultClock, defaultReset,
          vsyncPulse, hdmiIndicationProxy.ifc, clocked_by hdmi_clock, reset_by hdmi_reset);
  +   HdmiInternalRequestWrapper hdmiRequestWrapper <- mkHdmiInternalRequestWrapper(HdmiInternalRequest,hdmiGen.control);
  +
      ImageonSensor fromSensor <- mkImageonSensor(defaultClock, defaultReset, serdes.data, vsyncPulse.pulse(),
          hdmiGen.control, hdmi_clock, hdmi_reset, clocked_by imageon_clock, reset_by imageon_reset);
  -
  -   rule spiControllerResponse;
  -       Bit#(26) v <- spiController.response.get();
  -       captureIndicationProxy.ifc.spi_response(extend(v));
  -   endrule
  -
  -   Reg#(Bit#(1)) i2c_mux_reset_n_reg <- mkReg(0);
  +   ImageonSensorRequestWrapper sensorRequestWrapper <- mkImageonSensorRequestWrapper(ImageonSensorRequest,fromSensor.control);
  +
  +   ImageCaptureIndicationProxy captureIndicationProxy <- mkImageCaptureIndicationProxy(ImageCaptureIndication);
      FrequencyCounter axiFreqCounter <- mkFrequencyCounter(defaultClock, defaultReset);
      FrequencyCounter hdmiFreqCounter <- mkFrequencyCounter(hdmi_clock, hdmi_reset);
      FrequencyCounter imageonFreqCounter <- mkFrequencyCounter(imageon_clock, imageon_reset);
      FrequencyCounter fmcFreqCounter <- mkFrequencyCounter(fmc_imageon_clk1, fmc_imageon_reset);
  +   ImageCaptureRequest imageCaptureRequest = (interface ImageCaptureRequest;
  +      method Action get_debugind();
  +         captureIndicationProxy.ifc.debugind(fromSensor.control.get_debugind());
  +      endmethod
  +      method Action put_spi_request(Bit#(32) v);
  +         spiController.request.put(truncate(v));
  +      endmethod
  +      method Action set_i2c_mux_reset_n(Bit#(1) v);
  +	 i2c_mux_reset_n_reg <= v;
  +      endmethod
  +      method Action measure_axi_clock_period(Bit#(32) cycles_100mhz);
  +	 axiFreqCounter.start(cycles_100mhz);
  +      endmethod
  +      method Action measure_hdmi_clock_period(Bit#(32) cycles_100mhz);
  +         hdmiFreqCounter.start(cycles_100mhz);
  +      endmethod
  +      method Action measure_imageon_clock_period(Bit#(32) cycles_100mhz);
  +         imageonFreqCounter.start(cycles_100mhz);
  +      endmethod
  +      method Action measure_fmc_clock_period(Bit#(32) cycles_100mhz);
  +         fmcFreqCounter.start(cycles_100mhz);
  +      endmethod
  +      endinterface);
  +   ImageCaptureRequestWrapper captureRequestWrapper <- mkImageCaptureRequestWrapper(ImageCapture, imageCaptureRequest);
  +
  +   rule spiControllerResponse;
  +       Bit#(26) v <- spiController.response.get();
  +       captureIndicationProxy.ifc.spi_response(extend(v));
  +   endrule
   
      rule gotAxiClockPeriod;
         let cycles <- axiFreqCounter.elapsedCycles();
  
positive.code:       captureIndicationProxy.ifc.frameStart(monitor, count);
     endrule
  
      rule xsviConnection;
          let xsvi <- fromSensor.get_data();
          Bit#(32) pixel = {8'b0, xsvi[9:2], xsvi[9:2], xsvi[9:2]};
          hdmiGen.request.put(pixel);
      endrule
     
     Vector#(7,StdPortal) portals;
     portals[0] = captureRequestWrapper.portalIfc;
  
negative.code: // Copyright (c) 2014 Quanta Research Cambridge, Inc.
  
  // Permission is hereby granted, free of charge, to any person
  // obtaining a copy of this software and associated documentation
  // files (the "Software"), to deal in the Software without
  // restriction, including without limitation the rights to use, copy,
  // modify, merge, publish, distribute, sublicense, and/or sell copies
  // of the Software, and to permit persons to whom the Software is
  // furnished to do so, subject to the following conditions:
  
  // The above copyright notice and this permission notice shall be
  // included in all copies or substantial portions of the Software.
  
  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  // SOFTWARE.
  
  // bsv libraries
  import Vector::*;
  import FIFO::*;
  import DefaultValue::*;
  
  // portz libraries
  