Hardware LTI filters computing just right x F. de Dinechin, x x - - PowerPoint PPT Presentation

hardware lti filters computing just right
SMART_READER_LITE
LIVE PREVIEW

Hardware LTI filters computing just right x F. de Dinechin, x x - - PowerPoint PPT Presentation

Hardware LTI filters computing just right x F. de Dinechin, x x 2+ y 2+ z 2 log x s i x i n x e n Th. Hilaire, e x + i =0 y M. Istoan, A. Volkova Once upon a time in the maths ... there lived a handsome filter named H


slide-1
SLIDE 1

Hardware LTI filters computing just right

  • F. de Dinechin,
  • Th. Hilaire,
  • M. Istoan,
  • A. Volkova

e

x

x2+y2+z2

πx

s i n

e

x+ y n

  • i=0

xi

√x

logx

slide-2
SLIDE 2

Once upon a time in the maths

... there lived a handsome filter named H H u(k) y(k)

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 2

slide-3
SLIDE 3

Once upon a time in the maths

... there lived a handsome filter named H H u(k) y(k) The Matlab fairies had blessed him with the most perfect transfer function: H(z) =

nb

  • i=0

biz−i 1 +

na

  • i=1

aiz−i , ∀z ∈ C. whose coefficients (ai) and (bi) were real numbers so pure they could be computed very accurately in Matlab.

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 2

slide-4
SLIDE 4

And so H converged beautifully

using its evaluation formula y(k) =

nb

  • i=0

biu(k − i) −

na

  • i=1

aiy(k − i) as long as the poles of H remained safely within the unit circle.

u(k) b0 b1 b2 b3

u(k − 1)

+

u(k − 2)

+

u(k − 3)

+ y(k) a1 +

  • y(k − 1)

a2 +

  • y(k − 2)

a3 +

  • y(k − 3)
  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 3

slide-5
SLIDE 5

And so H converged beautifully

using its evaluation formula y(k) =

nb

  • i=0

biu(k − i) −

na

  • i=1

aiy(k − i) as long as the poles of H remained safely within the unit circle.

u(k) b0 b1 b2 b3

u(k − 1)

+

u(k − 2)

+

u(k − 3)

+ y(k) a1 +

  • y(k − 1)

a2 +

  • y(k − 2)

a3 +

  • y(k − 3)

But the fairies had warned H: Don’t let your poles come close to the unit circle!

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 3

slide-6
SLIDE 6

For it was a cruel, fixed-point world out there

Although H had very pure coefficients, he had to serve in the dark underworld of CorteXLab.

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 4

slide-7
SLIDE 7

For it was a cruel, fixed-point world out there

Although H had very pure coefficients, he had to serve in the dark underworld of CorteXLab. There, inputs and outputs were no real numbers, but low-resolution numbers in some ugly binary fixed-point (m, l) format.

s

bit position

  • 8
  • 7
  • 6
  • 5
  • 4
  • 3
  • 2
  • 1

1 2 3 4 5 6 7

bit weight −2m 2m−1 20 2ℓ

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 4

slide-8
SLIDE 8

For it was a cruel, fixed-point world out there

Although H had very pure coefficients, he had to serve in the dark underworld of CorteXLab. There, inputs and outputs were no real numbers, but low-resolution numbers in some ugly binary fixed-point (m, l) format.

s

bit position

  • 8
  • 7
  • 6
  • 5
  • 4
  • 3
  • 2
  • 1

1 2 3 4 5 6 7

bit weight −2m 2m−1 20 2ℓ

For the input, it was OK, for a fixed-point number is also a real number.

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 4

slide-9
SLIDE 9

For it was a cruel, fixed-point world out there

Although H had very pure coefficients, he had to serve in the dark underworld of CorteXLab. There, inputs and outputs were no real numbers, but low-resolution numbers in some ugly binary fixed-point (m, l) format.

s

bit position

  • 8
  • 7
  • 6
  • 5
  • 4
  • 3
  • 2
  • 1

1 2 3 4 5 6 7

bit weight −2m 2m−1 20 2ℓ

For the input, it was OK, for a fixed-point number is also a real number. But H had to round his outputs, and this transformed him into a vile monster with a tilde. H u(k)

  • yout(k)
  • H

u(k)

/ (0, ℓin)

  • yout(k)

/ (mout, ℓout)

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 4

slide-10
SLIDE 10
  • H was a monster, and he diverged

When he rounded his pure coefficients to some fixed-point format,

  • H forgot the fairies’ advice!

u(k) /

(0, ℓin)

  • b0
  • b1
  • b2
  • b3

u(k − 1)

+ —

u(k − 2)

+ —

u(k − 3)

+ — y(k) /

(mout, ℓout)

  • a1

+

y(k − 1)

  • a2

+

y(k − 2)

  • a3

+

y(k − 3)

/ (mout, ℓout)

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 5

slide-11
SLIDE 11
  • H was a monster, and he diverged

When he rounded his pure coefficients to some fixed-point format,

  • H forgot the fairies’ advice!

u(k) /

(0, ℓin)

  • b0
  • b1
  • b2
  • b3

u(k − 1)

+ —

u(k − 2)

+ —

u(k − 3)

+ — y(k) /

(mout, ℓout)

  • a1

+

y(k − 1)

  • a2

+

y(k − 2)

  • a3

+

y(k − 3)

/ (mout, ℓout)

Rounding errors were amplified on the feedback loop, and H diverged miserably.

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 5

slide-12
SLIDE 12
  • H was a monster, and he diverged

When he rounded his pure coefficients to some fixed-point format,

  • H forgot the fairies’ advice!

u(k) /

(0, ℓin)

  • b0
  • b1
  • b2
  • b3

u(k − 1)

+ —

u(k − 2)

+ —

u(k − 3)

+ — y(k) /

(mout, ℓout)

  • a1

+

y(k − 1)

  • a2

+

y(k − 2)

  • a3

+

y(k − 3)

/ (mout, ℓout)

Rounding errors were amplified on the feedback loop, and H diverged miserably. And so Nokia engineers abandonned small and handsome H, preferring a plain 128-tap FIR filter which was bulky, but stable.

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 5

slide-13
SLIDE 13

So H was crying, alone and forgotten

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 6

slide-14
SLIDE 14

So H was crying, alone and forgotten

... when the good old witch FloPoCo heard his complaint. Looking at him, she said: you’re not that evil, you are just poorly specified.

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 6

slide-15
SLIDE 15

So H was crying, alone and forgotten

... when the good old witch FloPoCo heard his complaint. Looking at him, she said: you’re not that evil, you are just poorly specified. And in a whip of her magical TikZ cursor, she designed him a new interface: LTI Filter architecture generator (ai)1≤i<na, (bi)0≤i<nb input format (1, ℓin)

  • utput accuracy ℓout

FPGA frequency .vhdl Functional spec. Performance spec.

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 6

slide-16
SLIDE 16

So H was crying, alone and forgotten

... when the good old witch FloPoCo heard his complaint. Looking at him, she said: you’re not that evil, you are just poorly specified. And in a whip of her magical TikZ cursor, she designed him a new interface: LTI Filter architecture generator (ai)1≤i<na, (bi)0≤i<nb input format (1, ℓin)

  • utput accuracy ℓout

FPGA frequency .vhdl Functional spec. Performance spec. These ai and bi were reals! The very real coefficients! H suddenly felt much lighter than he had ever felt.

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 6

slide-17
SLIDE 17

So H was crying, alone and forgotten

... when the good old witch FloPoCo heard his complaint. Looking at him, she said: you’re not that evil, you are just poorly specified. And in a whip of her magical TikZ cursor, she designed him a new interface: LTI Filter architecture generator (ai)1≤i<na, (bi)0≤i<nb input format (1, ℓin)

  • utput accuracy ℓout

FPGA frequency .vhdl Functional spec. Performance spec. These ai and bi were reals! The very real coefficients! H suddenly felt much lighter than he had ever felt. But... but...

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 6

slide-18
SLIDE 18

But you forgot to provide me a mout, cried H

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 7

slide-19
SLIDE 19

But you forgot to provide me a mout, cried H

No, said FloPoCo, for I have, somewhere in my library, a spell that can compute it out of your coefficients.

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 7

slide-20
SLIDE 20

But you forgot to provide me a mout, cried H

No, said FloPoCo, for I have, somewhere in my library, a spell that can compute it out of your coefficients. (wait a moment, where is it? It was written by poor princess Anastasia Volkova during her captivity in the caves of the mighty sorcerers Lauter and Hilaire...)

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 7

slide-21
SLIDE 21

But you forgot to provide me a mout, cried H

No, said FloPoCo, for I have, somewhere in my library, a spell that can compute it out of your coefficients. (wait a moment, where is it? It was written by poor princess Anastasia Volkova during her captivity in the caves of the mighty sorcerers Lauter and Hilaire...) (I hope it still compiles...)

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 7

slide-22
SLIDE 22

But you forgot to provide me a mout, cried H

No, said FloPoCo, for I have, somewhere in my library, a spell that can compute it out of your coefficients. (wait a moment, where is it? It was written by poor princess Anastasia Volkova during her captivity in the caves of the mighty sorcerers Lauter and Hilaire...) (I hope it still compiles...) Ha, here you go:

Definition: Worst-Case Peak Gain H

  • f a filter H
  • H

= max

||u||∞=1||y||∞

where ||u||∞ is defined as ||u||∞ = max

k |u(k)|.

Then of course, mout = ⌈log2 H ⌉ .

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 7

slide-23
SLIDE 23

But how will this save me from diverging? cried H

Remember: you are H, answered the good witch and H doesn’t diverge in the pure mathematical world

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 8

slide-24
SLIDE 24

But how will this save me from diverging? cried H

Remember: you are H, answered the good witch and H doesn’t diverge in the pure mathematical world Let me cast this spell on your architecture:

  • H shall return a result that is that of H, rounded only once.

Then, your alter ego H won’t diverge. H round

/ (0, ℓin)

u(k) y(k)

/ (mout, ℓout)

  • y(k)
  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 8

slide-25
SLIDE 25

But how will this save me from diverging? cried H

Remember: you are H, answered the good witch and H doesn’t diverge in the pure mathematical world Let me cast this spell on your architecture:

  • H shall return a result that is that of H, rounded only once.

Then, your alter ego H won’t diverge. H round

/ (0, ℓin)

u(k) y(k)

/ (mout, ℓout)

  • y(k)

And FloPoCo invoked his two most crafted gremlins, Istoan and de Dinechin, to code this spell, with the help of Princess Anastasia who had managed to escape her tormentors.

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 8

slide-26
SLIDE 26

Actual architecture

SOPC

u(k) /

(0, ℓin)

b0 b1 b2 b3

u(k − 1)

+

u(k − 2)

+

u(k − 3)

+ final round /

(mout, ℓext)

  • y(k)

/

(mout, ℓout)

  • yout(k)

a1 +

  • y(k − 1)

a2 +

  • y(k − 2)

a3 +

  • y(k − 3)
  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 9

slide-27
SLIDE 27

Actual architecture

SOPC

u(k) /

(0, ℓin)

b0 b1 b2 b3

u(k − 1)

+

u(k − 2)

+

u(k − 3)

+ final round /

(mout, ℓext)

  • y(k)

/

(mout, ℓout)

  • yout(k)

a1 +

  • y(k − 1)

a2 +

  • y(k − 2)

a3 +

  • y(k − 3)

Another point of view: When ℓext → −∞ (which means: as the internal accuracy increase), at some point the computation should become accurate enough for H to converge.

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 9

slide-28
SLIDE 28

Amplification of errors on the feedback loop

Here should come 3 pages of runes which end in the following figure: H u(k) y(k) Hε εr(k) εt(k) +

  • y(k)

+

  • yout(k)

εf(k)

  • H

εr is the sum of all rounding errors εr(k) = y(k) − nb

  • i=0

biu(k − i) −

na

  • i=1

ai y(k − i)

  • Hε is the virtual filter that captures the error amplification on the

feedback loop: εt = Hε εr .

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 10

slide-29
SLIDE 29

Errors are captured, let us chain them in the basement

H u(k) y(k) Hε εr(k) εt(k) +

  • y(k)

+

  • yout(k)

εf(k)

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 11

slide-30
SLIDE 30

Rounding errors depend on the architecture

Example: An architecture optimized for LUT-based FPGAs: Split an input x into D chunks of α bits (e.g. α = 4: hexadecimal). x =

D

  • k=1

2−kαdk where dk ∈ {0, ..., 2α − 1} Then cx becomes cx =

D

  • k=1

2−kαcdk Tabulate each cdk sub-product in an α-input table indexed by dk

  • t1 ≈ cd1

xxxxxxxxxxxxxxxxxxxxxxxxxx...

  • t2 ≈ cd2

xxxxxxxxxxxxxxxxxxxx...

  • t3 ≈ cd3

xxxxxxxxxxxxxx... 2ℓr −g α bits α bits

Remark: c is a real number here, no need to quantize it!

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 12

slide-31
SLIDE 31

A LUT-based architecture

x = b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 T1 : ◦ℓr (c × d1) d1 T2 d2 T3 d3

+

/ qi + g

  • ti1

/ q − α + g

  • t2

/ q − 2α + g

  • t3

/ qi + g

  • pi ≈ cixi

The error is proportional to 2−g, so can made as small as needed by increasing g.

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 13

slide-32
SLIDE 32

Overall architecture

Bit-heap based summation architecture x0 T01 / α T02 / α T03 / α x1 T11 / α T12 / α T13 / α x2 T21 / α T22 / α T23 / α x3 T31 / α T32 / α T33 / α / (mout, ℓext) y

SOPC u(k) / (0, ℓin) b0 b1 b2 b3 u(k − 1) + u(k − 2) + u(k − 3) + final round / (mout, ℓext)

  • y(k)

/

(mout, ℓout)

yout(k) a1 +

  • y(k − 1)

a2 +

  • y(k − 2)

a3 +

  • y(k − 3)
  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 14

slide-33
SLIDE 33

You’re not evil, you’re just poorly specified

LTI Filter architecture generator (ai)1≤i<na, (bi)0≤i<nb input format (1, ℓin)

  • utput accuracy ℓout

FPGA frequency .vhdl Functional spec. Performance spec. ai and bi: real numbers

high-precision numbers from Matlab mathematical formulae such as sin(3*pi/8)

ℓin and ℓout: integers denoting the weight of the least significant bits of the input and of the result. Computing just right (TM): ℓout specifies output precision, but also output accuracy.

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 15

slide-34
SLIDE 34

A demo?

some Butterworth filters a radar filter submitted to Thibault a few years ago

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 16

slide-35
SLIDE 35

Bit heaps for 12-bit Butterworth filters

Order 4, g = 4 Order20, g = 7 because − log2 Hε = 3 because − log2 Hε = 19

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 17

slide-36
SLIDE 36

So everybody lived happily ever after...

A point of view on filter design that is universal

don’t compute useless bits: output format specifies output accuracy complete error analysis (coefficient quantization + architectural rounding errors) error amplification captured by a safe implementation of the WCPG

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 18

slide-37
SLIDE 37

So everybody lived happily ever after...

A point of view on filter design that is universal

don’t compute useless bits: output format specifies output accuracy complete error analysis (coefficient quantization + architectural rounding errors) error amplification captured by a safe implementation of the WCPG

A finely tuned implementation that uses FPGA-specific arithmetic

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 18

slide-38
SLIDE 38

... And they had a lot of children

This is just a basic block on the way to more interesting filter structures. implementation space: state space, SIF clean rule of the game: enables comparison of functionally equivalent architectures (to be continued)

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 19

slide-39
SLIDE 39

The End

Try me in FloPoCo v. 4.1.3 Read more on HAL: Towards Hardware IIR Filters Computing Just Right: Direct Form I Case Study

  • F. de Dinechin, Th. Hilaire, M. Istoan, A. Volkova

Hardware LTI filters computing just right 20