[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fixed-Point toolbox for octave-forge

From: David Bateman
Subject: Fixed-Point toolbox for octave-forge
Date: Tue, 25 May 2004 17:37:56 +0200
User-agent: Mutt/1.4.1i

Dear All,

I've just committed a fixed-point toolbox for octave to octave-forge.
The toolbox, creates numbers with a known number of bits before and
after the decimal point and then allows arbitrary mathematical
operations on them, taking into account the loss of precision at each
stage. This simulates a real limited complexity implementation of an
algorithm in an ASIC, and can be used to optimize the complexity (i.e
number of bits at each stage, and thus number of logic cells) of an

What it does is create several new user types for fixed point scalar,
complex scalars, matrices and complex matrices, and the corresponding
operators on these types. As this code was first written against 2.1.50
there is no capabilities at this time for NDArray operations with this
code, however I'm not sure this is a problem.

A typical use of the toolbox might be something like

n = 2;
a = rand (n, n);
b = rand (n, n);

## Create fixed-point version with 1 bit before decimal and 5 after.
af = fixed (1, 5, a);
bf = fixed (1, 5, b);

c = myfunc (a, b);
cf = myfunc (af, bf);

function y = myfunc (a, b)
 y = a * b;

where as you can see the underlying function myfunc is unchanged, while
it is called with either floating or fixed point types. The case above is
for fixed-point values with 1-bit before the decimal point and 5 after,
and for me gave a result of 

octave:8> c
c =

  0.98105  0.94436
  0.82622  0.30831

octave:9> cf
cf =

  0.93750  0.90625
  0.78125  0.25000

which clearly shows the loss of precision of a fixed-point algorithm 
with only 6-bits of precision in a matrix multiply. One gotcha in
this toolbox is the use of the concatenation operator "[]" which 
will implicitly reconverts fixed-point values back to floating-point.
This is due to an internal limitation of octave at this moment.
I hope in the future that this limitation will be removed, with a
reimplementation of the concatenation operator within octave itself.

The code can be found in the octave-forge cvs under main/fixed. Full
documentation is available and will be built as postscript and texinfo
during the build of the package.


David Bateman                                address@hidden
Motorola CRM                                 +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 1 69 35 77 01 (Fax) 
91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]