Checking eTPU_C generated code

eTPU_C | |

Byte Craft's eTPU customers generally use several different tools in their eTPU toolchain. The eTPU has a microcoded instruction set that may display the disassembly of the eTPU's instruction in several ways. The following example came from a conversation with a customer about instruction display formats of various tools that support the eTPU.

Byte Craft chose to display the instructions in the listing file as a functional representation of the instructions. In the following example an add with one side of the alu complimented and incremented is displayed as a subtract in our listings which is both functionally correct and a more compact representation.

Here's a good example:

0200 3BF14FB4   alu diob = c ,ccs.          if (x < y)
0204 3874FFF4   alu nil = d - diob ,ccs.           {
0208 F080109F   if c==0 jump 0210,flush.         

The instruction at location 0x204 is an alu operation, supposedly a subtract, intended to change the carry flag and nothing more. This performs the less-than compare operation. Let's see if that's how the eTPU interprets it.

Using the constant bits, we learn that instruction word 0x3874fff4 is a B6/1G format instruction, commonly used in ALU operations. The last 5 bits are the ALUOP subinstruction field, and a quick check in the Block Guide shows that pattern 10100 is an addition subinstruction. Not quite what the disassembly says.

The secret is in two other fields.

  • BINV is set to 0, causing the ALU's B source (DIOB) to be bitwise inverted.
  • CIN is set to 0, causing a carry-in of 1 to the addition.

Performing A + /B + 1 (carry-in) gives the result of A - B source. This is the intended subtraction.

Congratulations if you had the Block Guide close at hand to verify this. We build eTPU_C straight from the specifications, in close consultation with the eTPU designers. We're still sure that a C compiler is the best way to create programs for the eTPU.

These are all the fields in a B6/1G instruction:


Field Value Description
constant bits 0011 B6/1G instruction format
CCSV 10 Sample ALU flags
CIN 0 Carry in is 1
BINV 0 Invert B source
T4BBS 011 B source is DIOB 23:0
rsv 1
T4ABS 0100 A source is D 23:0
T2ABD 1111 No destination
SRC 1 No shift
SEXT 1 No A source sign extend
AS/CE 111 No size override
ABSE 1 A source first register set
ABDE 1 A destination first register set
ALUOP 10100 A source + B source

Note: remember that a 1 (or all ones) is often a "nop" value in eTPU subinstruction fields.