Altera_Forum
Honored Contributor
22 years agoStrange behaviour on NiosII/f
Hi All,
We are using Nios for a while now and recently ported our code to NiosII. Everything was running stable on a NiosII/s core. Then I tried to run the same code on a NiosII/f and it failed terribly, even when I turned on the 'always_bypass_dcache' option in the .ptf file! After some research I discovered that that our '_disable' macro caused the problem. This macro takes care of disabling the interrupt:#define WR_IENABLE(val) asm volatile (
"WRCTL ienable, %0;"
: /* no outputs */
: "r" (val) );
# define _enable() WR_IENABLE(0xffffffff)
# define _disable() WR_IENABLE(0x00000007) Interrupts 0,1 and 2 are used for 'non maskable' interrupts, the rest can be disabled and enabled with this macros. The problem is solved when I put a 'flushp' instruction after writing the IENABLE register in the '_disable' macro. It seems that on a NiosII/f core, sometimes something goes wrong directly after writing the IENABLE register if the pipeline is not flushed directly. I saw very strange behaviour. For example, NULL pointer exceptions caused by instructions directly after the disabling of interrupts (for detecting NULL pointer exceptions, we generate an interrupt on accessing address 0-7FF). Can anybody explain this strange behaviour? Kind regards, Tim Brugman