Buffered port bit order

Technical discussions around xCORE processors (e.g. xcore-200 & xcore.ai).
Post Reply
SpacedCowboy
Experienced Member
Posts: 67
Joined: Fri Aug 24, 2012 9:37 pm
Contact:

Buffered port bit order

Post by SpacedCowboy »

Is there any way to specify the bit-ordering of a buffered port ? I just wanted to check before I start writing code that uses lookup tables to re-order bits if that's unnecessary...

What I'm seeing on the logic analyzer is (for example) an MSB-first signal reading 0xFF.DB.6A.00, but what I get on the buffered port is 0x00.56.DB.FF. If you bit-reverse the 32-bit word, these match.

At first it was hard to see because (for some reason) a lot of the data I'm reading seems to be nibble-symmetric, so it looked as though 6A was just being read as 56 and I was getting the wrong endian-type of data, but in fact the only byte not bit-symmetric there is 56 (01010110), being read as 6A (01101010). 0xDB is 11011011, which reads the same no matter which end you start. Obviously 0xFF and 0x00 do as well...

So I can do an 8-bit lookup table, and a bit of shifting/masking to fix it, but was wondering if there was some sort of option to set which would prevent the need ?

Cheers
Simon


User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Post by mon2 »

Hi Simon. Will the bitrev() function work for your case ?

See here for some examples on how to use this function:

http://www.xcore.com/forum/viewtopic.ph ... lit=bitrev

https://www.xmos.com/search/content?term=bitrev%28%29

Update
=====

From XS1 Ports document:
https://www.xmos.com/download/public/XS ... 1373A).pdf

Bits are shifted in and out starting with the least significant bit. When you need to
start with the most significant bit you can use a single cycle bit-reverse operation
(BITREV) that can be called by invoking the bitrev() function.
SpacedCowboy
Experienced Member
Posts: 67
Joined: Fri Aug 24, 2012 9:37 pm
Contact:

Post by SpacedCowboy »

Thank you, that was really useful :)

bitrev does exactly what I want, and in less space and less time than using an 8-bit lookup table.

Cheers
Simon
Post Reply