Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21600 Discussions

Defining variables of fixed size in Nios Softaware

Altera_Forum
Honored Contributor II
1,357 Views

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?

0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
606 Views

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).
0 Kudos
Altera_Forum
Honored Contributor II
606 Views

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.
0 Kudos
Reply