aric team seminar

Post on 02-Jul-2015

697 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Context and Objectives FiPoGen Bits Formatting Conclusion

Optimal filter implementation in fixed-pointarithmetic

Benoit LopezSeminar ARIC team

December 12th 2013

1/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Outline

1 Context and Objectives

2 FiPoGen

3 Bits Formatting

4 Conclusion

2/41

Context and Objectives FiPoGen Bits Formatting Conclusion

ANR DEFIS

Projet ANR-11-INSE-008

DEsign of FIxed-point embedded Systems (DEFIS)

Various partners :

Research : IRISA, LIRMM (DALI), CEA, LIP6

3/41

Context and Objectives FiPoGen Bits Formatting Conclusion

ANR DEFIS

Projet ANR-11-INSE-008

DEsign of FIxed-point embedded Systems (DEFIS)

Various partners :

Research : IRISA, LIRMM (DALI), CEA, LIP6

3/41

Context and Objectives FiPoGen Bits Formatting Conclusion

ANR DEFIS

Projet ANR-11-INSE-008

DEsign of FIxed-point embedded Systems (DEFIS)

Various partners :

Research : IRISA, LIRMM (DALI), CEA, LIP6

Industrial : Thales, InPixal

3/41

Context and Objectives FiPoGen Bits Formatting Conclusion

On the first hand... A filter

+

z�1

z�1

z�1

z�1

z�1

z�1

b1

b1

b2

b3 a3

a2

a1

x[n] y[n]+

z�1

z�1

z�1

x[n] y[n]b0

b1

b2

b3

+

+

+

+

+

�a3

�a2

�a1

z�1

z�1

z�1

h(z) =

Pni=0 biz�i

1 +Pn

i=1 aiz�i

Signal ProcessingLTI filters: FIR or IIRIts transfer functionAlgorithmic relationship used to compute output(s) frominput(s), for example:

y(k) =nX

i=0

biu(k � i) �nX

i=1

aiy(k � i)

4/41

Context and Objectives FiPoGen Bits Formatting Conclusion

On the other hand... A target

±

. . .

. . .

2��

20

2��2

s ��

Hardware target (FPGA, ASIC) or software target (DSP,µC)

Using fixed-point arithmetic for di↵erent reasons:no FPUcostsizepower consumptionetc.

5/41

Context and Objectives FiPoGen Bits Formatting Conclusion

+

z�1

z�1

z�1

x[n] y[n]b0

b1

b2

b3

+

+

+

+

+

�a3

�a2

�a1

z�1

z�1

z�1

±

. . .

. . .

2��

20

2��2

s ��

Need

Methodology and tools for the implementation of embedded filteralgorithms in fixed-point arithmetic.

A first methodology

1 Given a filter, choose an algorithm

There are many possible realizations

2 Round the coe�cients in fixed-point arithmetic

What word-length? Depends on the choice of algorithm

3 Implement algorithm

Is there only one possible implementation?

6/41

Context and Objectives FiPoGen Bits Formatting Conclusion

+

z�1

z�1

z�1

x[n] y[n]b0

b1

b2

b3

+

+

+

+

+

�a3

�a2

�a1

z�1

z�1

z�1

±

. . .

. . .

2��

20

2��2

s ��

Need

Methodology and tools for the implementation of embedded filteralgorithms in fixed-point arithmetic.

A first methodology

1 Given a filter, choose an algorithm

There are many possible realizations

2 Round the coe�cients in fixed-point arithmetic

What word-length? Depends on the choice of algorithm

3 Implement algorithm

Is there only one possible implementation?

6/41

Context and Objectives FiPoGen Bits Formatting Conclusion

+

z�1

z�1

z�1

x[n] y[n]b0

b1

b2

b3

+

+

+

+

+

�a3

�a2

�a1

z�1

z�1

z�1

±

. . .

. . .

2��

20

2��2

s ��

Need

Methodology and tools for the implementation of embedded filteralgorithms in fixed-point arithmetic.

A first methodology

1 Given a filter, choose an algorithmThere are many possible realizations

2 Round the coe�cients in fixed-point arithmeticWhat word-length? Depends on the choice of algorithm

3 Implement algorithmIs there only one possible implementation?

6/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Fixed-Point Arithmetic

Fixed-Point number

Xm X0 X�1 X`

w

�2m 20 2�12m�1 2`

Representation : X .2` with X = XmXm�1...X0...X`.

Format : determined by wordlength and fixed-point position,and noted for example (m, `).

7/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Fixed-Point Arithmetic

Some FPF examples

p2 with 8 bits : FxP8(

p2) = 90.2�6

0 1 0 1 1 0 1 0 (1, �6)

�21 2�120 2�6

3 � ⇡ with 6 bits : FxP6(3 � ⇡) = �18.2�7

1 0 1 1 1 0 (�2, �7)

�2�2 2�3 2�7

42 with 5 bits : FxP5(42) = 10.22

0 1 0 1 0 (6, 2)

�26 25 22

8/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Fixed-Point Arithmetic

Some FPF examples

p2 with 8 bits : FxP8(

p2) = 90.2�6= 1.40625

0 1 0 1 1 0 1 0 (1, �6)

�21 2�120 2�6

3 � ⇡ with 6 bits : FxP6(3 � ⇡) = �18.2�7= �0.140625

1 0 1 1 1 0 (�2, �7)

�2�2 2�3 2�7

42 with 5 bits : FxP5(42) = 10.22= 40

0 1 0 1 0 (6, 2)

�26 25 22

8/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Fixed-Point Arithmetic

Fixed-Point number

Xm X0 X�1 X`

w

�2m 20 2�12m�1 2`

Representation : X .2` with X = XmXm�1...X0...X`

Format : determined by wordlength and fixed-point position,and noted for example (m, `)

Only the mantissa X is stored, the scale 2` is implicit

9/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Fixed-Point Arithmetic

Sum example

We want to compute 42 +p2 with an 8-bit operator :

0 1 0 1 0 1 0 0 84

0 1 0 1 1 0 1 0 90

s

10/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Fixed-Point Arithmetic

Sum example

We want to compute 42 +p2 with an 8-bit operator :

0 1 0 1 0 1 0 0 84

0 1 0 1 1 0 1 0 2

0 1 0 1 0 1 1 086

FxP8(FxP8(42) + FxP8(p2)) = FxP8(84.2�1 + 90.2�6) =

10/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Fixed-Point Arithmetic

Sum example

We want to compute 42 +p2 with an 8-bit operator :

0 1 0 1 0 1 0 0 84

0 1 0 1 1 0 1 0 2

0 1 0 1 0 1 1 086

FxP8(FxP8(42) + FxP8(p2)) = FxP8(84.2�1 + 90.2�6) =

84.2�1 + (90 � 5).2�1 = 86.2�1 = 43FxP8(42) + FxP8(

p2) = 43.40625

10/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Fixed-Point Arithmetic

Sum example

We want to compute 42 +p2 with an 8-bit operator :

0 1 0 1 0 1 0 0 84

0 1 0 1 1 0 1 0 2

0 1 0 1 0 1 1 086

FxP8(FxP8(42) + FxP8(p2)) = FxP8(84.2�1 + 90.2�6) =

84.2�1 + (90 � 5).2�1 = 86.2�1 = 43FxP8(42) + FxP8(

p2) = 43.40625

10/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Fixed-Point Arithmetic

Fixed-Point number

Xm X0 X�1 X`

w

�2m 20 2�12m�1 2`

Representation : X .2` with X = XmXm�1...X0...X`

Format : determined by wordlength and fixed-point position,and noted for example (m, `)

Only the mantissa X is stored, the scale 2` is implicit

Computation in finite precision implies errors.

Numerical degradations

quantization of the coe�cients

round-o↵ errors in computations

11/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Filter

IIR Filter

Let H be the transfer function of a n � th order IIR filter :

H(z) =b0 + b1z

�1 + · · · + bnz�n

1 + a1z�1 + · · · + anz�n, 8z 2 C. (1)

There is a lot of di↵erent realizations for a filter :

Direct Form I, DF II, ⇢DF II transposed

State-Space realizations, �-operator, LGS, LCW

parallel or cascade decompostion

...

Each realization needs its own parameters and therefore the impactof FxP computation will depend on the realization.

12/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Filter

IIR Filter

Let H be the transfer function of a n � th order IIR filter :

H(z) =b0 + b1z

�1 + · · · + bnz�n

1 + a1z�1 + · · · + anz�n, 8z 2 C. (1)

There is a lot of di↵erent realizations for a filter :

Direct Form I, DF II, ⇢DF II transposed

State-Space realizations, �-operator, LGS, LCW

parallel or cascade decompostion

...

Each realization needs its own parameters and therefore the impactof FxP computation will depend on the realization.

12/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Filter

This filter is usually realized with the following algorithm

y(k) =nX

i=0

biu(k � i) �nX

i=1

aiy(k � i) (2)

where u(k) is the input at step k and y(k) the output at step k .We can see round-o↵ errors as the add of an error e(k) on theoutput and only y †(k) can be computed.

y †(k) =nX

i=0

biu(k � i) �nX

i=1

aiy†(k � i) + e(k). (3)

13/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Filter

+

H

He

u(k)

e(k) �y(k) y†(k)

y(k)

�y(k) , y †(k) � y(k) can be seen as the result of the errorthrough the filter He :

He(z) =1

1 + a1z�1 + · · · + anz�n, 8z 2 C.

If the error e(k) is in [e; e], then we are able to compute �y and

�y such that �y(k) is in [�y ;�y ] :

�y =e + e

2|He |DC � e � e

2kHek`1

�y =e + e

2|He |DC +

e � e

2kHek`1

14/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Filter

+

H

He

u(k)

e(k) �y(k) y†(k)

y(k)

�y(k) , y †(k) � y(k) can be seen as the result of the errorthrough the filter He :

He(z) =1

1 + a1z�1 + · · · + anz�n, 8z 2 C.

If the error e(k) is in [e; e], then we are able to compute �y and

�y such that �y(k) is in [�y ;�y ] :

�y =e + e

2|He |DC � e � e

2kHek`1

�y =e + e

2|He |DC +

e � e

2kHek`1

14/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Objective

Objective:

Given an algorithm and a target, find the optimal implementation.

model the fixed-point algorithms

model the hardware resources (computational units, etc.)

evaluate the degradation

find one/some optimal implemented algorithm(s)

15/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Objective

From filter to code, global flow

SIF Realisationchoice

Fixed-pointimplementation

Codegeneration

filter

code

set of equivalent realisations optimal realisation

language

sensibillity mesures

multi-criteriaoptimisation

fixed-pointalgorithm

algorithm transformation implementation

16/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Objective

From filter to code, global flow

SIF Realisationchoice

Fixed-pointimplementation

Codegeneration

filter

code

set of equivalent realisations optimal realisation

language

sensibillity mesures

multi-criteriaoptimisation

fixed-pointalgorithm

algorithm transformation implementation

17/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Outline

1 Context and Objectives

2 FiPoGen

3 Bits Formatting

4 Conclusion

18/41

Context and Objectives FiPoGen Bits Formatting Conclusion

The only operations needed in filter algorithm computation aresum-of-products:

S =nX

i=1

ci · xi

where ci are known constants and xi variables (inputs, state orintermediate variables).

Question:

How to implement computation of S in fixed-point arithmetic?What control on degradation errors?

Answer:

A tool responding to the global flow in particular case ofsum-of-product (FiPoGen).

19/41

Context and Objectives FiPoGen Bits Formatting Conclusion

The only operations needed in filter algorithm computation aresum-of-products:

S =nX

i=1

ci · xi

where ci are known constants and xi variables (inputs, state orintermediate variables).

Question:

How to implement computation of S in fixed-point arithmetic?What control on degradation errors?

Answer:

A tool responding to the global flow in particular case ofsum-of-product (FiPoGen).

19/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Main example

Let H be the transfer function of a butterworth filter of 4th�order:

H(z) =0.00132801779278 + 0.00531207117112z�1 + 0.00796810675667z�2 + 0.00531207117112z�3 + 0.00132801779278z�4

1 � 2.87111622831650z�1 + 3.20825006629575z�2 � 1.63459488108445z�3 + 0.31870932778967z�4

Associated algorithm:

y(k) = 0.0013279914856 u(k) + 0.00531196594238 u(k � 1) + 0.00796794891357 u(k � 2)

+0.00531196594238 u(k � 3) + 0.0013279914856 u(k � 4) + 2.87109375 y(k � 1)

�3.20825195312 y(k � 2) + 1.63458251953 y(k � 3) � 0.318710327148 y(k � 4)

Inputs datas :

wordlength of constants, u(k) and y(k) : 16 bits

u(k) 2 [�13, 13] and y(k) 2 [�17.123541; 17.123541]Bits formatting example

20/41

Context and Objectives FiPoGen Bits Formatting Conclusion

From filter to code, global flow

SIF Realisationchoice

Fixed-pointimplementation

Codegeneration

filter

code

set of equivalent realisations optimal realisation

language

sensibillity mesures

multi-criteriaoptimisation

fixed-pointalgorithm

algorithm transformation implementation

21/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen - Fixed Point Generator

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

Conversion

The user gives in input to FiPoGen the wordlentgh of eachconstants, and FiPoGen computes the complete format of each ofthem, and specifies the format of each variables.

22/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

Order

In software, addition can be not associative, therefore all di↵erentorders of additions must be considered.

oSoP

An evaluation scheme for a given sum-of-products with a givenorder will be called ordered-sum-of-products (oSoP).

23/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

Order

In software, addition can be not associative, therefore all di↵erentorders of additions must be considered.

oSoP

An evaluation scheme for a given sum-of-products with a givenorder will be called ordered-sum-of-products (oSoP).

23/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

S

+

+

+

+

+

� 16

26781

(1,-14)

y [n � 3]

(5,-10)

� 16

23520

(2,-13)

y [n � 1]

(5,-10)

� 16

-26282

(2,-13)

y [n � 2]

(5,-10)

+

+

� 16

22280

(-9,-24)

u[n]

(4,-11)

� 16

16710

(-6,-21)

u[n � 2]

(4,-11)

� 16

22280

(-7,-22)

u[n � 3]

(4,-11)

� 16

-20887

(-1,-16)

y [n � 4]

(5,-10)

+

� 16

22280

(-9,-24)

u[n � 4]

(4,-11)

� 16

22280

(-7,-22)

u[n � 1]

(4,-11)

23/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

Number of oSoP

For a given sum-of-products of Nth�order, there areQN�1

i=1 (2i � 1)oSoP to consider.

23/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

S

+

+

+

+

� 16

-20887

(-1,-16)

y [n � 4]

(5,-10)

� 16

26781

(1,-14)

y [n � 3]

(5,-10)

� 16

23520

(2,-13)

y [n � 1]

(5,-10)

� 16

-26282

(2,-13)

y [n � 2]

(5,-10)

+

+

+

+

� 16

22280

(-7,-22)

u[n � 3]

(4,-11)

� 16

16710

(-6,-21)

u[n � 2]

(4,-11)

� 16

22280

(-9,-24)

u[n]

(4,-11)

� 16

22280

(-9,-24)

u[n � 4]

(4,-11)

� 16

22280

(-7,-22)

u[n � 1]

(4,-11)

23/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

Number of oSoP

For a given sum-of-products of Nth�order, there areQN�1

i=1 (2i � 1)oSoP to consider.

Generation

At this step, FiPoGen generates all the oSoP one by one.

23/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

Formats propagation

From an oSoP parametrized with inputs FPF and wordlength, andusing some propagation rules on adders and multipliers, we obtaina fully-parametrized oSoP.

24/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

S

+

+

+

+

� 16

-20887

(-1,-16)

y [n � 4]

(5,-10)

(5,-10)

F

� 16

26781

(1,-14)

y [n � 3]

(5,-10)

(7,-8)

(5,-10)

(5,-10)

F

� 16

23520

(2,-13)

y [n � 1]

(5,-10)

(8,-7)

(5,-10)

(5,-10)

F

� 16

-26282

(2,-13)

y [n � 2]

(5,-10)

(8,-7)

(5,-10)

(5,-10)

>> 6

+

>> 1

+

+

� 16

22280

(-7,-22)

u[n � 1]

(4,-11)

(-2,-17

)

� 16

22280

(-7,-22)

u[n � 3]

(4,-11)

(-2,-17)

(-2,-17)

>> 2

+

� 16

22280

(-9,-24)

u[n]

(4,-11)

(-4,-19)

� 16

22280

(-9,-24)

u[n � 4]

(4,-11)

(-4,-19)

(-4,-19)

(-2,-17)

(-2,-17)

(-1,-16)

� 16

16710

(-6,-21)

u[n � 2]

(4,-11)

(-1,-16)

(-1,-16)

(5,-10)

(5,-10)

24/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

Propagation =) right-shifts

By propagating formats, some additions yield a right-shift on itsoperands (for aligning them onto the result format). Thisright-shift implies error onto the final result.

24/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

Right-shift =) error interval

The right shifting of d bits of a variable x (with (m, `) as FPF) isequivalent to add an interval error [e] = [e; e] with

Truncation Round to the nearest

[e, e] [�2`+d + 2`; 0] [�2`+d�1 + 2`; 2`+d�1](4)

Cumulated error is therefore computed for a given evaluationscheme.

24/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

Optimization criteriaerrors

(noise : couple mean/variance)error interval

latency (infinite parallelism)

adequacy with hardware target

etc.

25/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

Optimization criteriaerrors

latency (infinite parallelism)height of the syntax tree

adequacy with hardware target

etc.

25/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

Optimization criteriaerrors

latency (infinite parallelism)

adequacy with hardware targetnumber of operatorswordlength of operatorsetc.

etc.

25/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

Optimization criteriaerrors

latency (infinite parallelism)

adequacy with hardware target

etc.

25/41

Context and Objectives FiPoGen Bits Formatting Conclusion

FiPoGen

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

Once we have the best evaluation scheme, we choose a languageand we generate the associated fixed-point code.

26/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Outline

1 Context and Objectives

2 FiPoGen

3 Bits Formatting

4 Conclusion

27/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

s

s

s

s

s

s

s s

s sf

Context

A sum of N terms (pi )1iN with di↵erent formats, and the knownFPF of final result (sf ), less than total wordlength (s).

Question:

Can we remove some useless bits ?

28/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

s

s

s

s

s

s

s s

s sf

Context

A sum of N terms (pi )1iN with di↵erent formats, and the knownFPF of final result (sf ), less than total wordlength (s).

Question:

Can we remove some useless bits ?

28/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

s

s

s

s

s

s

s s

s sf

Two-step formatting

1 most significant bits

2 least significant bits

28/41

Context and Objectives FiPoGen Bits Formatting Conclusion

MSB formatting

Jacskon’s Rule (1979)

This Rule states that in consecutive additions and/or subtractionsin two’s complement arithmetic, some intermediate results andoperands may overflow. As long as the final result representationcan handle the final result without overflow, then the result is valid.

Example :

We want to compute 104 + 82 � 94 with 8 bits :104 + 82 = �70 overflow !but �70 � 94 = 92 overflow !This second overflow cancels the first one and we obtain theexpected result.

29/41

Context and Objectives FiPoGen Bits Formatting Conclusion

MSB formatting

Jacskon’s Rule (1979)

This Rule states that in consecutive additions and/or subtractionsin two’s complement arithmetic, some intermediate results andoperands may overflow. As long as the final result representationcan handle the final result without overflow, then the result is valid.

Example :

We want to compute 104 + 82 � 94 with 8 bits :

104 + 82 = �70 overflow !but �70 � 94 = 92 overflow !This second overflow cancels the first one and we obtain theexpected result.

29/41

Context and Objectives FiPoGen Bits Formatting Conclusion

MSB formatting

Jacskon’s Rule (1979)

This Rule states that in consecutive additions and/or subtractionsin two’s complement arithmetic, some intermediate results andoperands may overflow. As long as the final result representationcan handle the final result without overflow, then the result is valid.

Example :

We want to compute 104 + 82 � 94 with 8 bits :104 + 82 = �70 overflow !

but �70 � 94 = 92 overflow !This second overflow cancels the first one and we obtain theexpected result.

29/41

Context and Objectives FiPoGen Bits Formatting Conclusion

MSB formatting

Jacskon’s Rule (1979)

This Rule states that in consecutive additions and/or subtractionsin two’s complement arithmetic, some intermediate results andoperands may overflow. As long as the final result representationcan handle the final result without overflow, then the result is valid.

Example :

We want to compute 104 + 82 � 94 with 8 bits :104 + 82 = �70 overflow !but �70 � 94 = 92 overflow !This second overflow cancels the first one and we obtain theexpected result.

29/41

Context and Objectives FiPoGen Bits Formatting Conclusion

MSB formatting

Fixed-Point Jacskon’s Rule

Let s be a sum of n fixed-point number pi s, in format (M, L). If sis known to have a final MSB equals to mf with mf < M, then:

s =mf +1M

1in

0

@mfX

j=L

2jpi ,j

1

A

s

s

s

s

s

s

s s

s sfM Lmf

30/41

Context and Objectives FiPoGen Bits Formatting Conclusion

MSB formatting

Fixed-Point Jacskon’s Rule

Let s be a sum of n fixed-point number pi s, in format (M, L). If sis known to have a final MSB equals to mf with mf < M, then:

s =mf +1M

1in

0

@mfX

j=L

2jpi ,j

1

A

s

s

s

s

s

s

s s s s

s sfM Lmf

30/41

Context and Objectives FiPoGen Bits Formatting Conclusion

LSB formatting

LSB Formatting main idea (from Florent de Dinechin)

s

s

s

s

s

s

s s

s sf

31/41

Context and Objectives FiPoGen Bits Formatting Conclusion

LSB formatting

LSB Formatting main idea (from Florent de Dinechin)

s

s

s

s

s

s

s s 0

s sf

31/41

Context and Objectives FiPoGen Bits Formatting Conclusion

LSB formatting

LSB Formatting main idea (from Florent de Dinechin)

s

s

s

s

s

s

s s 0

s s 0f

31/41

Context and Objectives FiPoGen Bits Formatting Conclusion

LSB formatting

LSB Formatting main idea (from Florent de Dinechin)

s

s

s

s

s

s

s s 0

s s 0f

s 0f 6= sf BUT s 0f is a faithful round-o↵ of sf .

31/41

Context and Objectives FiPoGen Bits Formatting Conclusion

LSB formatting

LSB Formatting main idea (from Florent de Dinechin)

s

s

s

s

s

s

�s s�

s s 0f

Can we determine a minimal � such that s 0f is always a faithfulround-o↵ of sf ?

31/41

Context and Objectives FiPoGen Bits Formatting Conclusion

LSB formatting

� evaluation

For both rounding mode (round-to-nearest or truncation), thesmallest integer � that provides s 0f = ?lf (sf ) is given by:

� = dlog2(n)e

More precisely

Some pi s may have LSB (`i ) greater than the final LSB `f , so wedon’t need to consider them in � computation :

� = dlog2(nf )e

with nf = Card(If ) and If , {i | `i < `f }.

32/41

Context and Objectives FiPoGen Bits Formatting Conclusion

LSB formatting

� evaluation

For both rounding mode (round-to-nearest or truncation), thesmallest integer � that provides s 0f = ?lf (sf ) is given by:

� = dlog2(n)e

More precisely

Some pi s may have LSB (`i ) greater than the final LSB `f , so wedon’t need to consider them in � computation :

� = dlog2(nf )e

with nf = Card(If ) and If , {i | `i < `f }.

32/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Formatting method

s

s

s

s

s

s

s s

s sf

1 we compute �

2 we format all pi s into FPF (mf , lf � �)

3 we compute s�4 we obtain s 0f from s�

33/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Formatting method

s

s

s

s

s

s

�s s�

s s 0f

1 we compute �

2 we format all pi s into FPF (mf , lf � �)

3 we compute s�4 we obtain s 0f from s�

33/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Back to our main example

Main example

s

s

s

s

s

s

s

s

s

s

s

34/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Back to our main example

Main example

s

s

s

s

s

s

s

s

s

s

s

� = dlog2(n)e

All the di↵erent oSoP have the same errors=) Here, error is not a criteria to choose the best oSoP

34/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

oSoP

S

>> 4

+

+

+

+

F

� 9

23520

(2,-13)

y [n � 1]

(5,-10)

(8,-14)

(5,-14)

F

� 9

-26282

(2,-13)

y [n � 2]

(5,-10)

(8,-14)

(5,-14)

(5,-14)

F

� 21

22280

(-9,-24)

u[n]

(4,-11)

(-4,-14)

(5,-14)

(5,-14)

+

F

� 19

22280

(-7,-22)

u[n � 3]

(4,-11)

(-2,-14)

(5,-14)

� 12

-20887

(-1,-16)

y [n � 4]

(5,-10)

(5,-14)

(5,-14)

(5,-14)

+

+

+

F

� 21

22280

(-9,-24)

u[n � 4]

(4,-11)

(-4,-14)

(5,-14)

F

� 10

26781

(1,-14)

y [n � 3]

(5,-10)

(7,-14)

(5,-14)

(5,-14)

F

� 18

16710

(-6,-21)

u[n � 2]

(4,-11)

(-1,-14)

(5,-14)

(5,-14)

F

� 19

22280

(-7,-22)

u[n � 1]

(4,-11)

(-2,-14)

(5,-14)

(5,-14)

(5,-14)

(5,-10)

35/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Comparison

sss

ssss

ss

ss

�2 = 0 �3 = dlog2(nf )e �1 = mini(`i )

36/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Comparison

Fix3

Fix2

Fix1

k

�y(k)

�y 2 [�y ;�y ] = [�8.52445240 ⇥ 10�2; 1.26555189 ⇥ 10�2]36/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Formatting

This new task can be inserted in FiPoGen process.

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

37/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Formatting

This new task can be inserted in FiPoGen process.

Fixed-PointConversion

Evaluationscheme

Formats propagation /

Noiseevaluation

Optimization / Best scheme

choiceCode

generation

sum-of-productrealisation

code

"lighter" fixed-pointalgorithm

one evaluationscheme

fully-parametrized

schemebest fixed-point

scheme

new scheme

Formatting

fixed-point algorithm

37/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Word-length optimization

It is a main current problem in fixed-point arithmetic. It consists ofminimizing the word-length of each parameter under constraints.

38/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Word-length optimization

It is a main current problem in fixed-point arithmetic. It consists ofminimizing the word-length of each parameter under constraints.

The idea, for a sum-of-products s =P

i ci ⇥ vi , is to :

define the cost function to minimize

define the constraints on the error by considering formatting

solve the problem using known solvers or find a new solution

min (ws +P

i wci +P

i wvi )

38/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Word-length optimization

It is a main current problem in fixed-point arithmetic. It consists ofminimizing the word-length of each parameter under constraints.

The idea, for a sum-of-products s =P

i ci ⇥ vi , is to :

define the cost function to minimize

define the constraints on the error by considering formatting

solve the problem using known solvers or find a new solution

`s � � � `ci + `vi

ws � wci � wvi � ms � mci � mvi � � � 1

38/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Word-length optimization

It is a main current problem in fixed-point arithmetic. It consists ofminimizing the word-length of each parameter under constraints.

The idea, for a sum-of-products s =P

i ci ⇥ vi , is to :

define the cost function to minimize

define the constraints on the error by considering formatting

solve the problem using known solvers or find a new solution

`s � � � `ci + `viws � wci � wvi � ms � mci � mvi � � � 1

38/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Word-length optimization

It is a main current problem in fixed-point arithmetic. It consists ofminimizing the word-length of each parameter under constraints.

The idea, for a sum-of-products s =P

i ci ⇥ vi , is to :

define the cost function to minimize

define the constraints on the error by considering formatting

solve the problem using known solvers or find a new solution

�y(k) 2 [�y ;�y ]

�y and �y are functions of e and e which are functions of ws , wci

and wvi .

38/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Word-length optimization

It is a main current problem in fixed-point arithmetic. It consists ofminimizing the word-length of each parameter under constraints.

The idea, for a sum-of-products s =P

i ci ⇥ vi , is to :

define the cost function to minimize

define the constraints on the error by considering formatting

solve the problem using known solvers or find a new solution

�y(k) 2 [�y ;�y ]

�y and �y are functions of e and e which are functions of ws , wci

and wvi .

38/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Formatting

Word-length optimization

It is a main current problem in fixed-point arithmetic. It consists ofminimizing the word-length of each parameter under constraints.

The idea, for a sum-of-products s =P

i ci ⇥ vi , is to :

define the cost function to minimize

define the constraints on the error by considering formatting

solve the problem using known solvers or find a new solution

38/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Conclusion

This PhD thesis answers the problem of optimal filterimplementation in fixed-point arithmetic.

For this, some works have been realized:

Formalisms : for conversion and basic operations infixed-point arithmetic

FiPoGen : a tool generating fixed-point code for awell-fashioned algorithm

Bits formatting : a first step towards word-length optimization

39/41

Context and Objectives FiPoGen Bits Formatting Conclusion

Second part of the PhD thesis

A lot of works still to be done:

Wordlength optimization considering bits formatting

Make FiPoGen realizes the complete flow defined before

Do the link with Silviu’s works

40/41

Context and Objectives FiPoGen Bits Formatting Conclusion

THANK YOUAny questions?

41/41

top related