unsigned long long & memory access exception with xcore-200

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

unsigned long long & memory access exception with xcore-200

Post by Folknology »

I have been getting ET_LOAD_STORE, Memory access exceptions with a project I am working on. This only occurs when I compile for target XCORE-200-EXPLORER and does not do so with my SLICEKIT-U16. I have narrowed it down to the long long arithmetic, when I use simple unsigned arithmetic the problem disappears

This does not work:

Code: Select all

#include "reminder.h"

[[combinable]]
void reminder_driver(server interface reminder_i rmdr[Clients],
											const static unsigned Clients) {

	timer tmr;
	unsigned timeout;
	unsigned long long  ticks = 0ULL;
	unsigned long long  trigger[Clients];

	tmr :> timeout;
	timeout += TICK;

	while(1) {
		select{
			case rmdr[int i].ticks(void) -> unsigned long long count:
				count = ticks;
				break;
			case rmdr[int i].set(unsigned delay):
				trigger[i] = ticks + (unsigned long long)delay;
				break;
			case tmr when timerafter(timeout) :> void:
				ticks++;
				for(unsigned i = 0; i < Clients; i++)
					if(ticks == trigger[i])
						rmdr[i].timeout();
				tmr :> timeout;
				timeout += TICK;
				break;
		}
	}
}
This works:

Code: Select all

#include "reminder.h"

[[combinable]]
void reminder_driver(server interface reminder_i rmdr[Clients],
											const static unsigned Clients) {

	timer tmr;
	unsigned timeout;
	unsigned  ticks = 0ULL;
	unsigned  trigger[Clients];

	tmr :> timeout;
	timeout += TICK;

	while(1) {
		select{
			case rmdr[int i].ticks(void) -> unsigned count:
				count = ticks;
				break;
			case rmdr[int i].set(unsigned delay):
				trigger[i] = ticks + delay;
				break;
			case tmr when timerafter(timeout) :> void:
				ticks++;
				for(unsigned i = 0; i < Clients; i++)
					if(ticks == trigger[i])
						rmdr[i].timeout();
				tmr :> timeout;
				timeout += TICK;
				break;
		}
	}
}
Heres the runtime error generated by the long long version:

Code: Select all

C:\Users\Alan\xmos\mash>xrun --io app_mash\bin\MASH.xe
xrun: Program received signal ET_LOAD_STORE, Memory access exception.
      _Sreminder_driver_0.init.1 (_Sreminder_driver_0.init.1.state_ptr=0x7fd04)
at C:/Users/Alan/xmos/mash/module_reminder/src/reminder.xc:9
      9         unsigned long long  ticks = 0ULL;
If I replace 'unsigned long long ticks = 0ULL;' with 'unsigned long long ticks'; the same error then occurs at 'trigger = ticks + (unsigned long long)delay;'

Any ideas on how to fix this, am I doing something wrong or is this a compiler issue?


User avatar
davelacey
Experienced Member
Posts: 104
Joined: Fri Dec 11, 2009 8:29 pm

Post by davelacey »

This looks like a compiler bug. I've raised an internal ticket on it.

Dave