/** * * The purpose of this function is to illustrate the usage of the HwIcap driver. * * @param HwIcapDeviceId is device ID of the XHwIcap Device, typically * XPAR_<HWICAP_instance>_DEVICE_ID value from xparameters.h * * @return XST_SUCCESS to indicate success, otherwise XST_FAILURE. * * @note None. * ****************************************************************************/ int HwIcapTestAppExample(u16 HwIcapDeviceId) { int Status; XHwIcap_Config *ConfigPtr; u32 ConfigRegData; /* * Initialize the HwIcap driver. */ ConfigPtr = XHwIcap_LookupConfig(HwIcapDeviceId); if (ConfigPtr == NULL) { return XST_FAILURE; } Status = XHwIcap_CfgInitialize(&HwIcap, ConfigPtr, ConfigPtr->BaseAddress); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Perform a self-test to ensure that the hardware was built correctly. */ Status = XHwIcap_SelfTest(&HwIcap); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Read the ID Code register inside the FPGA. */ Status = XHwIcap_GetConfigReg(&HwIcap, XHI_IDCODE, &ConfigRegData); if (Status != XST_SUCCESS) { return XST_FAILURE; } return XST_SUCCESS; }
/** * * This function initializes a specific XHwIcap instance. * The IDCODE is read from the FPGA and based on the IDCODE the information * about the resources in the FPGA is filled in the instance structure. * * The HwIcap device will be in put in a reset state before exiting this * function. * * @param InstancePtr is a pointer to the XHwIcap instance. * @param ConfigPtr points to the XHwIcap device configuration structure. * @param EffectiveAddr is the device base address in the virtual memory * address space. If the address translation is not used then the * physical address is passed. * Unexpected errors may occur if the address mapping is changed * after this function is invoked. * * @return XST_SUCCESS else XST_FAILURE * * @note None. * *****************************************************************************/ int XHwIcap_CfgInitialize(XHwIcap *InstancePtr, XHwIcap_Config *ConfigPtr, u32 EffectiveAddr) { int Status; u32 DeviceIdCode; u32 TempDevId; u8 DeviceIdIndex; u8 NumDevices; u8 IndexCount; int DeviceFound = FALSE; Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(ConfigPtr != NULL); /* * Set some default values. */ InstancePtr->IsReady = FALSE; InstancePtr->IsTransferInProgress = FALSE; InstancePtr->IsPolled = TRUE; /* Polled Mode */ /* * Set the device base address and stub handler. */ InstancePtr->HwIcapConfig.BaseAddress = EffectiveAddr; InstancePtr->StatusHandler = (XHwIcap_StatusHandler) StubStatusHandler; /** Set IcapWidth **/ InstancePtr->HwIcapConfig.IcapWidth = ConfigPtr->IcapWidth; /** Set IsLiteMode **/ InstancePtr->HwIcapConfig.IsLiteMode = ConfigPtr->IsLiteMode; /* * Read the IDCODE from ICAP. */ /* * Setting the IsReady of the driver temporarily so that * we can read the IdCode of the device. */ InstancePtr->IsReady = XIL_COMPONENT_IS_READY; /* * Dummy Read of the IDCODE as the first data read from the * ICAP has to be discarded (Due to the way the HW is designed). */ Status = XHwIcap_GetConfigReg(InstancePtr, XHI_IDCODE, &TempDevId); if (Status != XST_SUCCESS) { InstancePtr->IsReady = 0; return XST_FAILURE; } /* * Read the IDCODE and mask out the version section of the DeviceIdCode. */ Status = XHwIcap_GetConfigReg(InstancePtr, XHI_IDCODE, &DeviceIdCode); if (Status != XST_SUCCESS) { InstancePtr->IsReady = 0; return XST_FAILURE; } DeviceIdCode = DeviceIdCode & XHI_DEVICE_ID_CODE_MASK; if ((DeviceIdCode == XHI_DEVICE_ID_CODE_MASK) || (DeviceIdCode == 0x0)) { return XST_FAILURE; } Status = XHwIcap_CommandDesync(InstancePtr); InstancePtr->IsReady = 0; if (Status != XST_SUCCESS) { return XST_FAILURE; } InstancePtr->BytesPerFrame = XHI_NUM_FRAME_BYTES; InstancePtr->WordsPerFrame = (InstancePtr->BytesPerFrame/4); InstancePtr->IsReady = XIL_COMPONENT_IS_READY; /* * Reset the device. */ XHwIcap_Reset(InstancePtr); return XST_SUCCESS; } /* end XHwIcap_CfgInitialize() */
/** * * This function initializes a specific XHwIcap instance. * The IDCODE is read from the FPGA and based on the IDCODE the information * about the resources in the FPGA is filled in the instance structure. * * The HwIcap device will be in put in a reset state before exiting this * function. * * @param InstancePtr is a pointer to the XHwIcap instance. * @param ConfigPtr points to the XHwIcap device configuration structure. * @param EffectiveAddr is the device base address in the virtual memory * address space. If the address translation is not used then the * physical address is passed. * Unexpected errors may occur if the address mapping is changed * after this function is invoked. * * @return XST_SUCCESS else XST_FAILURE * * @note None. * *****************************************************************************/ int XHwIcap_custom_CfgInitialize(XHwIcap *InstancePtr, XHwIcap_Config *ConfigPtr, u32 EffectiveAddr) { int Status; u32 DeviceIdCode; u32 TempDevId; u8 DeviceIdIndex; u8 NumDevices; u8 IndexCount; int DeviceFound = FALSE; Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(ConfigPtr != NULL); /* * Set some default values. */ InstancePtr->IsReady = FALSE; InstancePtr->IsTransferInProgress = FALSE; InstancePtr->IsPolled = TRUE; /* Polled Mode */ /* * Set the device base address and stub handler. */ InstancePtr->HwIcapConfig.BaseAddress = EffectiveAddr; InstancePtr->StatusHandler = (XHwIcap_StatusHandler) StubStatusHandler; /** Set IcapWidth **/ InstancePtr->HwIcapConfig.IcapWidth = ConfigPtr->IcapWidth; /** Set IsLiteMode **/ InstancePtr->HwIcapConfig.IsLiteMode = ConfigPtr->IsLiteMode; /* * Read the IDCODE from ICAP. */ /* * Setting the IsReady of the driver temporarily so that * we can read the IdCode of the device. */ InstancePtr->IsReady = XIL_COMPONENT_IS_READY; /* * Dummy Read of the IDCODE as the first data read from the * ICAP has to be discarded (Due to the way the HW is designed). */ Status = XHwIcap_GetConfigReg(InstancePtr, XHI_IDCODE, &TempDevId); if (Status != XST_SUCCESS) { InstancePtr->IsReady = 0; return XST_FAILURE; } /* * Read the IDCODE and mask out the version section of the DeviceIdCode. */ Status = XHwIcap_GetConfigReg(InstancePtr, XHI_IDCODE, &DeviceIdCode); if (Status != XST_SUCCESS) { InstancePtr->IsReady = 0; return XST_FAILURE; } DeviceIdCode = DeviceIdCode & XHI_DEVICE_ID_CODE_MASK; #if (XHI_FAMILY != XHI_DEV_FAMILY_S6) Status = XHwIcap_CommandDesync(InstancePtr); InstancePtr->IsReady = 0; if (Status != XST_SUCCESS) { return XST_FAILURE; } #endif #if XHI_FAMILY == XHI_DEV_FAMILY_V4 /* Virtex4 */ DeviceIdIndex = 0; NumDevices = XHI_V4_NUM_DEVICES; #elif XHI_FAMILY == XHI_DEV_FAMILY_V5 /* Virtex5 */ DeviceIdIndex = XHI_V4_NUM_DEVICES; NumDevices = XHI_V5_NUM_DEVICES; #elif XHI_FAMILY == XHI_DEV_FAMILY_V6 /* Virtex6 */ DeviceIdIndex = XHI_V4_NUM_DEVICES + XHI_V5_NUM_DEVICES; NumDevices = XHI_V6_NUM_DEVICES; #elif XHI_FAMILY == XHI_DEV_FAMILY_S6 /* Spartan6 */ DeviceIdIndex = XHI_V4_NUM_DEVICES + XHI_V5_NUM_DEVICES + XHI_V6_NUM_DEVICES; NumDevices = XHI_S6_NUM_DEVICES; #elif XHI_FAMILY == XHI_DEV_FAMILY_7SERIES /* 7Series */ DeviceIdIndex = 0; /*specific to zynq*/ NumDevices = 1; /* Number of devices defined in DeviceDetaillkup_custom[]*/ #endif /* * Find the device index */ for (IndexCount = 0; IndexCount < NumDevices; IndexCount++) { if (DeviceIdCode == DeviceDetaillkup_custom[DeviceIdIndex + IndexCount]. DeviceIdCode) { DeviceIdIndex += IndexCount; DeviceFound = TRUE; break; } } if (DeviceFound != TRUE) { return XST_FAILURE; } InstancePtr->DeviceIdCode = DeviceDetaillkup_custom[DeviceIdIndex].DeviceIdCode; InstancePtr->Rows = DeviceDetaillkup_custom[DeviceIdIndex].Rows; InstancePtr->Cols = DeviceDetaillkup_custom[DeviceIdIndex].Cols; InstancePtr->BramCols = DeviceDetaillkup_custom[DeviceIdIndex].BramCols; InstancePtr->DSPCols = DeviceDetaillkup_custom[DeviceIdIndex].DSPCols; InstancePtr->IOCols = DeviceDetaillkup_custom[DeviceIdIndex].IOCols; InstancePtr->MGTCols = DeviceDetaillkup_custom[DeviceIdIndex].MGTCols; InstancePtr->HClkRows = DeviceDetaillkup_custom[DeviceIdIndex].HClkRows; InstancePtr->SkipCols = DeviceDetaillkup_custom[DeviceIdIndex].SkipCols; InstancePtr->BytesPerFrame = XHI_NUM_FRAME_BYTES; #if (XHI_FAMILY == XHI_DEV_FAMILY_S6) /* * In Spartan6 devices the word is defined as 16 bit */ InstancePtr->WordsPerFrame = (InstancePtr->BytesPerFrame/2); #else InstancePtr->WordsPerFrame = (InstancePtr->BytesPerFrame/4); #endif InstancePtr->ClbBlockFrames = (4 +22*2 + 4*2 + 22*InstancePtr->Cols); InstancePtr->BramBlockFrames = (64*InstancePtr->BramCols); InstancePtr->BramIntBlockFrames = (22*InstancePtr->BramCols); InstancePtr->IsReady = XIL_COMPONENT_IS_READY; /* * Reset the device. */ XHwIcap_Reset(InstancePtr); return XST_SUCCESS; } /* end XHwIcap_custom_CfgInitialize() */
/** * * This function reads the configuration registers inside the FPGA. * * @param DeviceId is the XPAR_<HWICAP_INSTANCE>_DEVICE_ID value from * xparameters.h. * * @return XST_SUCCESS if successful, otherwise XST_FAILURE. * * @note None. * ******************************************************************************/ int HwIcapReadConfigRegExample(u16 DeviceId) { int Status; XHwIcap_Config *CfgPtr; u32 ConfigRegData; /* * Initialize the HwIcap instance. */ CfgPtr = XHwIcap_LookupConfig(DeviceId); if (CfgPtr == NULL) { return XST_FAILURE; } Status = XHwIcap_CfgInitialize(&HwIcap, CfgPtr, CfgPtr->BaseAddress); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Run the Self test. */ Status = XHwIcap_SelfTest(&HwIcap); if (Status != XST_SUCCESS) { return XST_FAILURE; } printf("Value of the Configuration Registers. \r\n\r\n"); if (XHwIcap_GetConfigReg(&HwIcap, XHI_CRC, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" CRC -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_FAR, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" FAR -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_FDRI, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" FDRI -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_FDRO, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" FDRO -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_CMD, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" CMD -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_CTL, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" CTL -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_MASK, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" MASK -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_STAT, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" STAT -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_LOUT, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" LOUT -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_COR, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" COR -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_MFWR, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" MFWR -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_CBC, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" CBC -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_AXSS, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" AXSS -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_IDCODE, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" IDCODE -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_COR_1, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" COR_1 -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_CSOB, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" CSOB -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_WBSTAR, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" WBSTAR -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_TIMER, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" TIMER -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_BOOTSTS, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" BOOTSTS -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_CTL_1, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" CTL_1 -> \t %x \t\r\n", ConfigRegData); } printf("\r\n HwIcapReadConfigRegExample Passed Successfully.\r\n\r\n"); return XST_SUCCESS; }