Altera_Forum
Honored Contributor
16 years agoSSRAM to DDR buffer copy
Hello,
i've tried to copy a buffer stored in the SSRAM (2 Mbytes) that is filled by a VHDL block to a file, on DDR. Here is my code :
void dumpDataToFile(void){
unsigned int addr, dataLength;
unsigned char *buffer;
FILE * outfile;
dataLength= 2*1024*1024;
buffer=(unsigned char *)malloc(dataLength);
addr=(unsigned int *)SRAM_BASE;
memcpy(buffer, addr, dataLength);
outfile = fopen("data.bin", "wb" );
fwrite (buffer, dataLength, 1, outfile);
fclose (outfile);
free(bufferimg);
}
It works, but it's dramatically slow. About 4MBytes/sec. the file is in ramdisk, DDR as i said, so i don't understand why this is so slow. For my project, i don't need 200MB/s, but at least 15~20MB/s. both SSRAM and DDR have huge transfer rate compare to that poor 4MB/s i've tested each code line and it seems that for now it is the memcpy that slow down the function. read only in sram => fast fwrite => fast i've tested to read myself too, insteed of using memcpy and result are quite the same... My development platform is the cyclone II dev board, with a nios II and uClinux with 2.6.30 kernel. Any ideas on how i can increase my transfert rate ? Thank you in advance