file io with NIOS II
Hi all
I wrote a code to read the text file
for implementing in FPGA board (DE1-SOC) with NIOS II ,
but when I build the project, the elf file wasn't generated.
here's my code
--------------------------------------------------------------------------------------------
#include <stdio.h> int main() { int num; int ret; FILE * fp; fp=fopen("C:\\users\\HW\\Desktop\\test_num.txt","r"); ret=fscanf(fp,"%d",&num); printf("number is %d \n",num+ret); fclose(fp); return 0; }
------------------------------------------------------------------------------------------------------------
1. if there is a problem, Could somebody tell me what's wrong with it??
(with detail , I'll be really appreciated)
++ 2. I heard that there are many ways to transfer data from host PC to FPGA board,
like UARR
I'm a newbie with FPGA,
so I DESPERATELY need some help......
Hi, Dong Wook
You are right.
However, there is another way, ie using a character-mode device like UART.
Below example is to write characters to a UART called uart1. You can find the device name (/dev/uart1) in the system.h
#include <stdio.h>
#include <string.h>
int main (void)
{
char* msg = "hello world";
FILE* fp;
fp = fopen ("/dev/uart1", "w");
if (fp!=NULL) { fprintf(fp, "%s",msg); fclose (fp);}
return 0;
}
Thanks.
Eric