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++
12748 Discussions

Question regarding NIOS II custom registers

Altera_Forum
Honored Contributor II
1,325 Views

I read the Nios2 custom instruction reference book online, and found that the only way I could read or write data from custom registers is to change the assembly code (change rA or rB to cA and cB). 

 

However, if I were to load the C program directly to the Nios board, the IDE will never know that I use custom registers. (because when it compiles, IDE automatically assign all the variables to Nios registers) 

 

so my question is how do I let the IDE compiler know that some of my custom instructions use custom registers instead of Nios registers? 

 

any suggestions will be very appreciated http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
657 Views

I&#39;m not sure exactly what you mean here. 

 

What assembly code do you want to generate? And what&#39;s being generated? 

 

The best way to get custom instructions emitted is to use a function from the __builtin_custom family, or the wrapper which is built around it within system.h. 

 

If this isn&#39;t flexible enough then you can also use asm() statements within C code but you must make sure you get your constraints right as otherwise the generated code will be very inefficient or wrong.
0 Kudos
Altera_Forum
Honored Contributor II
657 Views

okei let me rephrase my question in a simpler way: 

 

after I use the __builtin_custom functions, how do I let the compiler know that I am using custom registers instead of NIOS2 registers? 

 

__builtin_custom only tells the compiler that I am using custom instructions, but it does not give informations to custom REGISTERS~
0 Kudos
Altera_Forum
Honored Contributor II
657 Views

The compiler won&#39;t be able to use your custom registers. You&#39;ll have to manage them yourself explicitly.

0 Kudos
Altera_Forum
Honored Contributor II
657 Views

Thanks James & wombat~ 

 

I guess I&#39;ll use asm() to do it...
0 Kudos
Reply