QUANTIZE DATA

Quantize the coefficients of the PWAG function

Contents

Private method of pwag object.

Description

This function converts all coefficients of the PWAG function in fixed point representation and provides in output all the needed information. The quantization procedure is explained below with a simple example.

The operations which must be performed in the circuit are either an edge evaluation:

h1 x1 + h2 x2 + k (1)

or a function computation:

y = f1 x1 + f2 x2 + g (2)

All terms h1, h2, k, f1, f2, g must be converted in fixed point representation with nbit_coeff bits, while for x1 and x2 nbit bits are used. All coefficients h1, h2, f1, f2, k, g are stored in matrices H, F, K and G.

Data are represented in two's complement coding, therefore, with nbit_coeff bits it is possible to represent values between

-2^(nbit_coeff-1) and 2^(nbit_coeff-1)-1 (3).

The first thing to do is to center the values of G around the origin, by introducing an offset GG. Expression (2) becomes therefore

y = f1 x1 + f2 x2 + g - GG (4)

Secondly F and G are multiplied by a scaling factor alpha such that they completely cover range (3) (i.e. either the maximum or the minimum value in F and G coicides with a boundary of the range. (4) is then transformed in

y = alpha (f1 x1 + f2 x2 + g - GG) (5)

When evaluating (1), only the sign is of interest, so it is possible to scale each inequality in a different way in order to cover range (3), without changing the result of the operation.

From now on, H, K, F and G denote the scaled matrices.

The minimum and maximum values of f1, h1 are now retrieved, in order to decide how many bits of integer part are necessary to represent all them. The same is done for h2, f2 and k, g. Each component of the computation is therefore represented with a possibly different number of decimal bits (dhf1, dhf2 and dkg).

In order to have integer numbers, h1 and f1 are all multiplied by 2^dhf1, h2 and f2 by 2^dhf2. Moreover k and g must be multiplied by 2^dkg. In order to make computation coherent x1 must be multiplied by 2^dkg/2^dhf1 and x2 must be multiplied by 2^dkg/2^dhf2.

Syntax

[Hint Kint Fint Gint A alpha beta nint nintcoeff ndecout] = ... quantizeData(H,K,F,G,D,nbit,nbitcoeff)

H,K,F,G are the coefficient matrices D is the domain nbit the number of bits to be used to represent inputs nbitcoeff the number of bits to be used to represent coefficients Hint, Kint, Fint, Gint are the quantized matrices A is the scaling factor for the input xcir = A x alpha and beta are the scaling factor for the output f = alpha fcir + beta nint and nintcoeff are the bits coding the integer part of inputs and coefficients ndecout is the number of bits to code the decimal part of the output

Acknowledgements

% Copyright is with the following author(s):

(C) 2012 Alberto Oliveri, University of Genoa, Italy, alberto.oliveri@unige.it