First and most important, sequential psC programming is not meant to replace C++ programming. The objective of sequential psC is to provide a tool to code high-performance short sequences of instructions. While most algorithms can be coded in parallel psC, there are many algorithms, like computing the square root, that are more naturally coded as a sequence of instructions. Here are a few examples illustrating how simple it is to create sequential psC code.
Sequential code may be added to any component simply by adding the sequential keyword to a function declaration. Here is a very simple example:
As in C++, psC control instructions include if, switch, while, do...while, break, continue, call and continue. Here is a sequential version of the Hello Digital World!"counter.
Sequential psC fully integrates into parallel psC. Sequential instructions can access any variables, arrays or ports. In addition, parallel instructions may be embedded into sequential code 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. Use of 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++; here is an example.
Copyright © 2019-22 ICI Techno - All right reserved.
Powered by GoDaddy Website Builder