⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 micro_dynamic_target_for_4_virtex.c

📁 Xilinx Jtag Configuration source code, Support *.xsvf file
💻 C
📖 第 1 页 / 共 5 页
字号:
                    xsvfTmsTransition( 1 );                    *pucTapState    = XTAPSTATE_EXIT1IR;                }                break;            case XTAPSTATE_SHIFTIR:                xsvfTmsTransition( 1 );                *pucTapState    = XTAPSTATE_EXIT1IR;                break;            case XTAPSTATE_EXIT1IR:                if ( ucTargetState == XTAPSTATE_PAUSEIR )                {                    xsvfTmsTransition( 0 );                    *pucTapState    = XTAPSTATE_PAUSEIR;                }                else                {                    xsvfTmsTransition( 1 );                    *pucTapState    = XTAPSTATE_UPDATEIR;                }                break;            case XTAPSTATE_PAUSEIR:                xsvfTmsTransition( 1 );                *pucTapState    = XTAPSTATE_EXIT2IR;                break;            case XTAPSTATE_EXIT2IR:                if ( ucTargetState == XTAPSTATE_SHIFTIR )                {                    xsvfTmsTransition( 0 );                    *pucTapState    = XTAPSTATE_SHIFTIR;                }                else                {                    xsvfTmsTransition( 1 );                    *pucTapState    = XTAPSTATE_UPDATEIR;                }                break;            case XTAPSTATE_UPDATEIR:                if ( ucTargetState == XTAPSTATE_RUNTEST )                {                    xsvfTmsTransition( 0 );                    *pucTapState    = XTAPSTATE_RUNTEST;                }                else                {                    xsvfTmsTransition( 1 );                    *pucTapState    = XTAPSTATE_SELECTDR;                }                break;            default:                iErrorCode      = XSVF_ERROR_ILLEGALSTATE;                *pucTapState    = ucTargetState;    /* Exit while loop */                break;            }            XSVFDBG_PRINTF1( 3, "   TAP State = %s\n",                             xsvf_pzTapState[ *pucTapState ] );        }    }    return( iErrorCode );}/****************************************************************************** Function:     xsvfShiftOnly* Description:  Assumes that starting TAP state is SHIFT-DR or SHIFT-IR.*               Shift the given TDI data into the JTAG scan chain.*               Optionally, save the TDO data shifted out of the scan chain.*               Last shift cycle is special:  capture last TDO, set last TDI,*               but does not pulse TCK.  Caller must pulse TCK and optionally*               set TMS=1 to exit shift state.* Parameters:   lNumBits        - number of bits to shift.*               plvTdi          - ptr to lenval for TDI data.*               plvTdoCaptured  - ptr to lenval for storing captured TDO data.*               iExitShift      - 1=exit at end of shift; 0=stay in Shift-DR.* Returns:      void.*****************************************************************************/void xsvfShiftOnly( long    lNumBits,                    lenVal* plvTdi,                    lenVal* plvTdoCaptured,                    int     iExitShift ){    unsigned char*  pucTdi;    unsigned char*  pucTdo;    unsigned char   ucTdiByte;    unsigned char   ucTdoByte;    unsigned char   ucTdoBit;    int             i;    /* assert( ( ( lNumBits + 7 ) / 8 ) == plvTdi->len ); */    /* Initialize TDO storage len == TDI len */    pucTdo  = 0;    if ( plvTdoCaptured )    {        plvTdoCaptured->len = plvTdi->len;        pucTdo              = plvTdoCaptured->val + plvTdi->len;    }    /* Shift LSB first.  val[N-1] == LSB.  val[0] == MSB. */    pucTdi  = plvTdi->val + plvTdi->len;    while ( lNumBits )    {        /* Process on a byte-basis */        ucTdiByte   = (*(--pucTdi));        ucTdoByte   = 0;        for ( i = 0; ( lNumBits && ( i < 8 ) ); ++i )        {            --lNumBits;            if ( iExitShift && !lNumBits )            {                /* Exit Shift-DR state */                setPort( TMS, 1 );            }            /* Set the new TDI value */            setPort( TDI, (short)(ucTdiByte & 1) );            ucTdiByte   >>= 1;            /* Set TCK low */            setPort( TCK, 0 );            if ( pucTdo )            {                /* Save the TDO value */                ucTdoBit    = readTDOBit();                ucTdoByte   |= ( ucTdoBit << i );            }            /* Set TCK high */            setPort( TCK, 1 );        }        /* Save the TDO byte value */        if ( pucTdo )        {            (*(--pucTdo))   = ucTdoByte;        }    }}/****************************************************************************** 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.*               iHeader         - Number of header bits to shift before data.*               iTrailer        - Number of trailer bits to shift after data.* 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              iHeader,               int              iTrailer ){    int             iErrorCode;    int             iMismatch;    unsigned char   ucRepeat;    int             iExitShift;    int             iHeaderCycles;    int             iTrailerCycles;    iErrorCode  = XSVF_ERROR_NONE;    iMismatch   = 0;    ucRepeat    = 0;    iExitShift  = ( ucStartState != ucEndState );    XSVFDBG_PRINTF1( 3, "   Shift Length = %ld\n", lNumBits );    XSVFDBG_PRINTF1( 4, "    Header Length  = %d\n", iHeader );    XSVFDBG_PRINTF1( 4, "    Trailer Length = %d\n", iTrailer );    XSVFDBG_PRINTF( 4, "    TDI          = ");    XSVFDBG_PRINTLENVAL( 4, plvTdi );    XSVFDBG_PRINTF( 4, "\n");    XSVFDBG_PRINTF( 4, "    TDO Expected = ");    XSVFDBG_PRINTLENVAL( 4, plvTdoExpected );    XSVFDBG_PRINTF( 4, "\n");    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        {            iHeaderCycles   = iHeader;            iTrailerCycles  = iTrailer;            /* Goto Shift-DR or Shift-IR */            xsvfGotoTapState( pucTapState, ucStartState );            if ( iHeaderCycles )            {                setPort( TDI, (short)((ucStartState==XTAPSTATE_SHIFTIR)?1:0) );                while ( iHeaderCycles-- )                {                    pulseClock();                }            }            /* Shift TDI and capture TDO */            xsvfShiftOnly( lNumBits, plvTdi, plvTdoCaptured,                           (iExitShift && !iTrailerCycles) );            if ( plvTdoExpected )            {                /* Compare TDO data to expected TDO data */                iMismatch   = !EqualLenVal( plvTdoExpected,                                            plvTdoCaptured,                                            plvTdoMask );            }            if ( iExitShift )            {                if ( iTrailerCycles )                {                    setPort( TDI,(short)((ucStartState==XTAPSTATE_SHIFTIR)?1:0));                    while ( iTrailerCycles-- )                    {                        if ( iTrailerCycles == 0 )                        {                            setPort( TMS, 1 );                        }                pulseClock();            }                }                /* Update TAP state:  Shift->Exit */                ++(*pucTapState);                XSVFDBG_PRINTF1( 3, "   TAP State = %s\n",                                 xsvf_pzTapState[ *pucTapState ] );                if ( iMismatch && lRunTestTime && ( ucRepeat < ucMaxRepeat ) )                {                    XSVFDBG_PRINTF( 4, "    TDO Expected = ");                    XSVFDBG_PRINTLENVAL( 4, plvTdoExpected );                    XSVFDBG_PRINTF( 4, "\n");                    XSVFDBG_PRINTF( 4, "    TDO Captured = ");                    XSVFDBG_PRINTLENVAL( 4, plvTdoCaptured );                    XSVFDBG_PRINTF( 4, "\n");                    XSVFDBG_PRINTF( 4, "    TDO Mask     = ");                    XSVFDBG_PRINTLENVAL( 4, plvTdoMask );                    XSVFDBG_PRINTF( 4, "\n");                    XSVFDBG_PRINTF1( 3, "   Retry #%d\n", ( ucRepeat + 1 ) );                    /* 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 ) );    }    if ( iMismatch )    {        XSVFDBG_PRINTF( 1, " TDO Expected = ");        XSVFDBG_PRINTLENVAL( 1, plvTdoExpected );        XSVFDBG_PRINTF( 1, "\n");        XSVFDBG_PRINTF( 1, " TDO Captured = ");        XSVFDBG_PRINTLENVAL( 1, plvTdoCaptured );        XSVFDBG_PRINTF( 1, "\n");        XSVFDBG_PRINTF( 1, " TDO Mask     = ");        XSVFDBG_PRINTLENVAL( 1, plvTdoMask );        XSVFDBG_PRINTF( 1, "\n");        if ( ucMaxRepeat && ( ucRepeat > ucMaxRepeat ) )        {            iErrorCode  = XSVF_ERROR_MAXRETRIES;        }        else        {            iErrorCode  = XSVF_ERROR_TDOMISMATCH;        }    }    return( iErrorCode );}/****************************************************************************** Function:     xsvfBasicXSDRTDO* Description:  Get the XSDRTDO parameters and execute the XSDRTDO command.*               This is the common function for all XSDRTDO commands.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -