• No results found

3. Arithmetic Codes

3.4. ANB-Codes

tectable errors. However, they did only use addition and multiplication. The presented systolic array did not require a division.

3.3.4. Conclusions for AN-Codes

We will not use any of the special AN-codes presented because they provide either less capabilities than common AN-codes or they still require fundamental research before being usable. The latter one is the case for error correcting AN-codes. So far, it was only shown that they exist and under which conditions. However, their implementation – especially the implementation of error correction – was not described. Systematic AN-codes, on the other hand, are difficult to realize because many corrections are required additionally to the executed operation to produce valid code words. Last, |gAN |M codes seemed promissing. Yet, in

contrast to common AN-codes they do not support signed numbers and the division operation.

But we will look into extensions of common AN-codes further because:

• AN-codes are the only arithmetic codes that we know of that support a directly encoded division operation in addition to subtraction, addition, and multiplication.

• They do not facilitate the detection of all error symptoms that we defined in Section 2.5. However, they can be extended to detect these symptoms also (see the following sections 3.4 and 3.5).

3.4. ANB-Codes

To solve the problem of undetectable exchanged operators and operands, Forin in [For89] introduced static signatures (which he referred to as signatures or “B”s). In the resulting ANB-code, the encoding of a variable x is defined as

xc= A ∗ x + Bx with 0 < Bx< A.

If two encoded values are combined for example by adding them, the result’s signature depends on the signatures of the input values. This expected signature for the result is precomputed when the signatures are assigned to the input values of a program, that is, at encoding time.

To check the code of xc, xc’s modulus with A is computed. The result has to

be equal to the assigned or precomputed expected signature Bx of xc. The

functional value x is obtained by an integer division x = xc/A.

ANB-codes support nearly the same operations as AN-codes. However, currently, Supported operations we know no easy solution to encode a division with an ANB-code. Thus, we

either have to emulate it using subtractions executed in a loop or to use the less safe AN-encoded variant.

ANB-encoding operations often requires additional corrections. These corrections ensure that the encoded operation produces a valid code word with a signature

34 CHAPTER 3. ARITHMETIC CODES

that only depends on the signatures of the input values and not on their functional values. For example, the multiplication requires extensive corrections because xc∗ ycdoes not result in the intended A ∗ x ∗ y + Bx∗ By but in A2∗ x ∗ y + A ∗

x ∗ By + A ∗ y ∗ Bx+ Bx∗ By.

ANB-encoding can be realized completely in software and also partly in hardware. Implementation

A complete realization in hardware of course would be possible. However, assigning signatures and precomputing expected signatures is easier to realize in software. Yet, encoded programs could benefit of hardware implementations of encoded operations. These, could reduce the runtime overhead induced by the encoding dramatically.

Like with AN-codes, we have to ensure that ANB-encoded applications solely process encoded data items and preserve the code. The ANB-encoded version of our small example looks as follows:

i n t c f o o c ( i n t c xc , i n t c yc , i n t c z c ) {

i n t c uc = xc + yc ; // uc = A∗ x+Bx + A+y+By = A( x+y)+Bx+By

i n t c vc = uc + z c ; // v c = A( x+y+z )+Bx+By+Bz

return vc ; // e x p e c t e d : v c mod A == Bx+By+Bz

}

When encoding the program represented by foo, we assign static signatures to the input variables x, y, and z. Knowing the program, we can precompute the result’s expected signature Bv = Bx+ By+ Bz. Bv also has to be smaller

than A and larger than zero. This can be ensured by correcting the signatures during program execution. The corrections required are also precomputed at encoding time for static signatures. We add them to the concerned encoded value at runtime in each execution.

Note that for implementing dynamically allocated memory, we introduce dynamic signatures in Chapter 7 and [WF07b]. These are assigned and precomputed at runtime instead of at compile time.

If an error would now exchange the variable yc (that represents the encoded value Error detection

capabilities yc) with another encoded variable uc= A∗u+Bu, the result’s computed signature vcmod A would be (Bx+ Bu+ Bz) instead of the expected (Bx+ By+ Bz).

If the addition were to be replaced erroneously by a subtraction, the resulting computed signature would be (Bx– By+ Bz) instead of (Bx+By+ Bz).

Thus, an ANB-code can detect the following errors: faulty operations, modified operands, exchanged operands, and exchanged operators. Because an ANB-code can detect exchanged operands and operators, we say it detects data and control flow errors.

However, now consider that there is a bitflip on the address bus when storing variable yc. Thus, we have a lost update on yc because yc is stored in a wrong memory location. When reading yc the next time, the old version of yc is read – which is correctly ANB-encoded but outdated. This example shows that ANB-codes might not detect lost updates.

We know of no approach that uses solely ANB-encoding apart from our encoding Systems using

this code compiler that we will present in Chapter 8. This encoding compiler can apply