|
发表于 2010-6-21 15:00:01
|
显示全部楼层
cpld 下载1.5,仅供学习。点击此处下载 ourdev_562948BD1RHJ.rar(文件大小:6.53M) (原文件名:Xilinx CPLD Download Tool V1.5i for Win2k&XP Setup.rar)
仅供学习,另附自己1999年编写的CPLD/fpga下载代码。使用*.bit格式。
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <alloc.h>
#include <io.h>
#include <dos.h>
#include <ctype.h>
#include <time.h>
#include <bios.h>
FILE *fp;
int handle;
unsigned long len,i,start,end,n=0;
unsigned char *buf,c,j,*p,data,m,d,flag[4],w=0,names[4096];
float tt;
/* gnd ,cclk(d1),done(null,input),din(d0),prog(d3),init(null, input or output(low) delay configure)*/
main(int argc,char *argv[])
{
strcpy(names,argv[0]);
names[strlen(argv[0])-7]=0;
if(argc!=1)printf("%s>%s %s\n",names,argv[0],argv[1]);
if(argc<2){printf("Usage: pf inputfile(*.bit)\n Configure FPGA From PC Paralle!\n");exit(-2);}
fp=fopen(argv[1],"rb");
if(!fp){printf("\nOpen file %s error!\n",argv[1]);exit(-1);}
strcpy(names,"del ");
strcat(names,argv[1]);
handle=fileno(fp);
len=filelength(handle);
p=buf=(char *)malloc(len);
fread(buf,len,1,fp);
p=buf+71;
fclose(fp);
flag[0]='|';
flag[1]='/';
flag[2]='-';
flag[3]='\\';
data=0;
next:
start=biostime(0,0L);
outport(0x378,0x0); /*reset fpga prog=low*/
delay(10);
outport(0x378,0x8); /*prog=high*/
delay(1); /*wait init goes high*/
buf=p;
printf("\nConfigure FPGA from PC Parallel....\n");
for(i=0;i<len-71;i++){
c=*buf++;
n++;
if(n>1024){gotoxy(1,wherey());
printf("%c",flag[w%4]);w++;n=0;}
for(j=0;j<8;j++){
if((c<<j)&0x80)data=11; /*prog,cclk hold, data=1*/
else data=10; /*prog,cclk hold, data=0*/
outport(0x378,data); /*output data to din*/
outport(0x378,data&=0x9); /*prog,data hold ,cclk=low*/
outport(0x378,data|=2); /*cclk=high,prog=high,data hold*/
}
}
end=biostime(0,0L);
tt=1.0*(end-start)/CLK_TCK;
gotoxy(1,wherey());
printf("Complete !!!\nTime used:%.3fsecs\n",tt);
} |
|