Data Types

<< Click to Display Table of Contents >>

Navigation:  ETEC 'C' Compiler Information >

Data Types

Previous pageReturn to chapter overviewNext page

Sizes

The eTPU compiler supports int8, int16, int24 and int32. The eTPU is a 24 bit machine and as such it is best at using 24 bit data. Int8 is useful for flags and counts. The compiler will packed an int8 with an int24 to form a single 32 bit parameter.

Int16 and int32 values typically require more code to access and manipulate so generally they should be avoided is possible.  IMPORTANT NOTE: only load/store oprations (i.e. assignment) are supported for the int32 type.  The ETEC compiler will issue and error if the user tries to perform any other kind of operation on 32-bit data; the Byte Craft compiler will silently generate buggy code.

Bit flags

If you need bit flags it is best to implement them as an int8 that gets packed with an int24 for form a 32 bit parameter. When a packed 32 bit value is loaded it is put in the internal P registers of the eTPU. The eTPU has instructions to directly test each of the upper 8 bits in the P register.

Accessing 24 bit data from the host CPU

The eTPU uses 24 bit data but the host processor can only do 32 bit accesses. When the compiler packs an int24 and an int8 into a 32bit parameter RAM how the host access the data without using host code to separate the values?

Accessing the int8 is not a problem because the CPU can just do 8 bit accesses directly to it.

The easiest way to access 24 bit eTPU data is to use the sign extended mirror of the eTPU parameter RAM. The parameter RAM is mapped into the CPU memory map twice, once normally and once sign extended. This allows the host to do a 32 bit read and get a sign extended 24 bit value, making it easier for the host to use the data. This feature can also be used to write 24 bit values into the parameter RAM. When the host does a 32 bit write to the sign extended parameter RAM mirror, only the lower 24 bits are written to the parameter RAM.