anchor.diff:        let cycles <- fmcFreqCounter.elapsedCycles();
         captureIndicationProxy.ifc.fmc_clock_period(cycles);
      endrule
  -
  -   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);
  -    ImageonSerdesRequestWrapper serdesRequestWrapper <- mkImageonSerdesRequestWrapper(ImageonSerdesRequest,serdes.control);
  -    HdmiInternalRequestWrapper hdmiRequestWrapper <- mkHdmiInternalRequestWrapper(HdmiInternalRequest,hdmiGen.control);
  -    ImageonSensorRequestWrapper sensorRequestWrapper <- mkImageonSensorRequestWrapper(ImageonSensorRequest,fromSensor.control);
   
      Reg#(Bool) frameStart <- mkReg(False, clocked_by imageon_clock, reset_by imageon_reset);
      Reg#(Bit#(32)) frameCount <- mkReg(0, clocked_by imageon_clock, reset_by imageon_reset);
  
positive.code: // bsv libraries
  import Vector::*;
  import FIFO::*;
  import Connectable::*;
  import DefaultValue::*;
  
  // portz libraries
  
negative.code:    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);
     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);
     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();
  