Forum Discussion
Altera_Forum
Honored Contributor
15 years agoAll global variables are accessed via GP, as the NIOS instruction set does not have an instruction that uses a (32 bit) direct address (obviously: the instruction code is just 32 bits :) ).
Only thread vars (__thread keyword) are accessed via a different register. The load/store instructions only provide a signed 16 bit "offset" so you are right that only +/32 K is possible. (The Linker can "reloc" ate them correctly to be GP-relative.) I suppose the linker and the OS will place GP at the beginning of the global variables area and thus in fact only some 32K global variables are possible in a program, unless the compiler provides a method to access them with slower code than usual (in a dedicated "far" region). I don't know whether the compiler/linker can do this, but obviously it needs to be defined in the make/linker scripts. Supposedly same holds for consts that I think are just global variables initialized when loading the program. -Michael