Forum Discussion

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

Defining variables of fixed size in Nios Softaware

Is there anyway to define a variable of arbitrary size in Nios Software? for example a 16 bit variable. I know we can use some known types in C like int,... but the size of these variables vary with the compiler. Is there a class defined to use in such cases?

2 Replies

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

    THere's multiple solutions to that:

    a) define your own variable declarations, and use them in your code......could be a problem if you need to re-use existing code, but you can easily redefine it when you move your code to a different target.

    b) some projects/Compilers/tools already bring predefined types like BYTE, WORD, DWORD...... this might or might not work when using your code to other tools/targets, but you be optimistic to have these types on a new target (if not, you can define them to your needs).

    c) use alt_types.h, which defines alt_u8, alt_u16, alt_u32, alt_s8, alt_s16, alt_s32 and so on.....accounts for altera tools only, apart from that same as (b).
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Tnx, so much. I have another question.What is a context argument? Im trying to write ISRs. I've noticed that one of the parameters that alt_irq_register() takes, is context argument.

    tnx in advance.