Signed in as:
filler@godaddy.com
Signed in as:
filler@godaddy.com
Arduino setup() and loop() functions are supported. Here is a very simple example:
As in C++, psC control instructions include if, switch, while, do...while, for, break, continue, call and return. Here is a counter:
For added performance, you can take many instructions and execute them parallel in a single step. Instructions can be made parallel by simply by enclosing them in parentheses or braces. Here is an example:
In previous examples, the single-step loop was used to wait for events. Combined with parallel execution, it can be a powerful tool for implementing efficient sequential code. The next example computes the square root; it is a direct implementation of the C++ algorithm. Using parallel assignments and single-step loops makes the code as efficient as hand-coded VHDL code.
Obviously one cannot imagine sequential programming without functions. The psC functions are like C++ functions, except they are declared using the keyword function and called using the keyword call. Execution is as in C++. Functions can also reference arrays (&). Here is an example.