Talk:XCore Architecture

Latest comment: 12 years ago by Chris Chittleborough in topic Encoding three numbers from 0 to 11

Encoding three numbers from 0 to 11 edit

Some readers will be curious, as I was, about how XMOS encode three numbers from 0 to 11 inclusive (eg., general purpose register numbers) in 16-bit instructions. Note that 12×12×12 = 1728 = 2**10.75, so you need 11 bits.

Let x, y, and z be the numbers being encoded, all ≥ 0 and ≤ 11.

  • Use 5 bits to hold (x/4)×9 + (y/4)×3 + (z/4)
    which can never exceed 2×9+2×3+2=26
  • Use 2 bits to hold (x & 0x3)
  • Use 2 bits to hold (y & 0x3)
  • Use 2 bits to hold (z & 0x3)

(I guess the 5-bit field is small enough to decode directly into (x/4), (y/4) and (z/4), without using any division or modulo operations.)

This allows XMOS to use values 26-31 in that 5 bit field for other purposes. Neat, hey? CWC 07:01, 8 January 2012 (UTC)Reply