1 /* ******************************************************** */
2 /* Small program to download a VHDL program to a JTAG port. */
3 /* Julian Lewis Mon 7th April 2003 */
16 void setPort(short p
,short val
);
17 void readByte(unsigned char *data
);
18 unsigned char readTDOBit();
19 void waitTime(long microsec
);
22 static int xsvf_iDebugLevel
= 0;
23 static FILE *inp
= NULL
;
24 static short *jtagAddr
= NULL
;
25 static unsigned short jtag
= 0x0F; /* Keep all jtag bits */
32 /* ********************************************* */
33 /* Arguments: Filename VME-Address [Debug-Level] */
35 int main(int argc
,char *argv
[]) {
37 char fname
[128], *cp
, *ep
, yn
;
41 if ((argc
< 3) || (argc
> 4)) {
42 printf("jtag: <filename> <vme address> [<debug level>]\n");
43 printf("Examples:\n");
44 printf(" nouchi.xsvf 0x1000\n");
45 printf(" nouchi.xsvf 0x1000 4\n");
49 strcpy(fname
,argv
[1]);
51 vmeAddress
= (short *) strtoul(cp
,&ep
,0);
52 if (argc
== 4) xsvf_iDebugLevel
= strtoul(argv
[3],&ep
,0);
54 printf("VHDL-Compiled BitStream Filename: %s VMEAddress: 0x%X DebugLevel: %d \n",
57 (int) xsvf_iDebugLevel
);
59 printf("Continue (Y/N):"); yn
= getchar();
60 if ((yn
!= 'y') && (yn
!= 'Y')) exit(0);
62 inp
= fopen(fname
,"r");
65 if (GetJtagPort(vmeAddress
)) {
67 cc
= xsvfExecute(); /* Play the xsvf file */
68 if (cc
) printf("Jtag: xsvfExecute: ReturnCode: %d Error\n",cc
);
69 else printf("Jtag: xsvfExecute: ReturnCode: %d All OK\n",cc
);
75 printf("Could not open the file: %s for reading\n",fname
);