rp181 wrote:I'le be honest, I have no idea what your talking about. I have never worked with binary numbers directly nor bitwise shifting (ile look into it more).
When you say:
Code: Select all
Double_nibble = ((Byte1>>4)<<4) + (Byte2 >>4);
Does this mean you combine 2 4-bit values (byte1, byte2) to get the resultant bit (8 bits?), and then take 4 of these and store it?
What is the LSRI instruction?
What exactly does "masking" do, and which is preferable?
What is "disasm"? Does this just mean extracting the original values form the combined result?
You can read about all the instructions in this manual:
http://www.xmos.com/system/files/xs1_en.pdf , use search in the pdf and it will help you find it.
The manual shows all available instruction.
To check what the C compiler translate the code to, you have the tool in the XDE to check the result.
Check out
http://en.wikipedia.org/wiki/Disassembler thats the disasm
As you earlier said, it's about rounding: In MATLAB on a PC or another hi level tool we could have written
round(Byte1/256) to reduce the value to 4 bit's. Doing that operation would have taking many operations to calculate on any machine.
In this embedded world we need to think about doing things fast. Instead of dividing something with 2^n, we shift the bits by n steps. (The rounding mode will be similar to round to - Infinity)
To make thing even faster we try to use the Immediate instruction when possible.
Compare ADD and ADDI for an example in the xs1_en.pdf
XMOS have even more tricks. It's possible to read an port and manipulate data in the same instruction.
Check out the XS1 Hardware routines (xs1.h)
{Your local disk}\XMOS\DesktopTools\10.4\doc\libs\html\index.html
Check out:
void set_port_shift_count (void port p, unsigned n)
Sets the shift count for a port.
unsigned
partin (void port p, unsigned n)
Performs an input of the specified width on a buffered port.
void
partout (void port p, unsigned n, unsigned val)
Performs an output of the specified width on a buffered port.
Is it a 8 bit parallel communication line from the camera ? Do you have a clock available e.g. sync. communication ?
I do not have the overview here, but the smart way is maybe to change to a 4 bit port (Just in XC) for the most significant bits instead of using a 8 bit port. Use port doublebuffering to collect 8 pieces of 4 bit's data without using any instruction during the time.
PS. You will probably find out during the road that you will have to rewrite parts of you code to make it X times more efficient. Regarding reading/writing to ports there is many tricks to collect 32bit´s of data without bothering the CPU. DS.