/***************************************************************************** * Function: xsvfShift * Description: Goes to the given starting TAP state. * Calls xsvfShiftOnly to shift in the given TDI data and * optionally capture the TDO data. * Compares the TDO captured data against the TDO expected * data. * If a data mismatch occurs, then executes the exception * handling loop upto ucMaxRepeat times. * Parameters: pucTapState - Ptr to current TAP state. * ucStartState - Starting shift state: Shift-DR or Shift-IR. * lNumBits - number of bits to shift. * plvTdi - ptr to lenval for TDI data. * plvTdoCaptured - ptr to lenval for storing TDO data. * plvTdoExpected - ptr to expected TDO data. * plvTdoMask - ptr to TDO mask. * ucEndState - state in which to end the shift. * lRunTestTime - amount of time to wait after the shift. * ucMaxRepeat - Maximum number of retries on TDO mismatch. * Returns: int - 0 = success; otherwise TDO mismatch. * Notes: XC9500XL-only Optimization: * Skip the EEWaitTime() if plvTdoMask->val[0:plvTdoMask->len-1] * is NOT all zeros and sMatch==1. *****************************************************************************/ int xsvfShift( PBYTE pucTapState, BYTE ucStartState, LONG lNumBits, PLENVALUE plvTdi, PLENVALUE plvTdoCaptured, PLENVALUE plvTdoExpected, PLENVALUE plvTdoMask, BYTE ucEndState, LONG lRunTestTime, BYTE ucMaxRepeat ) { int iErrorCode; int iMismatch; BYTE ucRepeat; iErrorCode = XSVF_ERROR_NONE; iMismatch = 0; ucRepeat = 0; if ( !lNumBits ) { // Compatibility with XSVF2.00: XSDR 0 = no shift, but wait in RTI if ( lRunTestTime ) { // Wait for prespecified XRUNTEST time xsvfGotoTapState( pucTapState, XTAPSTATE_RUNTEST ); EEWaitTime( lRunTestTime ); } } else { do { // Goto Shift-DR or Shift-IR xsvfGotoTapState( pucTapState, ucStartState ); // Shift TDI and capture TDO xsvfShiftOnly( lNumBits, plvTdi, plvTdoCaptured ); if ( plvTdoExpected ) { // Compare TDO data to expected TDO data iMismatch = !LVEqual( plvTdoExpected, plvTdoCaptured, plvTdoMask ); } if ( ucStartState == ucEndState ) { // Staying/continuing in shift state; clock in last TDI bit EEPulseClock(); } else // Exit shift { if ( iMismatch && lRunTestTime && ( ucRepeat < ucMaxRepeat ) ) { // Do exception handling retry - ShiftDR only xsvfGotoTapState( pucTapState, XTAPSTATE_PAUSEDR ); // Shift 1 extra bit xsvfGotoTapState( pucTapState, XTAPSTATE_SHIFTDR ); // Increment RUNTEST time by an additional 25% lRunTestTime += ( lRunTestTime >> 2 ); } else { // Do normal exit from Shift-XR xsvfGotoTapState( pucTapState, ucEndState ); } if ( lRunTestTime ) { // Wait for prespecified XRUNTEST time xsvfGotoTapState( pucTapState, XTAPSTATE_RUNTEST ); EEWaitTime( lRunTestTime ); } } } while ( iMismatch && ( ucRepeat++ < ucMaxRepeat ) );
/***************************************************************************** * Function: xsvfShift * Description: Goes to the given starting TAP state. * Calls xsvfShiftOnly to shift in the given TDI data and * optionally capture the TDO data. * Compares the TDO captured data against the TDO expected * data. * If a data mismatch occurs, then executes the exception * handling loop upto ucMaxRepeat times. * Parameters: pucTapState - Ptr to current TAP state. * ucStartState - Starting shift state: Shift-DR or Shift-IR. * lNumBits - number of bits to shift. * plvTdi - ptr to lenval for TDI data. * plvTdoCaptured - ptr to lenval for storing TDO data. * plvTdoExpected - ptr to expected TDO data. * plvTdoMask - ptr to TDO mask. * ucEndState - state in which to end the shift. * lRunTestTime - amount of time to wait after the shift. * ucMaxRepeat - Maximum number of retries on TDO mismatch. * Returns: int - 0 = success; otherwise TDO mismatch. * Notes: XC9500XL-only Optimization: * Skip the waitTime() if plvTdoMask->val[0:plvTdoMask->len-1] * is NOT all zeros and sMatch==1. *****************************************************************************/ int xsvfShift( unsigned char* pucTapState, unsigned char ucStartState, long lNumBits, lenVal* plvTdi, lenVal* plvTdoCaptured, lenVal* plvTdoExpected, lenVal* plvTdoMask, unsigned char ucEndState, long lRunTestTime, unsigned char ucMaxRepeat ) { int xdata iErrorCode; int xdata iMismatch; unsigned char xdata ucRepeat; int xdata iExitShift; iErrorCode = XSVF_ERROR_NONE; iMismatch = 0; ucRepeat = 0; iExitShift = ( ucStartState != ucEndState ); if ( !lNumBits ) { /* Compatibility with XSVF2.00: XSDR 0 = no shift, but wait in RTI */ if ( lRunTestTime ) { /* Wait for prespecified XRUNTEST time */ xsvfGotoTapState( pucTapState, XTAPSTATE_RUNTEST ); XSVFDBG_PRINTF1( 3, " Wait = %ld usec\n", lRunTestTime ); waitTime( lRunTestTime ); } } else { do { /* Goto Shift-DR or Shift-IR */ xsvfGotoTapState( pucTapState, ucStartState ); /* Shift TDI and capture TDO */ xsvfShiftOnly( lNumBits, plvTdi, plvTdoCaptured, iExitShift ); if ( plvTdoExpected ) { /* Compare TDO data to expected TDO data */ iMismatch = !EqualLenVal( plvTdoExpected, plvTdoCaptured, plvTdoMask ); } if ( iExitShift ) { /* Update TAP state: Shift->Exit */ ++(*pucTapState); XSVFDBG_PRINTF1( 3, " TAP State = %s\n", xsvf_pzTapState[ *pucTapState ] ); if ( iMismatch && lRunTestTime && ( ucRepeat < ucMaxRepeat ) ) { /* Do exception handling retry - ShiftDR only */ xsvfGotoTapState( pucTapState, XTAPSTATE_PAUSEDR ); /* Shift 1 extra bit */ xsvfGotoTapState( pucTapState, XTAPSTATE_SHIFTDR ); /* Increment RUNTEST time by an additional 25% */ lRunTestTime += ( lRunTestTime >> 2 ); } else { /* Do normal exit from Shift-XR */ xsvfGotoTapState( pucTapState, ucEndState ); } if ( lRunTestTime ) { /* Wait for prespecified XRUNTEST time */ xsvfGotoTapState( pucTapState, XTAPSTATE_RUNTEST ); XSVFDBG_PRINTF1( 3, " Wait = %ld usec\n", lRunTestTime ); waitTime( lRunTestTime ); } } } while ( iMismatch && ( ucRepeat++ < ucMaxRepeat ) );