Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

io.h vs normal data access

Altera_Forum
Honored Contributor II
1,906 Views

Hi there, 

 

Maybe a silly question... 

 

What is the purpose of the io.h headerfile? 

 

A memory addressable device can be referenced as follows: 

data = *(INT32U*) 0x200000; 

 

or using io.h 

data = IORD_32DIRECT(0x200000, 0); 

 

I find that it some cases the first option does not work correctly - the device chip selects do not get set while doing the read. 

 

I have now switched to using io.h for such reads but would like to know if anyone can explain this? 

 

Thanks 

 

R
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
1,081 Views

I'm guessing that you have a data cache in your system, which is why you're seeing strange results with your first example. The second example maps onto the ldxio assembly functions which bypass the cache. For more information you should read Writing Device Drivers (page 7-4) in the Nios II Software Developer's Handbook (n2sw_nii5v2.pdf)

0 Kudos
Altera_Forum
Honored Contributor II
1,081 Views

Rikusg. 

 

If you were working with Nios I then what you showed in your first example was correct. However from a software point of view, you can't pre-determine if you will get a cache hit or miss (cache hit in your case will cause the program to fail since your device will not be accessed).
0 Kudos
Reply