madalin1990
Full Member level 2
Hi!
I have a program that is supossed to send bits from a file saved in computer to a memory implemented on FPGA. There are two Depp functions usedeppPutReg is used to specify the start address and DeppPutRegRepeat to copy the data from the file to the memory.
The logic implemented on the FPGA automatically increases the address after a bite is copied at a address. The problem is when i try 2 send 2 bytes the memory address increases by two instead of 16.
My question is what should i modify in the code below to make my HW read the bites correctly:
I have a program that is supossed to send bits from a file saved in computer to a memory implemented on FPGA. There are two Depp functions usedeppPutReg is used to specify the start address and DeppPutRegRepeat to copy the data from the file to the memory.
The logic implemented on the FPGA automatically increases the address after a bite is copied at a address. The problem is when i try 2 send 2 bytes the memory address increases by two instead of 16.
My question is what should i modify in the code below to make my HW read the bites correctly:
Code:
void DoPutRegs() {
BYTE idStartMemAddress;
char * szStop;
long cb;
BYTE rgbLd[cbBlockSize];
int cbSend, cbSendTotal, cbSendCheck;
cb = strtol(szCount, &szStop, 10);
idStartMemAddress = (BYTE) strtol(szAddressStart, &szStop, 10);
if(!DeppPutReg(hif, HW_REG_MEM_ADDRESS, idStartMemAddress, fFalse)) {
printf("DeppPutReg failed\n");
return;
}
fopen_s(&fhin, szFile, "r+b");
if (fhin == NULL) {
printf("Cannot open file\n");
ErrorExit();
}
// write the file into the data register
cbSendTotal = cb;
cbSend = 0;
while (cbSendTotal > 0) {
if ((cbSendTotal - cbBlockSize) <= 0) {
cbSend = cbSendTotal;
cbSendTotal = 0;
}
else {
cbSend = cbBlockSize;
cbSendTotal -= cbBlockSize;
}
cbSendCheck = fread(rgbLd, sizeof(BYTE), cbSend, fhin);
if (cbSendCheck != cbSend) {
printf("Cannot read specified number of bytes from file.\n");
ErrorExit();
}
// DEPP API Call: DeppPutRegRepeat
if(!DeppPutRegRepeat(hif, HW_REG_MEM_DATA, rgbLd, cbSend, fFalse)){
printf("DeppPutRegRepeat failed.\n");
ErrorExit();
}
}
printf("Stream to memory complete!\n");
if( fhin != NULL ) {
fclose(fhin);
}
return;
}