Jump to content

XCore Architecture

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Henk.muller (talk | contribs) at 09:58, 1 June 2009 (Created page with 'The '''XS1''' instruction set is designed to be used for embedded processors and uses a mixture of 16/32 bit instructions. It uses one, two, and [[Instructi…'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

The XS1 instruction set is designed to be used for embedded processors and uses a mixture of 16/32 bit instructions. It uses one, two, and three-operand instructions based on a set of 12 general purpose registers[1]. Three operands can be identified using no more than 11 bits, enabling a large set of frequently used 3-operand instructions to be encoded in 16 bits. The instruction set includes operations to create threads, communicate between threads, and execute operations on resources Less frequently used instructions are encoded in 32 bits.

Description

The instruction set comprises both a (more or less standard) sequential programming model, and instructions that implement multi-threading, multi-core, and I/O operations.

Sequential programming model

Each thread has access to 12 general purpose registers R0...R11. In addition there are 4 special purpose registers the SP, LR (Link register - stores the return address), CP (constant pool, points to a part of memory that stores constants) and DP (data pool - points to global variables). In addition to those 16 there are another 9 registers that store the PC, kernel PC, Exception type, Exception data, and saved copies of all those in case of an exception or interrupt. The instruction set is a load-store instruction set.

All instructions execute in a single cycle. If an instruction does not need data from memory (for example, arithmetic operations), the instruction will prefetch a word of instructions. Because most instructions are encoded in 16-bits, and because most instructions are not loads or stores (a typical number is 20% loads stores, 80% other instructions[2]), the prefetch mechanism can stay ahead of the instructions stream. This acts like a very small instruction cache, but its behaviour can be predicted at compile time, making timing behaviour as predictable as functional behaviour.

Instructions that access memory all use a base register: SP, DP, CP, PC or any general purpose register. In a single 16-bit instruction a thread can access:

  • Up to 64 words relative to the stack pointer (read or write, word access only)
  • Up to 64 words relative to the data pointer (read or write, word access only)
  • Up to 64 words relative to the constant pointer (read only, word access only)
  • Up to 12 words relative to any general purpose register (read and write, word access only)
  • An indexed word using any two general purpose registers
  • An indexed 16-bit quantity using any two general purpose registers
  • An indexed byte using any two general purpose registers

Larger sections of memory can be accessed by means of extended instructions, which extend the above ranges to 64 KBytes.

This scheme is designed in order densely encode the common cases found in many programming patterns: access to small stack frames, a small set of globals and constants, structures, and arrays. Access to bit fields that have an odd length is facilitated by means of sign and zero extend instructions.

All common arithmetic instructions are provided - including a divide and remainder (which are the only instructions that are not single cycle). Comparison instructions compute a truth value (0 or 1) into a register, avoiding the use of flags (insert reference to other processors here). Many instructions have immediate version that allow a single operand with a value of between 0 and 11 inclusive, encoding many common cases such as "i = i + 1". In the case of bit operations such as shift, the immediate value encodes common cases. Extra instructions are provided for reversing bits and bytes, count leading zeros, digital signal processing, and long integer arithmetic.

The branch instructions include conditional and unconditional relative branches. A branch using the address in a register is provided; a relative branch which adds a scaled register operand to the program counter is provided to support jump tables. Branches to up to instructions distance are encoded in a single word. The procedure calling instructions include relative calls, calls via the constant pool, indexed calls via a dedicated register and calls via a register. Most calls within a single program module can be encoded in a single instruction; inter-module calling requires at most two instructions. It is up to the callee to save the link-register if it is not a leaf-function, a single instruction extends the stack and saves the link register.

Parallel Programming Model

The XCore was specifically designed to support both multi threading and multi-core computations. To this extent it supports channel communication (to support distributed memory computations) and barriers and locks (to support shared memory computations). A thread initiates execution on one or more newly allocated threads by setting their initial register values.

Communication between threads is performed using channels that provide full-duplex data transfer between channel-ends. This enables, amongst others, the implementation of CSP based languages, languages based on the Pi calculus. Channels can be connected inside a xcore, between xcores on a chip, or xcores on different chips, using an XSwitch. Channels carry messages constructed from data and control tokens between the two channel ends. The control tokens are used to encode communication protocols.

Channel ends have a buffer able to hold sufficient tokens to allow at least one word to be buffered. If an output instruction is executed when the channel is too full to take the data then the thread which executed the instruction is paused. It is restarted when there is enough room in the channel for the instruction to successfully complete. Likewise, when an input instruction is executed and there is not enough data available then the thread is paused and will be restarted when enough data becomes available.

A thread can, with a single instruction, synchronise with a group of threads using a barrier synchronisation. Alternatively a thread can synchronise using a lock, providing mutual exclusion. In order to communicate data when using barriers and locks, threads can either write data into the registers of another thread, or they can access memory of another thread (provided both threads execute on the same core). If shared memory is used, then the compiler or the programmer must ensure that there are no race conditions.

I/O and timing instructions

The XCore is an event driven processor that can use events rather than interrupts to dispatch external events. This means that the processor has to expect an event and wait in a specific place so that it can be handled synchronously. If desired, I/O can be handled asynchronously using interrupts. Events and interrupts can be used for external input, timers, and channel communication.

References

  1. ^ "XMOS XS1 Instruction Set Architecture" (PDF). XMOS web site. Retrieved 2009-01-19.
  2. ^ Processor Architecture. Springer. 1999. ISBN 3540647988. {{cite book}}: Unknown parameter |coauthors= ignored (|author= suggested) (help)