Section 4.5. Impulse C Signed and Unsigned Datatypes

4.5. Impulse C Signed and Unsigned Datatypes

Impulse C provides predefined unsigned and signed integer datatypes for selected bit lengths ranging from 1 to 64, as shown in the following examples:

co_int1 1-bit integer type

co_int7 7-bit signed integer type

co_uint16 16-bit unsigned type

co_uint24 24-bit unsigned type

co_int32 32-bit signed type

co_uint64 64-bit unsigned type

A simple convention is used to name these predefined types. Signed types have the name co_int followed by the bit length, while unsigned types have the name co_uint followed by the bit length. Variables of these types may be used in an Impulse C program for either software or hardware processes. A stream may have one of these C integer types as its data element type.

During desktop simulation, types whose widths do not match one of the standard C types (for example, a 24-bit integer) are modeled using the next largest integer type. This can result in differences in bit-accurate behavior between the desktop simulation environment and a hardware implementation. To prevent such differences and ensure bit-accurate modeling, you may choose to use the bit-accurate arithmetic macro operations defined in the Impulse C library. Here are some examples of these macro operations:

UADD4(a,b) Unsigned 4-bit addition

ISUB7(a,b) Signed 7-bit subtraction

UMUL24(a,b) Unsigned 24-bit multiplication

UDIV28(a,b) Unsigned 28-bit division

Note that the bit-accurate macro operations are specified in terms of their return value bit width, and there is no enforcement or checking of bit widths of the operands.

    Practical FPGA Programming in C
    Practical FPGA Programming in C
    ISBN: 0131543180
    EAN: 2147483647
    Year: 2005
    Pages: 208

    Similar book on Amazon © 2008-2017.
    If you may any questions please contact us: