XC Programming Language
Encyclopedia
The XC Programming Language is a computer programming language developed by XMOS
.
XC is an imperative programming language with a computational framework based on C. XC programs consist of functions that execute statements that act upon values stored in variables. Control-flow statements express decisions, and looping statements express iteration.
The language was designed to exploit the XMOS processor architecture
, but is a general-purpose language and implementations for other architectures are in construction. Running XC on other platforms is currently supported by highly-optimised interpretation of the XMOS instruction set.
The language permits explicit parallelism, as well as parallel replication.
Concurrent processes can communicate using channels.
Edsger Dijkstra
's guarded commands also feature.
More unconventionally, the language includes the use of ports - which can be used to directly control hardware pins from high-level software.
- a process algebra developed by Tony Hoare, and therefore includes explicit parallelism and channel communication. Edsger Dijkstra
can also claim an influence with the inclusion of guarded commands
.
Because of its relations to CSP, the framework for modelling from CSP can be used to reason about XC programs.
As a result the language bears semantic (though not structural) similarities to languages such as occam. This is not surprising as one of the chief XC language designers was David May
who also created occam.
XMOS
XMOS is a fabless semiconductor company that develops multi-core multi-threaded processors designed to execute several real-time tasks, DSP, and control flow all at once.-Company history:...
.
XC is an imperative programming language with a computational framework based on C. XC programs consist of functions that execute statements that act upon values stored in variables. Control-flow statements express decisions, and looping statements express iteration.
The language was designed to exploit the XMOS processor architecture
XCore XS1
The XCore XS1 is a 32-bit RISC microprocessor architecture designed by XMOS. The architecture is designed to be used for embedded systems, and instruction encoding is compact using 16 bits for frequently used instructions and 32 bits for less frequently used instructions .Almost all instructions...
, but is a general-purpose language and implementations for other architectures are in construction. Running XC on other platforms is currently supported by highly-optimised interpretation of the XMOS instruction set.
New features
One of the most unusual features of XC is the inclusion of timers and ports in a high-level programming language. One of the great historical weaknesses of high-level programming languages - particularly those based on formal theoretical frameworks such as process calculi or those based on functional programming - is the inability to combine clean high-level constructs with efficient and safe input-output.Introduction
The following is the XC source for the Hello World program.
- include < stdio .h >
main ( void ) {
printf ( " Hello , world !\ n " );
}
The language permits explicit parallelism, as well as parallel replication.
- include < platform .h >
on stdcore [0] : out port tx = XS1_PORT_1A ;
on stdcore [0] : in port rx = XS1_PORT_1B ;
on stdcore [1] : out port lcdData = XS1_PORT_32A ;
on stdcore [2] : in port keys = XS1_PORT_8B ;
int main ( void ) {
par {
on stdcore [0] : uartTX ( tx );
on stdcore [0] : uartRX ( rx );
on stdcore [1] : lcdDrive ( lcdData );
on stdcore [2] : kbListen ( keys );
}
}
Concurrent processes can communicate using channels.
- include < platform .h >
on stdcore [0] : out port tx = XS1_PORT_1A ;
on stdcore [1] : in port keys = XS1_PORT_8B ;
void uartTX ( chanend dataIn , port tx ) {
char data ;
while (1) {
dataIn :> data ;
transmitByte ( tx , data );
}
}
void kbListen ( chanend c , port keys ) {
char data ;
while (1) {
data = waitForKeyStroke ( keys );
c <: data ;
}
}
int main ( void ) {
chan c ;
par {
on stdcore [0] : uartTX (c , tx ); // Thread X
on stdcore [1] : kbListen (c , keys ); // Thread Y
}
}
Edsger Dijkstra
Edsger Dijkstra
Edsger Wybe Dijkstra ; ) was a Dutch computer scientist. He received the 1972 Turing Award for fundamental contributions to developing programming languages, and was the Schlumberger Centennial Chair of Computer Sciences at The University of Texas at Austin from 1984 until 2000.Shortly before his...
's guarded commands also feature.
More unconventionally, the language includes the use of ports - which can be used to directly control hardware pins from high-level software.
- include < xs1 .h >
out port p = XS1_PORT_1A ;
int main ( void ) {
p <: 1;
p <: 0;
}
Historical influences
The language design was heavily influenced by Communicating Sequential ProcessesCommunicating sequential processes
In computer science, Communicating Sequential Processes is a formal language for describing patterns of interaction in concurrent systems. It is a member of the family of mathematical theories of concurrency known as process algebras, or process calculi...
- a process algebra developed by Tony Hoare, and therefore includes explicit parallelism and channel communication. Edsger Dijkstra
Edsger Dijkstra
Edsger Wybe Dijkstra ; ) was a Dutch computer scientist. He received the 1972 Turing Award for fundamental contributions to developing programming languages, and was the Schlumberger Centennial Chair of Computer Sciences at The University of Texas at Austin from 1984 until 2000.Shortly before his...
can also claim an influence with the inclusion of guarded commands
Guarded Command Language
The Guarded Command Language is a language defined by Edsger Dijkstra for predicate transformer semantics. It combines programming concepts in a compact way, before the program is written in some practical programming language...
.
Because of its relations to CSP, the framework for modelling from CSP can be used to reason about XC programs.
As a result the language bears semantic (though not structural) similarities to languages such as occam. This is not surprising as one of the chief XC language designers was David May
David May (computer scientist)
Michael David May, born February 24, 1951, is a British computer scientist. He is Professor of Computer Science at the University of Bristol and founder and Chief Technology Officer of XMOS Semiconductor.May was lead architect for the transputer...
who also created occam.