FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
6356 Discussions

how to deal with data array??

Altera_Forum
Honored Contributor II
1,369 Views

hello everyone: 

now I work on the nios ide. my program is work on a file named"testdata.dat",  

 

static short InData[] = { 

# include "testdata.dat" 

};  

 

after the program run out , i can get a outputdata[ ], the datas can be showed in console. but if i want to gather these datas to a new file which named "outputdata.dat"--I found it by myself. how I can do so. I just use outputdata=outdata, but there is no datas in outputdata.dat. so i thought the datas that i want have been saved in my board (some rom array), but how to gather them in a file that we can see in computer??? 

 

 

thanks a million. 

 

Jennysun
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
655 Views

Your are on your way in the darkness down the wrong road. Its not possible to do what you describe here. (Strictly speaking this is not true, but don't even think of that now.) 

 

Your target is some board with an FPGA, presumably an Altera dev kit. Your program will after compilation run on this board. This board has no way of accessing your files on your dev computer where your sources and testdata.dat are located. So outputdata.dat never get any data. 

 

Even if it had, you would not write to a file the way you describe, at least not if the language is C. And using the# include works but its likely not what you really intend to do. Every time you change the file you will have to recompile. Not practical at all. 

 

I suggest you put away the Nios IDE and fire up a C compiler which is targeting your pc. Grab a C book or some tutorial from the web and get acquainted with the language before starting to use the nios IDE dev environment. This environment is not suitable as a starter for C learning. But have in mind that although possible it is far from trivial and uncommon, to access files on your PC from the FPGA. 

 

Good luck
0 Kudos
Altera_Forum
Honored Contributor II
655 Views

ok , I will try another way . thank you very much:)

0 Kudos
Altera_Forum
Honored Contributor II
655 Views

To avoid re-compling all the time when you change "testdata.dat" you can open the contents of the file over JTAG. So Nios II will open "testdata.dat" just like a file (google search "C file I/O" if you are not familiar with that) and you just have to place the .dat file in a fixed location. Then your embedded system will read in the contents of testdata.dat each time you read from it. I don't recommend this if your test vectors are large since I find the transfer speed is around 4.5kB/s. If you test vector is large then your recompile method would be better (or some other means to transfer data to the system over a high speed link) 

 

The software template "Host FS" will have more details of what to do and will show you how you can open files from your PC and/or have Nios II write files directly to your PC over JTAG. Keep in mind you have to do this in the debugger in the Nios II IDE (Host FS uses gdb to transfer the data). Over in the Nios forum I answered your question about why your line "outputdata=outdata;" doesn't work.
0 Kudos
Reply