speed issue

Technical questions regarding the XTC tools and programming with XMOS.
nisma
Active Member
Posts: 53
Joined: Sun Dec 13, 2009 5:39 pm

speed issue

Post by nisma »

Below there is a copy for little piece of code.
It´s possible that the max speed is 5Mhz on 32bit port or 20Mhz if i divide the code into 4 threads.
On 4/8 bit ports the speed is ok. 16 and 32bit the speed is terrible. Have i made some error, it´s
possible to optimize this better.

Pseudocode:

Code: Select all

		while(1) {
			old=tmp;
            cIn :> tmp;     // 32/16/8/4 bit port.
			tIn :> trigger; //  8bit port using only higher 4bit value
			triggered|=trigger;
			if (old==tmp&&!(++cnt||++cnt1!=0xf))
					continue;
			buff_dat[idx]=tmp; buff_cnt[idx]=cnt; buff[idx++]=cnt1|((trigger>>24)&0xf0);
			if(id>=BUFFER_SIZE) idx=0; 
			if(triggered&&!sampling--) return(id); // sampling done
		}
		
Pseudocode simple:

Code: Select all

	while(!triggered||sampling--) {
			old=tmp;
            cIn :> tmp;     // 32/16/8/4 bit port.
			tIn :> trigger; //  8bit port using only higher 4bit value
			triggered|=trigger;
			if (old==tmp&&++cnt)
					continue;
			buff_dat[idx]=tmp; buff_cnt[idx]=cnt; buff_trg[idx++]=trigger;
			if(id>=BUFFER_SIZE) idx=0;
		}

Pseudocode asm:

Code: Select all

		while(!triggered||sampling--) {
			add triggered #0
			jump if equal #0 label @2
			sub sampling #1 -> sampling
			jump if equal #0 label break
	@2      load port to reg1	-- cIn :> tmp;     // 32/16/8/4 bit port.
			load port to reg2	-- tIn :> trigger; //  8bit port using only higher 4bit value
			math or reg3 <- reg2 - reg3
			xor reg10 reg1 -> reg10
			jump if not equal to #0 label @1
			add reg4 #1
			cmp reg4 #0
			jump if not equal to continue
			xor reg10 reg1 -> reg10
	@1:		store indirect reg10
			store indirect reg4
			store indirect reg2
			add   reg5 #1
			xor   reg5 reg6 -> reg5
			jump if equal #0 continue
			xor   reg5 reg6 -> reg5
			jump continue
		}
Last edited by nisma on Tue Nov 08, 2011 6:56 pm, edited 1 time in total.


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

Post by davelacey »

There may be some stuff you can do here using the XCore port logic. Is cIn a clocked port?
nisma
Active Member
Posts: 53
Joined: Sun Dec 13, 2009 5:39 pm

Post by nisma »

It´s more brainstorming about using the xmos as logic analyzer.
It don´t matter if the port is clocked or not. The port interface surely does it´s job.
But i must read it, save it to memory, increment memory pointer at least.
Running 4 thread, one that read the port, annother that do the compression, a third
that saves the compression and a fourth that check the trigger pattern and shut
down the other threads if the buffer is full. Ideally there should be further a communication
channel to the PC, but that annother story. Using such a approach i came up to 20Mhz max
sample rate or approximate 5mhz using a single 100mhz thread. All not tested, just brainstorming.
Using the same brainstorming, 1,2,4bit works without problem, 8bit is a bit slow and should work
too. 16 and 32 bit seems to be a no-go. I could be wrong with this, or don´t consider somethings,
thats because i have opened the discussion.
User avatar
Ross
XCore Expert
Posts: 967
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Please use the Code tags, makes things a lot easier to read ;) I have modified one snippet in your post as an example.