Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

Question regarding NIOS II custom registers

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

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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~
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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