Jump to content
  • 0

Configuration of Spartan-3E Using Boundary Scan


humuji

Question

Hi

        I am trying to program spartan-3e(NEXYS2) using boundary scan based on  Digilent Adept JTAG Interface
(DJTG) Programmer’s Reference Manual. And i find a demo(
xilinx_jtag_prigramming_linux.c)[1] about how to program

spartan-2 in JTAG mode through a parallel port. I have rewritten a procedure refer to the demo[1] basing on Digilent Adept

JTAG Interface (DJTG) Programmer’s Reference Manual and Spartan-3 Generation Configuration User Guide. But it dose't work.

       My question is whether there are some differences between spartan-3e and spartan-2 in JTAG programming? i can not

find the document about configuration and readback of Spartan-3 and Spartan-3e in xilinx website. And how Adept programs

spartan-3e in JTAG mode through USB cable?

      Any help will be appreciated, thank you!

 

 

Link to comment
Share on other sites

12 answers to this question

Recommended Posts

Hi @humuji,

I reached out to our design engineer. They responded after looking at jtscdvclist.txt that they can tell that the Spartan 3E is a different programming algorithm than Spartan 2. They don’t know what the difference between the two programming algorithms are. Did you try using djtgcfg to program the Spartan 3E on your board to see if Adept even has the correct algorithm?

thank you,

Jon

Link to comment
Share on other sites

Hi @jpeyron 

          As it is showed in the figure 1, i have tried to program Spartan-3e through Adept and it works well.  

          image.png.68333f050ccb59c61ea585ae60e19ba4.png

                                                                           figure 1

           I also rewrite  a procedure referring to Spartan-6 FPGA Configuration user guide. This proceduer can download some 

bit files correctly, but failed for other bit files. I haven't found the reason yet.The jtag configuration steps i found in Spartan-6  FPGA Configuration user guide

are showed in figure 2.

image.png.8d43598bfc690b9a1cfd6fae9dc52af4.png

                                                             figure 2

And the following is my procedure. Can you tell me in which step i made a mistake.Thank you!

humuji

Spoiler

 

#define _CRT_SECURE_NO_WARNINGS

/* ------------------------------------------------------------ */
/*                    Include File Definitions                    */
/* ------------------------------------------------------------ */

#if defined(WIN32)
    
    /* Include Windows specific headers here.
    */
    #include <windows.h>
    
#else

    /* Include Unix specific headers here.
    */
    

#endif

#include <stdio.h>
#include <stdlib.h>

#include "dpcdecl.h" 
#include "djtg.h"
#include "dmgr.h"

/* ------------------------------------------------------------ */
/*                Local Type and Constant Definitions                */
/* ------------------------------------------------------------ */


/* ------------------------------------------------------------ */
/*                Global Variables                                */
/* ------------------------------------------------------------ */
HIF hif;

/* ------------------------------------------------------------ */
/*                Local Variables                                    */
/* ------------------------------------------------------------ */


/* ------------------------------------------------------------ */
/*                Forward Declarations                            */
/* ------------------------------------------------------------ */
void decode_id(int id);
void ShowUsage(char* szProgName);
void ErrorExit();

#define file_name "D:\\VS_workspace\\work1\\DJAG_download_bit\\DJAG_read_idcode\\led_test.bit"
#define number_per_trans 10240
/* ------------------------------------------------------------ */
/*                Procedure Definitions                            */
/* ------------------------------------------------------------ */
/***    main
**
**    Parameters:
**        cszArg        - number of command line arguments
**        rgszArg        - array of command line argument strings
**
**    Return Value:
**
**    Errors:
**
**    Description:
**        Run the program.
*/

int main(int cszArg, char* rgszArg[]) {

    char *rbname = file_name;        /*rbt file name*/
    FILE *f;            /*rbt file ptr*/
    char c, next;        /*char from f*/
    unsigned char uc;
    BYTE  in_data[number_per_trans];
    BYTE last_byte;
    BYTE last_input[2];
    BYTE buffer;

    long bitcount;
    int n, x, len, len2, token;
    int devid;
    int i;

    /* Command checking */
    if( cszArg < 3 ) {
        ShowUsage(rgszArg[0]);
        ErrorExit();
    }
    if( strcmp(rgszArg[1], "-d") != 0 ) {
        ShowUsage(rgszArg[0]);
        ErrorExit();
    }
    //========================================
    //=========get input file
    if ((f = fopen(rbname, "r")) == NULL){
        printf("The file can not opened.\n");
        ErrorExit();
    }
    else{
        printf("The file %s is opened successfully.\n",rbname);
    }

    //=========================================
    //=========parse binary Header 
    uc = getc(f);
    len = uc << 8;
    uc = getc(f);
    len += uc;
    for (x = 0; x < len; x++)
        c = getc(f);

    uc = getc(f);
    len = uc << 8;
    uc = getc(f);
    len += uc;
    //printf("Length: %0d\n",len);

    uc = getc(f);
    token = uc;
    //printf("Token: %x\n",token);

    uc = getc(f);
    len = uc << 8;
    uc = getc(f);
    len += uc;
    //printf("Length: %0d\n",len);

    printf("Design Name: ");

    for (x = 0; x < len; x++)
    {
        uc = getc(f);
        printf("%c", uc);
    }
    printf("\n");

    uc = getc(f);
    token = uc;
    //printf("Token: %x\n",token);

    uc = getc(f);
    len = uc << 8;
    uc = getc(f);
    len += uc;
    //printf("Length: %0d\n",len);

    printf("Device: ");

    for (x = 0; x < len; x++)
    {
        uc = getc(f);
        printf("%c", uc);
    }
    printf("\n");


    uc = getc(f);
    token = uc;
    //printf("Token: %x\n",token);

    uc = getc(f);
    len = uc << 8;
    uc = getc(f);
    len += uc;
    //printf("Length: %0d\n",len);

    printf("Date: ");

    for (x = 0; x < len; x++)
    {
        uc = getc(f);
        printf("%c", uc);
    }
    printf("\n");


    uc = getc(f);
    token = uc;
    //printf("Token: %x\n",token);

    uc = getc(f);
    len = uc << 8;
    uc = getc(f);
    len += uc;
    //printf("Length: %0d\n",len);

    printf("Time: ");

    for (x = 0; x < len; x++)
    {
        uc = getc(f);
        printf("%c", uc);
    }
    printf("\n");

    uc = getc(f);
    token = uc;
    //printf("Token: %x\n",token);

    uc = getc(f);
    len = uc << 24;
    uc = getc(f);
    len += uc << 16;
    uc = getc(f);
    len += uc << 8;
    uc = getc(f);
    len += uc;
    printf("Bitstream Length: %0d bits\n", len * 8);

    // DMGR API Call: DmgrOpen
    if(!DmgrOpen(&hif, rgszArg[2])) {
        printf("Error: Could not open device. Check device name\n");
        ErrorExit();
    }

    // DJTG API CALL: DjtgEnable
    if(!DjtgEnable(hif)) {
        printf("Error: DjtgEnable failed\n");
        ErrorExit();
    }

    // ====================================================
    // ##########  Start of JTAG Programming sequence

    // ====================================================
    // ##########  RESET jtag Logic and put the tap state into SHIFT-IR
    BYTE SHIFT_IR[2] = { 0xdf, 0x00 };
    if (!DjtgPutTmsBits(hif, 0, SHIFT_IR, NULL, 10, NULL)){
        printf("DjtgPutTmsBits1 failed\n");
        ErrorExit();
    }

    // ====================================================
    // ##########  CONFIGURE
    // CFG_IN 000101
    /*Put CFG_IN instruction into TAP*/
    BYTE id_readinstruction[2] = { 0x11, 0x08 };
    if (!DjtgPutTmsTdiBits(hif, id_readinstruction, NULL, 6, NULL)){
        printf("DjtgPutTdiBits_CFG_IN failed\n");
        ErrorExit();
    }
    /*Put the tap state into SHIFT_DR*/
    BYTE SHIFT_DR[1] = { 0x05 };
    if (!DjtgPutTmsBits(hif, 0, SHIFT_DR, NULL, 5, NULL)){
        printf("DjtgPutTmsBits1 failed\n");
        ErrorExit();
    }

    // ====================================================
    // SEND DATA
    bitcount = 0;
    printf("Programming start......\n");
    
    do{
            if ((len - bitcount-1) <= number_per_trans){
                for (n = 0; n < ((len - bitcount) -1); n++){
                    buffer = getc(f);
                    buffer = ((buffer & 0x01) << 7) | ((buffer & 0x02) << 5) | ((buffer & 0x04) << 3) | ((buffer & 0x08) << 1)
                        | ((buffer & 0x10) >> 1) | ((buffer & 0x20) >> 3) | ((buffer & 0x40) >> 5) | ((buffer & 0x80) >> 7);    //mirror the data

                    in_data[n] = buffer;

                }
                if (!DjtgPutTdiBits(hif, 0, in_data, NULL, (len-bitcount-1)*8, NULL)){
                    printf("failed in inputing %d Byte.\n", n);
                    ErrorExit();
                }
                bitcount = bitcount + (len - bitcount - 1);
            }   
            else{
                for (n = 0; n < number_per_trans; n++){
                    buffer = getc(f);
                    buffer = ((buffer & 0x01) << 7) | ((buffer & 0x02) << 5) | ((buffer & 0x04) << 3) | ((buffer & 0x08) << 1)
                        | ((buffer & 0x10) >> 1) | ((buffer & 0x20) >> 3) | ((buffer & 0x40) >> 5) | ((buffer & 0x80) >> 7);    //mirror the data

                    in_data[n] = buffer;

                }
                
                if (!DjtgPutTdiBits(hif, 0, in_data, NULL, number_per_trans * 8, NULL)){
                    printf("failed in inputing %d Byte.\n", n);
                    ErrorExit();
                }
                bitcount = bitcount + number_per_trans;
            }
            printf("bitcount %d\n", bitcount);
    } while (bitcount < len-1);

    /*write the last BYTE*/
        last_byte = getc(f);

        //fseek(f, -2, SEEK_CUR);
        last_byte = ((last_byte & 0x01) << 7) | ((last_byte & 0x02) << 5) | ((last_byte & 0x04) << 3) | ((last_byte & 0x08) << 1)
            | ((last_byte & 0x10) >> 1) | ((last_byte & 0x20) >> 3) | ((last_byte & 0x40) >> 5) | ((last_byte & 0x80) >> 7);    //mirror
        /*printf("%d\n", (int)last_byte);*/
        BYTE bit1 = last_byte & 0x01;
        BYTE bit2 = last_byte & (0x01 << 1);
        BYTE bit3 = last_byte & (0x01 << 2);
        BYTE bit4 = last_byte & (0x01 << 3);
        last_input[0] = (bit4 << 3) | (bit3 << 2) | (bit2 << 1) | (bit1);//combine the low four bits with TMS(0000)
        BYTE bit5 = last_byte & (0x01 << 4);
        BYTE bit6 = last_byte & (0x01 << 5);
        BYTE bit7 = last_byte & (0x01 << 6);
        BYTE bit8 = last_byte & (0x01 << 7);
        last_input[1] = (bit8 >> 1) | 0x80 | (bit7 >> 2) | (bit6 >> 3) | (bit5 >> 4);//combine the high four bits with TMS(0000)
        if (!DjtgPutTmsTdiBits(hif, last_input, NULL, 8, NULL)){
            printf("DjtgPutTdiBits_last_byte_input failed\n");
            ErrorExit();
        }
        bitcount = (bitcount + 1)*8;
    
    printf("\nProgrammed %d bits.\n",bitcount);

    /*Put the tap state into SHIFT-IR state*/
    BYTE SHIFT_IR_2[1] = { 0x0d };
    if (!DjtgPutTmsBits(hif, 0, SHIFT_IR_2, NULL, 6, NULL)){
        printf("DjtgPutTmsBits2 failed\n");
        ErrorExit();
    }


    
    // ====================================================
    // ##########  JSTART 001100
    BYTE JSTART_instr[2] = {0x50,0x08};
    if (!DjtgPutTmsTdiBits(hif, JSTART_instr, NULL, 6, NULL)){
        printf("DjtgPutTmsTdiBits_JSTART failed\n");
        ErrorExit();
    }

    BYTE SHIFT_DR_1[3] = { 0x01,0x00,0x0e };
    if (!DjtgPutTmsBits(hif, 0, SHIFT_DR_1, NULL, 20, NULL)){
        printf("DjtgPutTmsBits1 failed\n");
        ErrorExit();
    }

    printf("Please input a character.\n");
    getchar();

    // Disable Djtg and close device handle
    if( hif != hifInvalid ) {
        // DGTG API Call: DjtgDisable
        DjtgDisable(hif);

        // DMGR API Call: DmgrClose
        DmgrClose(hif);
    }

    return 0;
}


/* ------------------------------------------------------------ */
/***    ShowUsage
**
**    Parameters:
**        szProgName    - name of program as called (from rgszArg[0])
**
**    Return Value:
**        none
**
**    Errors:
**        none
**
**    Description:
**        Demonstrates proper paramater usage to the user
*/

void 
ShowUsage(char* szProgName) {
    printf("Error: Invalid paramaters\n");
    printf("Usage: %s -d <device> \n\n", szProgName);
    getchar();
}

/* ------------------------------------------------------------ */
/***    ErrorExit
**
**    Parameters:
**        none
**
**    Return Value:
**        none
**
**    Errors:
**        none
**
**    Description:
**        Disables DJTG, closes the device, and exits the program
*/
void ErrorExit() {
    if( hif != hifInvalid ) {

        // DJGT API Call: DjtgDisable
        DjtgDisable(hif);

        // DMGR API Call: DmgrClose
        DmgrClose(hif);
    }
    printf("please input a character\n");
    getchar();
    exit(1);
}

/* ------------------------------------------------------------ */

/************************************************************************/

 

 

Link to comment
Share on other sites

HI @jpeyron

              I am trying to program spartan-3e xc3s1200 via jtag pins using the spartan-6 configuration user guide. Because i can not find spartan-3e jtag configuration user guide in xilinx website and I assume spartan-3e and spartan-6 are similar in jtag configuration. My board is Nexys2.

thank you,

humuji

Link to comment
Share on other sites

Hi @jpeyron

         Thank you for your help, I have read  Spartan-3 Generation Configuration User Guide Chapter 9. And I write a procedure refer to the svf file generated by 

IMPACT for  xc3s1200e(NEXYS2) . When i tried to dowanload bit files through this procedure , something wrong happened. If i download a bit file with simple  logic, it works well. But when i download a bit file with complex logic, it can not work and the DONE pin not goes high after configuration. I guess maybe a mistake

happened in CRC check when complex bit file is downloaded. But i haven't found the reason yet, and don't know how to fix it.

        The timer_svf(Complex).svf SVF file generated by IMPACT has been attached.

        Can you or your design engineer give me some advises, thank you!

        The SVF file generated by IMPACT has been attached in the following.

humuji

timer_svf(Complex).svf

Link to comment
Share on other sites

Hi @jpeyron

       I meet with a problem when i try to use the function of DjtgSetSpeed(HIF hif,DWORD frqReq,DWORD *pfrqSet) which comes from digilent.adept.sdkv2.1.1. And the

error code returned is 1.

      Can you help me, Thank you!

Link to comment
Share on other sites

Hi @humuji,

I reached out to one of our design engineers about this thread. They responded that the Error code 1 is ercNotSupported which means that functionality isn’t supported. The JTAG interface of our Cypress based solution is implemented through a bitbang and only operates at one frequency, which is approximately 1.8MHz. Could you be more specific what are you trying to do with you project?  Here is an AR that might be helpful as well.

thank you,

Jon

Link to comment
Share on other sites

Hi @jpeyron

       I am trying to configure Sparten-3e in Nexys2 in jtag mode based on digilent.adept.sdkv2.1.1. And the jtag frequency required by 

the datasheet of Spartan-3e is 1MHz. So I want to set the frequency to 1MHz by using the function of DjtgSetSpeed(HIF hif,DWORD frqReq,DWORD *pfrqSet)

supported by digilent.adept.sdkv2.1.1.

Link to comment
Share on other sites

Hi @humuji,

What programmer are you using to connect to the Nexys 2; a JTAG-USB cable or something else? Additionally, where are you seeing the 1 MHz requirement for the JTAG frequency? From Table 123 on page 154 of the Spartan-3E datasheet, the JTAG frequency appears to be allowed to go as high as 30 MHz. Additionally, as @jpeyron mentioned, the programming interface on the Nexys 2 only operates at 1.8 MHz so you will not be able to change the frequency through Adept SDK.

Thank you,
JColvin

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...