Forum Discussion
Altera_Forum
Honored Contributor
15 years agoHi teddy,
--- Quote Start --- p = fopen("C:\test1.txt", "w"); fprintf(fp, "%d", output_data); fclose(fp); --- Quote End --- Akira is right. You need a filesystem for that. But as Cris mentioned, I am also concerned about the IOWR/IORD-part. If I got you right, you want to write input_data to some SDRAM-address and read it back for printing it. First: I would let the compiler allocate memory for you, unless you know what is at the specified address. You can use malloc or something like that or you just declare a variable. For example (assumed that data region is located at SDRAM):#include <stdio.h># include <unistd.h># include "system.h"
int input_data = 1;
int output_data = 0;
int output_data_read = 0;
int main()
{
IOWR(&output_data,0,input_data); // write input_data to output_data with IOWR
output_data_read = IORD(&output_data,0); // read it back from output_data to output_data_read
printf("output data = %d\n", output_data_read); // printing on STDOUT
return 0;
}
Second: I would usually use IOWR/IORD only in cases where it can be neccessary. Like bypassing the data cache. Otherwise, better use standard C-coding for accessing memory. Regards, PhilippYogesh
Occasional Contributor
5 years agoHi,
How to use standard C coding to access memory as per your answer?
I am having an array of data say 1,2,3...10. I want to write this data to FPGA memory( say address 1,2,3...10) using C code .
How to do this ? Can you please provide a sample code to do the same ?
Thankyou
Regards,
Yogesh
How to use standard C coding to access memory as per your answer?
I am having an array of data say 1,2,3...10. I want to write this data to FPGA memory( say address 1,2,3...10) using C code .
How to do this ? Can you please provide a sample code to do the same ?
Thankyou
Regards,
Yogesh