SBAM - SPM Bit Accurate Modelling


Inner Product

Compute inner product of the following 3 element vectors:

Standard double Implementation

using c++ double type results in c = -0.399771

Double Implementation

Using the recommended workflow the first step is to use the Double type provided by SBAM. To do this, lines 2, 3 & 4 are altered so that arrays of Double are created. Note these alterations are simply changing variable declarations. The body of the simulation (lines 5-7) remain unchanged.

When this program runs it also computes c = -0.399771. This is as expected since Double is simply a wrapper around double.

FloatingPoint Implementation

The next step is to use the SBAM FloatingPoint type and investigate the effects of reducing the precision. To this end there are two additional lines defining the number of mantissa bits and exponent bits, and once again the type declarations are change. As before the main simulation code remain unchanged.

With this configuration the result is c = -0.406250.

Fixed Point Implementation

Changing from floating point to fixed point involves altering the variable declarations. Lines 2 & 3 have been changed to define the number of integer bits and fractional bits.

When this program runs it computes c = -0.437500. Note that it would have been possible to use a typedef to make this process simpler, this technique was not used in these examples for the sake of clarity.

Maintained by Alan Murray
University of Newcastle
23 Sep 2009, © Copyright