📄 micro.c
字号:
for ( i = plvDataMask->len - 1; i >= 0; --i ) { /* Go through data mask in reverse order looking for mask (1) bits */ ucDataMask = plvDataMask->val[ i ]; if ( ucDataMask ) { /* Retrieve the corresponding TDI byte value */ ucTdi = plvTdi->val[ i ]; /* For each bit in the data mask byte, look for 1's */ ucTdiMask = 1; while ( ucDataMask ) { if ( ucDataMask & 1 ) { if ( !ucNextMask ) { /* Get the next data byte */ ucNextData = plvNextData->val[ --sNextData ]; ucNextMask = 1; } /* Set or clear the data bit according to the next data */ if ( ucNextData & ucNextMask ) { ucTdi |= ucTdiMask; /* Set bit */ } else { ucTdi &= ( ~ucTdiMask ); /* Clear bit */ } /* Update the next data */ ucNextMask <<= 1; } ucTdiMask <<= 1; ucDataMask >>= 1; } /* Update the TDI value */ plvTdi->val[ i ] = ucTdi; } }}#endif /* XSVF_SUPPORT_COMPRESSION *//*============================================================================* XSVF Command Functions (type = TXsvfDoCmdFuncPtr)* These functions update pXsvfInfo->iErrorCode only on an error.* Otherwise, the error code is left alone.* The function returns the error code from the function.============================================================================*//****************************************************************************** Function: xsvfDoIllegalCmd* Description: Function place holder for illegal/unsupported commands.* Parameters: pXsvfInfo - XSVF information pointer.* Returns: int - 0 = success; non-zero = error.*****************************************************************************/int xsvfDoIllegalCmd( SXsvfInfo* pXsvfInfo ){ XSVFDBG_PRINTF2( 0, "ERROR: Encountered unsupported command #%d (%s)\n", ((unsigned int)(pXsvfInfo->ucCommand)), ((pXsvfInfo->ucCommand < XLASTCMD) ? (xsvf_pzCommandName[pXsvfInfo->ucCommand]) : "Unknown") ); pXsvfInfo->iErrorCode = XSVF_ERROR_ILLEGALCMD; return( pXsvfInfo->iErrorCode );}/****************************************************************************** Function: xsvfDoXCOMPLETE* Description: XCOMPLETE (no parameters)* Update complete status for XSVF player.* Parameters: pXsvfInfo - XSVF information pointer.* Returns: int - 0 = success; non-zero = error.*****************************************************************************/int xsvfDoXCOMPLETE( SXsvfInfo* pXsvfInfo ){ pXsvfInfo->ucComplete = 1; return( XSVF_ERROR_NONE );}/****************************************************************************** Function: xsvfDoXTDOMASK* Description: XTDOMASK <lenVal.TdoMask[XSDRSIZE]>* Prespecify the TDO compare mask.* Parameters: pXsvfInfo - XSVF information pointer.* Returns: int - 0 = success; non-zero = error.*****************************************************************************/int xsvfDoXTDOMASK( SXsvfInfo* pXsvfInfo ){ readVal( &(pXsvfInfo->lvTdoMask), pXsvfInfo->sShiftLengthBytes ); XSVFDBG_PRINTF( 4, " TDO Mask = "); XSVFDBG_PRINTLENVAL( 4, &(pXsvfInfo->lvTdoMask) ); XSVFDBG_PRINTF( 4, "\n"); return( XSVF_ERROR_NONE );}/****************************************************************************** Function: xsvfDoXSIR* Description: XSIR <(byte)shiftlen> <lenVal.TDI[shiftlen]>* Get the instruction and shift the instruction into the TAP.* If prespecified XRUNTEST!=0, goto RUNTEST and wait after* the shift for XRUNTEST usec.* Parameters: pXsvfInfo - XSVF information pointer.* Returns: int - 0 = success; non-zero = error.*****************************************************************************/int xsvfDoXSIR( SXsvfInfo* pXsvfInfo ){ unsigned char ucShiftIrBits; short sShiftIrBytes; int iErrorCode; /* Get the shift length and store */ readByte( &ucShiftIrBits ); sShiftIrBytes = xsvfGetAsNumBytes( ucShiftIrBits ); XSVFDBG_PRINTF1( 3, " XSIR length = %d\n", ((unsigned int)ucShiftIrBits) ); if ( sShiftIrBytes > MAX_LEN ) { iErrorCode = XSVF_ERROR_DATAOVERFLOW; } else { /* Get and store instruction to shift in */ readVal( &(pXsvfInfo->lvTdi), xsvfGetAsNumBytes( ucShiftIrBits ) ); /* Shift the data */ iErrorCode = xsvfShift( &(pXsvfInfo->ucTapState), XTAPSTATE_SHIFTIR, ucShiftIrBits, &(pXsvfInfo->lvTdi), /*plvTdoCaptured*/0, /*plvTdoExpected*/0, /*plvTdoMask*/0, pXsvfInfo->ucEndIR, pXsvfInfo->lRunTestTime, /*ucMaxRepeat*/0 ); } if ( iErrorCode != XSVF_ERROR_NONE ) { pXsvfInfo->iErrorCode = iErrorCode; } return( iErrorCode );}/****************************************************************************** Function: xsvfDoXSIR2* Description: XSIR <(2-byte)shiftlen> <lenVal.TDI[shiftlen]>* Get the instruction and shift the instruction into the TAP.* If prespecified XRUNTEST!=0, goto RUNTEST and wait after* the shift for XRUNTEST usec.* Parameters: pXsvfInfo - XSVF information pointer.* Returns: int - 0 = success; non-zero = error.*****************************************************************************/int xsvfDoXSIR2( SXsvfInfo* pXsvfInfo ){ long lShiftIrBits; short sShiftIrBytes; int iErrorCode; /* Get the shift length and store */ readVal( &(pXsvfInfo->lvTdi), 2 ); lShiftIrBits = value( &(pXsvfInfo->lvTdi) ); sShiftIrBytes = xsvfGetAsNumBytes( lShiftIrBits ); XSVFDBG_PRINTF1( 3, " XSIR2 length = %d\n", lShiftIrBits); if ( sShiftIrBytes > MAX_LEN ) { iErrorCode = XSVF_ERROR_DATAOVERFLOW; } else { /* Get and store instruction to shift in */ readVal( &(pXsvfInfo->lvTdi), xsvfGetAsNumBytes( lShiftIrBits ) ); /* Shift the data */ iErrorCode = xsvfShift( &(pXsvfInfo->ucTapState), XTAPSTATE_SHIFTIR, lShiftIrBits, &(pXsvfInfo->lvTdi), /*plvTdoCaptured*/0, /*plvTdoExpected*/0, /*plvTdoMask*/0, pXsvfInfo->ucEndIR, pXsvfInfo->lRunTestTime, /*ucMaxRepeat*/0 ); } if ( iErrorCode != XSVF_ERROR_NONE ) { pXsvfInfo->iErrorCode = iErrorCode; } return( iErrorCode );}/****************************************************************************** Function: xsvfDoXSDR* Description: XSDR <lenVal.TDI[XSDRSIZE]>* Shift the given TDI data into the JTAG scan chain.* Compare the captured TDO with the expected TDO from the* previous XSDRTDO command using the previously specified* XTDOMASK.* Parameters: pXsvfInfo - XSVF information pointer.* Returns: int - 0 = success; non-zero = error.*****************************************************************************/int xsvfDoXSDR( SXsvfInfo* pXsvfInfo ){ int iErrorCode; readVal( &(pXsvfInfo->lvTdi), pXsvfInfo->sShiftLengthBytes ); /* use TDOExpected from last XSDRTDO instruction */ iErrorCode = xsvfShift( &(pXsvfInfo->ucTapState), XTAPSTATE_SHIFTDR, pXsvfInfo->lShiftLengthBits, &(pXsvfInfo->lvTdi), &(pXsvfInfo->lvTdoCaptured), &(pXsvfInfo->lvTdoExpected), &(pXsvfInfo->lvTdoMask), pXsvfInfo->ucEndDR, pXsvfInfo->lRunTestTime, pXsvfInfo->ucMaxRepeat ); if ( iErrorCode != XSVF_ERROR_NONE ) { pXsvfInfo->iErrorCode = iErrorCode; } return( iErrorCode );}/****************************************************************************** Function: xsvfDoXRUNTEST* Description: XRUNTEST <uint32>* Prespecify the XRUNTEST wait time for shift operations.* Parameters: pXsvfInfo - XSVF information pointer.* Returns: int - 0 = success; non-zero = error.*****************************************************************************/int xsvfDoXRUNTEST( SXsvfInfo* pXsvfInfo ){ readVal( &(pXsvfInfo->lvTdi), 4 ); pXsvfInfo->lRunTestTime = value( &(pXsvfInfo->lvTdi) ); XSVFDBG_PRINTF1( 3, " XRUNTEST = %ld\n", pXsvfInfo->lRunTestTime ); return( XSVF_ERROR_NONE );}/****************************************************************************** Function: xsvfDoXREPEAT* Description: XREPEAT <byte>* Prespecify the maximum number of XC9500/XL retries.* Parameters: pXsvfInfo - XSVF information pointer.* Returns: int - 0 = success; non-zero = error.*****************************************************************************/int xsvfDoXREPEAT( SXsvfInfo* pXsvfInfo ){ readByte( &(pXsvfInfo->ucMaxRepeat) ); XSVFDBG_PRINTF1( 3, " XREPEAT = %d\n", ((unsigned int)(pXsvfInfo->ucMaxRepeat)) ); return( XSVF_ERROR_NONE );}/****************************************************************************** Function: xsvfDoXSDRSIZE* Description: XSDRSIZE <uint32>* Prespecify the XRUNTEST wait time for shift operations.* Parameters: pXsvfInfo - XSVF information pointer.* Returns: int - 0 = success; non-zero = error.*****************************************************************************/int xsvfDoXSDRSIZE( SXsvfInfo* pXsvfInfo ){ int iErrorCode; iErrorCode = XSVF_ERROR_NONE; readVal( &(pXsvfInfo->lvTdi), 4 ); pXsvfInfo->lShiftLengthBits = value( &(pXsvfInfo->lvTdi) ); pXsvfInfo->sShiftLengthBytes= xsvfGetAsNumBytes( pXsvfInfo->lShiftLengthBits ); XSVFDBG_PRINTF1( 3, " XSDRSIZE = %ld\n", pXsvfInfo->lShiftLengthBits ); if ( pXsvfInfo->sShiftLengthBytes > MAX_LEN ) { iErrorCode = XSVF_ERROR_DATAOVERFLOW; pXsvfInfo->iErrorCode = iErrorCode; } return( iErrorCode );}/****************************************************************************** Function: xsvfDoXSDRTDO* Description: XSDRTDO <lenVal.TDI[XSDRSIZE]> <lenVal.TDO[XSDRSIZE]>* Get the TDI and expected TDO values. Then, shift.* Compare the expected TDO with the captured TDO using the* prespecified XTDOMASK.* Parameters: pXsvfInfo - XSVF information pointer.* Returns: int - 0 = success; non-zero = error.*****************************************************************************/int xsvfDoXSDRTDO( SXsvfInfo* pXsvfInfo ){ int iErrorCode; iErrorCode = xsvfBasicXSDRTDO( &(pXsvfInfo->ucTapState), pXsvfInfo->lShiftLengthBits, pXsvfInfo->sShiftLengthBytes, &(pXsvfInfo->lvTdi), &(pXsvfInfo->lvTdoCaptured), &(pXsvfInfo->lvTdoExpected), &(pXsvfInfo->lvTdoMask), pXsvfInfo->ucEndDR, pXsvfInfo->lRunTestTime, pXsvfInfo->ucMaxRepeat ); if ( iErrorCode != XSVF_ERROR_NONE ) { pXsvfInfo->iErrorCode = iErrorCode; } return( iErrorCode );}/****************************************************************************** Function: xsvfDoXSETSDRMASKS* Description: XSETSDRMASKS <lenVal.AddressMask[XSDRSIZE]>* <lenVal.DataMask[XSDRSIZE]>* Get the prespecified address and data mask for the XSDRINC* command.* Used for xc9500/xl compressed XSVF data.* Parameters: pXsvfInfo - XSVF information pointer.* Returns: int - 0 = success; non-zero = error.*****************************************************************************/#ifdef XSVF_SUPPORT_COMPRESSIONint xsvfDoXSETSDRMASKS( SXsvfInfo* pXsvfInfo ){ /* read the addressMask */ readVal( &(pXsvfInfo->lvAddressMask), pXsvfInfo->sShiftLengthBytes ); /* read the dataMask */ readVal( &(pXsvfInfo->lvDataMask), pXsvfInfo->sShiftLengthBytes ); XSVFDBG_PRINTF( 4, " Address Mask = " ); XSVFDBG_PRINTLENVAL( 4, &(pXsvfInfo->lvAddressMask) ); XSVFDBG_PRINTF( 4, "\n" ); XSVFDBG_PRINTF( 4, " Data Mask = " ); XSVFDBG_PRINTLENVAL( 4, &(pXsvfInfo->lvDataMask) ); XSVFDBG_PRINTF( 4, "\n" ); return( XSVF_ERROR_NONE );}#endif /* XSVF_SUPPORT_COMPRESSION *//****************************************************************************** Function: xsvfDoXSDRINC* Description: XSDRINC <lenVal.firstTDI[XSDRSIZE]> <byte(numTimes)>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -