6.8. Language Constraints for Hardware Processes
Impulse C is compatible with standard ANSI C and allows you to take full advantage of C language (and third-party C libraries) for describing the software elements of your application. For those
No Support for Hardware Function Calls
Impulse C processes are intended to be created at compile time and exist statically (as persistent objects) at runtime. As such, it is not
Integer Math OperationsFor integer datatypes, the standard C arithmetic operations +, -, *, ++ are supported as single-cycle operations. Division using the / operation results in a multicycle implementation requiring one cycle for each bit in the result. The algorithm is designed to be low in area and delay, with the goal of reducing the overall system fMax . Shift OperationsShift operations are limited to constant values for the shift operand. For example, the following loop:
iFlags = 0;
for(i = 0; i < 8; i++)
{
if(afCubeVal[i] <= FTARGETVALUE)
iFlags = 1 << i; // Not supported in hardware compilation
}
should be rewritten as:
iFlags = 0;
bit = 1;
for(i = 0; i < 8; i++)
{
if(afCubeVal[i] <= FTARGETVALUE)
iFlags = bit;
bit = bit << 1;
}
Support for Datatypes Is LimitedAs of this writing there is no support in the Impulse C compiler for complex datatypes such as structs and unions, although support for these datatypes is expected in a later release of the compiler. Floating-point types are also not supported at this writing. Limited Support for PointersThe use of pointers to reference array data in your Impulse C hardware processes is supported, but with some major limitations. Fundamentally, all uses of pointers must be resolvable at compile time to static references to specific memory locations. Therefore, pointer support in Impulse C hardware processes is limited to the following situations:
Also, pointers may not point to more than one array. The following, however, is allowed: p = &(a[2]); ... p = &(a[3]); The second assignment in the following is not okay: p = &(a[2]); // This is OK … p = &(b[3]); // This is not OK. Can't re-use the pointer for b Using Pointers with Multidimensional Arrays
Rather than using nested
p = &(a[0][0]);
for (i=0; i<4*5; i++) {
... // Access the array elements using p
p++;
}
|