DevEX - reference for building teams, processes, and platforms
From controller to code
1. From controller/filter to code:
the optimal implementation problem
Thibault Hilaire (thibault.hilaire@lip6.fr)
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 1/72
2. Context Linear filters and equivalent realizations
1 Context and
problematics
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 2/72
3. Context Linear filters and equivalent realizations
Outline
1 Context
2 Linear filters and equivalent realizations
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 3/72
7. Context Linear filters and equivalent realizations
Context
0
01
01
11
11
0 10 0
00 01
1 01
10 11
10 11
110 010
10 00
00 10
1
01 10
10
01
0 01
01
implantation
Implementation
implantation
Filters/Controllers
algorithmes TS Cibles
Targets
Algorithms
algorithmes TS Cibles
• Finite precision implementation (fixed-point arithmetic)
• LTI systems
• hardware (FPGA, ASIC) or software (DSP, µC)
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 4/72
8. Context Linear filters and equivalent realizations
Context
0
01
01
11
11
0 10 0
00 01
1 01
10 11
10 11
110 010
10 00
00 10
1
01 10
10
01
0 01
01
implantation
Implementation
implantation
Filters/Controllers
algorithmes TS Cibles
Targets
Algorithms
algorithmes TS Cibles
• Finite precision implementation (fixed-point arithmetic)
• LTI systems
• hardware (FPGA, ASIC) or software (DSP, µC)
Methodology for the implementation of embedded algorithms
(controllers/filters)
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 4/72
9. Context Linear filters and equivalent realizations
Implementation under constraints
Embedded systems suffer from various constraints:
• Cost (short Time to Market, rapid renewal, etc...)
• Power consumption (energy-autonomous systems)
• Resources (Limited computing resources (no FPU))
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 5/72
10. Context Linear filters and equivalent realizations
Implementation under constraints
Embedded systems suffer from various constraints:
• Cost (short Time to Market, rapid renewal, etc...)
• Power consumption (energy-autonomous systems)
• Resources (Limited computing resources (no FPU))
The implementation of a given algorithm is difficult:
• Deal with precision problems
• Implementation ⇒ accuracy problems
• Fixed-point arithmetic
• Area/power consumption constraints
• multiple wordlength paradigm (ASIC and FPGA)
• Time-consuming work
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 5/72
11. Context Linear filters and equivalent realizations
Implementation under constraints
Embedded systems suffer from various constraints:
• Cost (short Time to Market, rapid renewal, etc...)
• Power consumption (energy-autonomous systems)
• Resources (Limited computing resources (no FPU))
The implementation of a given algorithm is difficult:
• Deal with precision problems
• Implementation ⇒ accuracy problems
• Fixed-point arithmetic
• Area/power consumption constraints
• multiple wordlength paradigm (ASIC and FPGA)
• Time-consuming work
We need tools to transform controller into code that deal with
precision/performance/computational cost tradeoff
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 5/72
12. Context Linear filters and equivalent realizations
Objectives
The objectives of the presentation is to give an overview of:
• the interest and the difficulties of this problem
• the parts already (almost) done
• the various parts in-progress
• some analogies with the optimal polynomial implementation
problem
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 6/72
13. Context Linear filters and equivalent realizations
Finite precision degradations
The implementation ⇒ degradations (performances, characteristics, etc.)
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 7/72
14. Context Linear filters and equivalent realizations
Finite precision degradations
The implementation ⇒ degradations (performances, characteristics, etc.)
Origins of the degradations
Two sources of deteriorations are considered:
• Roundoff errors into the computations
→ roundoff noise
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 7/72
15. Context Linear filters and equivalent realizations
Finite precision degradations
The implementation ⇒ degradations (performances, characteristics, etc.)
Origins of the degradations
Two sources of deteriorations are considered:
• Roundoff errors into the computations
→ roundoff noise
• Quantization of the coefficients
→ parametric errors
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 7/72
16. Context Linear filters and equivalent realizations
Finite precision degradations
The implementation ⇒ degradations (performances, characteristics, etc.)
Origins of the degradations
Two sources of deteriorations are considered:
• Roundoff errors into the computations
→ roundoff noise
• Quantization of the coefficients
→ parametric errors
The degradations depends on
• the algorithmic relationship used to compute output(s) from
input(s)
• the computations themselves (wordlengths, roundoff mode,
binary point position, additions order, etc.)
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 7/72
17. Context Linear filters and equivalent realizations
Linear filters
LTI: Linear system with known and constant coefficients
• FIR (Finite Impulse Response) :
n n
−i
H(z) = bi z , ⇒ y (k) = bi u(k − i)
i=0 i=0
• IIR (Infinite Impulse Response) :
n −i n n
i=0 bi z
H(z) = n −i
, ⇒ y (k) = bi u(k−i)− ai y (k−i)
1+ i=1 ai z i=0 i=1
Filters and signal processing
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 8/72
18. Context Linear filters and equivalent realizations
Equivalent realizations
For a given LTI controller, it exist various equivalent realizations
• Direct Form I (2n + 1 coefs)
u(k) u(k − 1) u(k − n)
q −1 q −1 q −1 q −1
b0 b1 b2 bi bn
n −i
i=0 bi z
H(z) = n −i
1+ i=1 ai z + y(k)
n n
y (k) = bi u(k−i)− ai y (k−i) −an −ai −a2 −a1
i =0 i =1
q −1 q −1 q −1 q −1
y(k − n) y(k − 1)
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 9/72
19. Context Linear filters and equivalent realizations
Equivalent realizations
For a given LTI controller, it exist various equivalent realizations
• Direct Form I (2n + 1 coefs)
• Direct Form II (transposed or not) (2n + 1 coefs)
u(k) e(k) y(k)
+ b0 +
q −1
e(k − 1)
+ −a1 b1 +
q −1
+ −a2 b2 +
q −1
+ −ai bi +
q −1
−an bn
e(k − n)
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 9/72
20. Context Linear filters and equivalent realizations
Equivalent realizations
For a given LTI controller, it exist various equivalent realizations
• Direct Form I (2n + 1 coefs)
• Direct Form II (transposed or not) (2n + 1 coefs)
• State-space (depend on the basis) ((n + 1)2 coefs)
X (k + 1) = AX (k) + Bu(k)
y (k) = CX (k) + Du(k)
A
X (k) → T .X (k) U (k) Y (k)
B + q −1 C +
X(k + 1) X(k)
D
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 9/72
21. Context Linear filters and equivalent realizations
Equivalent realizations
For a given LTI controller, it exist various equivalent realizations
• Direct Form I (2n + 1 coefs)
• Direct Form II (transposed or not) (2n + 1 coefs)
• State-space (depend on the basis) ((n + 1)2 coefs)
• δ-operator δ q−1 ∆
Aδ
U (k) Y (k)
∆ + q −1
Bδ + δ −1 Cδ +
X(k + 1) X(k)
δ −1
Dδ
δ[X (k)] = Aδ X (k) + Bδ u(k)
y (k) = Cδ X (k) + Dδ u(k)
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 9/72
22. Context Linear filters and equivalent realizations
Equivalent realizations
For a given LTI controller, it exist various equivalent realizations
• Direct Form I (2n + 1 coefs)
• Direct Form II (transposed or not) (2n + 1 coefs)
• State-space (depend on the basis) ((n + 1)2 coefs)
• δ-operator δ q−1 ∆
• Cascad and/or parallel decompositions
H1
H2
+
H1 H2 Hi Hm Hi
H
Hm
H
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 9/72
23. Context Linear filters and equivalent realizations
Equivalent realizations
For a given LTI controller, it exist various equivalent realizations
• Direct Form I (2n + 1 coefs)
• Direct Form II (transposed or not) (2n + 1 coefs)
• State-space (depend on the basis) ((n + 1)2 coefs)
• δ-operator δ q−1 ∆
• Cascad and/or parallel decompositions
• ρDirect Form II transposed (5n + 1 ou 4n + 1 coefs) ρDFIIt
u(k)
βn βn−1 βi β1 β0
+ z −1 ∆i
ρ−1 ρ−1 ρ−1 ρ−1
+
+
+
+
+
n i+1 i 1
γi −1
ρi
αn αn−1 αi α1
y(k)
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 9/72
24. Context Linear filters and equivalent realizations
Equivalent realizations
For a given LTI controller, it exist various equivalent realizations
• Direct Form I (2n + 1 coefs)
• Direct Form II (transposed or not) (2n + 1 coefs)
• State-space (depend on the basis) ((n + 1)2 coefs)
• δ-operator δ q−1 ∆
• Cascad and/or parallel decompositions
• ρDirect Form II transposed (5n + 1 ou 4n + 1 coefs) ρDFIIt
• lattice, ρ-modale, LGC et LCW-structures, sparse state-space,
etc.
Each of these realizations uses different coefficients.
They are equivalent in infinite precision, but no more in finite
precision. The finite precision degradation (parametric errors and
roundoff noises) depends on the realization.
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 9/72
25. Context Linear filters and equivalent realizations
Comparison with polynomials – 1
It is very interesting to compare filter realizations and polynomial
evaluation:
z −1
• The shift operator • The multiplication by x
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 10/72
26. Context Linear filters and equivalent realizations
Comparison with polynomials – 1
It is very interesting to compare filter realizations and polynomial
evaluation:
z −1
• The shift operator • The multiplication by x
• Direct forms • Horner’s method
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 10/72
27. Context Linear filters and equivalent realizations
Comparison with polynomials – 1
It is very interesting to compare filter realizations and polynomial
evaluation:
z −1
• The shift operator • The multiplication by x
• Direct forms • Horner’s method
• ρ-operator • Newton’s basis
n
z − γj Pi = Πik=1 (X − xk )
i (z) =
∆j
j=i+1
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 10/72
28. Context Linear filters and equivalent realizations
Comparison with polynomials – 1
It is very interesting to compare filter realizations and polynomial
evaluation:
z −1
• The shift operator • The multiplication by x
• Direct forms • Horner’s method
• ρ-operator • Newton’s basis
n
z − γj Pi = Πik=1 (X − xk )
i (z) =
∆j
j=i+1
• ρDFIIt • Horner’s method with Newton’s
basis
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 10/72
29. Context Linear filters and equivalent realizations
Comparison with polynomials – 2
X (k + 1) = AX (k) + Bu(k)
• State-space
y (k) = C X (k) + Du(k)
X0 = 1 0 ... 0
x
1 0
• Xi +1 =
.. .. Xi
. .
1 0
P = an an−1 . . . a0 Xn
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 11/72
30. Context Linear filters and equivalent realizations
Comparison with polynomials – 2
X (k + 1) = T −1 AT X (k) + T −1 Bu(k)
• State-space
y (k) = C T X (k) + Du(k)
X0 = 1 0 ... 0
x
1 0
• Xi +1 = T −1
.. .. T Xi
. .
1 0
P = an an−1 . . . a0 T Xn
• Basis change with any T invertible
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 11/72
31. Context Linear filters and equivalent realizations
Comparison with polynomials – 2
X (k + 1) = T −1 AT X (k) + T −1 Bu(k)
• State-space
y (k) = C T X (k) + Du(k)
X0 = 1 0 ... 0
x
1 0
• Xi +1 = T −1
.. .. T Xi
. .
1 0
P = an an−1 . . . a0 T Xn
• Basis change with any T invertible
Could it be interesting to consider other polynomial evaluation
schemes (Estrin, Knuth&Eve, etc.) ?
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 11/72
32. Context Linear filters and equivalent realizations
HW or SW implementation
In addition to the choice of the realization, a lot of other options:
• Fixed-point evaluation schemes
• order of the operations
• fixed-point alignments
• quantization modes, etc.
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 12/72
33. Context Linear filters and equivalent realizations
HW or SW implementation
In addition to the choice of the realization, a lot of other options:
• Fixed-point evaluation schemes
• order of the operations
• fixed-point alignments
• quantization modes, etc.
• Software implementation (µC, DSP, etc.):
• Parallelization
• Ressource allocations
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 12/72
34. Context Linear filters and equivalent realizations
HW or SW implementation
In addition to the choice of the realization, a lot of other options:
• Fixed-point evaluation schemes
• order of the operations
• fixed-point alignments
• quantization modes, etc.
• Software implementation (µC, DSP, etc.):
• Parallelization
• Ressource allocations
• Hardware implementation (FPGA, ASIC)
• Multiple word-length paradigm
• Operators optimizations (multiplications by constant, etc.)
• Hardware-oriented arithmetic
• Operators regroupment
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 12/72
35. Context Linear filters and equivalent realizations
HW or SW implementation
In addition to the choice of the realization, a lot of other options:
• Fixed-point evaluation schemes
• order of the operations
• fixed-point alignments
• quantization modes, etc.
• Software implementation (µC, DSP, etc.):
• Parallelization
• Ressource allocations
• Hardware implementation (FPGA, ASIC)
• Multiple word-length paradigm
• Operators optimizations (multiplications by constant, etc.)
• Hardware-oriented arithmetic
• Operators regroupment
Different levels of optimizations !
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 12/72
36. Objectives SIF Criteria Evaluation scheme Methodology
2 Our approach
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 13/72
37. Objectives SIF Criteria Evaluation scheme Methodology
Outline
3 Objectives
4 SIF
5 Criteria
6 Evaluation scheme
7 Methodology
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 14/72
38. Objectives SIF Criteria Evaluation scheme Methodology
Objectives
Given a controller and a target, find the optimal implementation.
• Model all the equivalent realizations
• SIF (Specialized Implicit Form)
• Model the fixed-point algorithms
• depends on evaluation schemes for sum-of-products
• Model the hardware resources
• computational units, etc.
• Evaluate the degradation
• Find one/some optimal realizations
Tradeoff between:
• Performance / Accuracy (multi-criteria)
• Computational cost
• Area, power consumption
• Computation time, reusability, off-line efforts, etc.
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 15/72
39. Objectives SIF Criteria Evaluation scheme Methodology
From controller to code
transfer function, state-space, etc.
structure SIF
set of equivalent realizations
T , ∆, γ, ... realization
choice
Z
abstract syntax tree
roundoff modes
word-length implementation ...
arithmetic operators
fixed-point algorithm (Z*, ...)
code
langage
generation
code
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 16/72
40. Objectives SIF Criteria Evaluation scheme Methodology
A Unifying Framework Realizations
We have shown that it was possible to describe all these realizations
in a descriptor framework called Specialized Implicit Form (SIF).
• Macroscopic description of the computations
• More general than state-space
• Explicit all the operations and their linking
J 0 0 T (k + 1) 0 M N T (k)
−K I 0 X (k + 1) = 0 P Q X (k)
−L 0 I Y (k) 0 R S U(k)
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 17/72
41. Objectives SIF Criteria Evaluation scheme Methodology
A Unifying Framework Realizations
We have shown that it was possible to describe all these realizations
in a descriptor framework called Specialized Implicit Form (SIF).
• Macroscopic description of the computations
• More general than state-space
• Explicit all the operations and their linking
J 0 0 T (k + 1) 0 M N T (k)
−K I 0 X (k + 1) = 0 P Q X (k)
−L 0 I Y (k) 0 R S U(k)
→ it is able to represent all the graph flows with delay, additions
and constant multiplications
SIF
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 17/72
42. Objectives SIF Criteria Evaluation scheme Methodology
A Unifying Framework Realizations
We have shown that it was possible to describe all these realizations
in a descriptor framework called Specialized Implicit Form (SIF).
• Macroscopic description of the computations
• More general than state-space
• Explicit all the operations and their linking
J 0 0 T (k + 1) 0 M N T (k)
−K I 0 X (k + 1) = 0 P Q X (k)
−L 0 I Y (k) 0 R S U(k)
We denote Z the matrix containing all the
−J M N
coefficients (and the structure of the K P Q
Z
realization)
L R S
SIF
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 17/72
43. Objectives SIF Criteria Evaluation scheme Methodology
Different criteria
We have three kinds of criteria to evaluate the finite-precision
degradation:
• Performance:
• transfer function error H − H †
• poles or zeros errors |λ| − |λ† |
• weighted errors
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 18/72
44. Objectives SIF Criteria Evaluation scheme Methodology
Different criteria
We have three kinds of criteria to evaluate the finite-precision
degradation:
• Performance:
• transfer function error H − H †
• poles or zeros errors |λ| − |λ† |
• weighted errors
• Accuracy:
• Signal to Quantization Noise Ratio
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 18/72
45. Objectives SIF Criteria Evaluation scheme Methodology
Different criteria
We have three kinds of criteria to evaluate the finite-precision
degradation:
• Performance:
• transfer function error H − H †
• poles or zeros errors |λ| − |λ† |
• weighted errors
• Accuracy:
• Signal to Quantization Noise Ratio
• Computational cost:
• number of coefficients, number of operations
• area, power consumption (FPGA, ASIC)
• WCET
• complexity, etc.
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 18/72
46. Objectives SIF Criteria Evaluation scheme Methodology
Different criteria
We have three kinds of criteria to evaluate the finite-precision
degradation:
• Performance:
• transfer function error H − H †
• poles or zeros errors |λ| − |λ† |
• weighted errors
• Accuracy:
• Signal to Quantization Noise Ratio
• Computational cost:
• number of coefficients, number of operations
• area, power consumption (FPGA, ASIC)
• WCET
• complexity, etc.
→ These criteria require to know the exact implementation.
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 18/72
47. Objectives SIF Criteria Evaluation scheme Methodology
Different criteria
We have three kinds of criteria to evaluate the finite-precision
degradation:
• Performance:
• transfer function error H − H †
• poles or zeros errors |λ| − |λ† |
• weighted errors
• Accuracy:
• Signal to Quantization Noise Ratio
• Computational cost:
• number of coefficients, number of operations
• area, power consumption (FPGA, ASIC)
• WCET
• complexity, etc.
→ These criteria require to know the exact implementation.
So we extend them in a priori criteria (that do not depend on
implementation) and a posteriori criteria.
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 18/72
48. Objectives SIF Criteria Evaluation scheme Methodology
a priori criteria – 1 a priori
measures
These criteria come from control:
a priori measures
• sensitivity with respect to the coefficients Z
• transfer function sensitivity : ∂H
∂Z
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 19/72
49. Objectives SIF Criteria Evaluation scheme Methodology
a priori criteria – 1 a priori
measures
These criteria come from control:
a priori measures
• sensitivity with respect to the coefficients Z
• transfer function sensitivity : ∂H
∂Z
• poles or zeros sensitivity : ∂|λk |
∂Z
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 19/72
50. Objectives SIF Criteria Evaluation scheme Methodology
a priori criteria – 1 a priori
measures
These criteria come from control:
a priori measures
• sensitivity with respect to the coefficients Z
• transfer function sensitivity : ∂H
∂Z
• poles or zeros sensitivity : ∂|λk |
∂Z
• Roundoff Noise Gain
we suppose here that each quantization error leads to the addition of a
white independent uniform noise
→ Gain from these noises to the output
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 19/72
51. Objectives SIF Criteria Evaluation scheme Methodology
a priori criteria – 2 a priori
measures
The idea is to approximate how much the transfer function is
modified by the coefficients’ quantization.
Denote
0 if Zi,j could be exactly implemented ∈ {2p |p ∈ Z}
(δZ )i,j =
1 else
Then, the transfer function error is approached by the L2 -sensitivity
measure
L2 -sensitivity measure
2
∂H
ML2 = × δZ
∂Z 2
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 20/72
52. Objectives SIF Criteria Evaluation scheme Methodology
a priori criteria – 3 a priori
measures
In a same way, the pole error is approached by a pole-sensitivity
measured.
pole-sensitivity
n 2
∂ |λk |
Ψ ωk × δZ
∂Z F
k=1
where λk are the poles, and ωk some wieghting parameters (usually
1
ωk = 1−|λ | )
k
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 21/72
53. Objectives SIF Criteria Evaluation scheme Methodology
a priori criteria – 3 a priori
measures
In a same way, the pole error is approached by a pole-sensitivity
measured.
pole-sensitivity
n 2
∂ |λk |
Ψ ωk × δZ
∂Z F
k=1
where λk are the poles, and ωk some wieghting parameters (usually
1
ωk = 1−|λ | )
k
→In closed-loop, Ψ is related to the distance to instability.
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 21/72
54. Objectives SIF Criteria Evaluation scheme Methodology
a priori criteria – 3 a priori
measures
In a same way, the pole error is approached by a pole-sensitivity
measured.
pole-sensitivity
n 2
∂ |λk |
Ψ ωk × δZ
∂Z F
k=1
where λk are the poles, and ωk some wieghting parameters (usually
1
ωk = 1−|λ | )
k
→In closed-loop, Ψ is related to the distance to instability.
These measures have been developed for the SIF:
• MIMO case
• open and closed-loop cases
• analytical expressions
2
And extended with more accurate fixed-point considerations σδH
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 21/72
55. Objectives SIF Criteria Evaluation scheme Methodology
a posteriori measure a posteriori
measures
The main measure based on exact implementation is the Signal to
Quantization Noise Ratio SQNR :
a posteriori measure
It measures the noise on the output produced by the implementation
• bit-accurate measure
• depends on HW/SW
• wordlength
• evaluation scheme (order, roundoff mode, etc.)
• an optimization on the word-length can be done
→ For that purpose, we need to generate bit-accurate fixed-point
algorithms
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 22/72
56. Objectives SIF Criteria Evaluation scheme Methodology
Sum-of-products evaluation scheme – 1 fixed-point
evaluation
schemes
The only operations needed are sum-of-products:
n
S= ci · xi
i=1
where ci are known constants and xi variables (inputs, state or
intermediate variables).
We have developed technics to transform real sum-of-products into
fixed-point algorithms:
• we consider the Πn (2i − 1) possible ordered-sum-of-products
i=1
(assuming the fixed-point addition is commutative but not associative)
• given the various word-lengths (operators, constants), we
propagate fixed-point rules among the abstract syntax tree
• we consider various scheme (RBM/RAM, no-shifts, etc.)
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 23/72
57. Objectives SIF Criteria Evaluation scheme Methodology
Sum-of-products evaluation scheme – 2 fixed-point
evaluation
schemes
S = 1.524·X0 +4.89765·X1 −42.3246·X2 +58.35498·X3 +2.857·X4 −49.3246·X5 +24.3468·X6
• 8-bit coefficients, 16-bit additions
• Q6.2 for xi and s
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 24/72
58. Objectives SIF Criteria Evaluation scheme Methodology
Sujet de la Th`se
e Travaux r´alis´s jusqu’ici
e e
Sum-of-products evaluation scheme – 2
Ordered Sum of Products fixed-point
evaluation
schemes
S = 1.524·X0 +4.89765·Xe−42.3246·X2 +58.35498·X3 +2.857·X4 −49.3246·X5 +24.3468·X6
On fixe ici les repr´sentations virgule fixe :
1
8 bits sign´s pour les coefficients
e
• 8-bit coefficients, 16-bit additions
Q6, 2 pour les Xi et S.
• Q6.2 for xi and s
S
+
+ +
>> 4 + × >> 1
+ ×
+ × 117 X3
>> 1 × 97
>> 3 × X6
-99 X5
×
91 X4 ×
-85 X2
98 X0 78 X1
Roundoff After Multiplication
Roundoff After Multiplication
→The roundoff noise is then deduced
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 24/72
59. Objectives SIF Criteria Evaluation scheme Methodology
Sujet de la Th`se
e Travaux r´alis´s jusqu’ici
e e
Ordered Sum of Products
Sum-of-products evaluation scheme – 2 fixed-point
evaluation
schemes
S On fixe 0 +4.89765·X1 −42.3246·X2 +58.35498·X3 +2.857·X4 −49.3246·X5 +24.3468·X6
= 1.524·X ici les repr´sentations virgule fixe :
e
8 bits sign´s pour les coefficients
e
• 8-bit coefficients, 16-bit additions
Q6, 2 pour les Xi et S.
• Q6.2 for xi and s
S
+
+ +
>> 4 + × ×
+ >> 1
+ × 117 X3 X6
× × 97
× × -99 X5
>> 1 91
X0 X4 >> 3
X1 -85 X2
98
78
Roundoff Before Multiplication
Roundoff Before Multiplication
→The roundoff noise is then deduced
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 24/72
60. Objectives SIF Criteria Evaluation scheme Methodology
State-space example
0.58399 −0.42019 0.64635
X (k + 1) = X (k) +
0.42019 0.1638 −0.23982
Y (k) = 0.64635 0.23982 X (k) + 0.13111U(k)
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 25/72
61. Objectives SIF Criteria Evaluation scheme Methodology
State-space example
0.58399 −0.42019 0.64635
X (k + 1) = X (k) +
0.42019 0.1638 −0.23982
Y (k) = 0.64635 0.23982 X (k) + 0.13111U(k)
16-bit input, output, states
16-bit coefficients
32-bit accumulators
max
U = 10
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 25/72
63. Objectives SIF Criteria Evaluation scheme Methodology
realization
Optimal realization optimization
A 1st possible optimization concerns the realization
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 26/72
64. Objectives SIF Criteria Evaluation scheme Methodology
realization
Optimal realization optimization
A 1st possible optimization concerns the realization
Let H be a given controller, we denote RH the set of equivalent
realizations (with H as transfer function).
2
Let J be an a priori criterion (sensibility, RNG, σ∆H , ...).
The optimal realization problem
The optimal realization problem consists in finding a realization
that minimizes J
Ropt = arg min J (R)
R∈RH
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 26/72
65. Objectives SIF Criteria Evaluation scheme Methodology
realization
Optimal realization optimization
A 1st possible optimization concerns the realization
Let H be a given controller, we denote RH the set of equivalent
realizations (with H as transfer function).
2
Let J be an a priori criterion (sensibility, RNG, σ∆H , ...).
The optimal realization problem
The optimal realization problem consists in finding a realization
that minimizes J
Ropt = arg min J (R)
R∈RH
RH is too large, so pratically we only considered structured
realizations (state-space, ρ-forms, etc.)
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 26/72
66. Objectives SIF Criteria Evaluation scheme Methodology
Example – 1
We consider the following transfer function:
38252z 3 − 101878z 2 + 91135z − 27230
H:z →
z 4 − 2.3166z 3 + 2.1662z 2 − 0.96455z + 0.17565
¯
• Closed-loop L2 -sensitivity ML2
¯
• Closed-loop pole-sensitivity : Ψ
¯
• Roundoff Noise Gain (RNG) : G
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 27/72
67. Objectives SIF Criteria Evaluation scheme Methodology
Example – 2
¯W
ML2 ¯
Ψ ¯
G ¯
TO Nb. op.
Z1 1.9046e+7 3.3562e+7 1.186e+6 7 + 8×
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 28/72
68. Objectives SIF Criteria Evaluation scheme Methodology
Example – 2
¯W
ML2 ¯
Ψ ¯
G ¯
TO Nb. op.
Z1 1.9046e+7 3.3562e+7 1.186e+6 3.6764e+8 7 + 8×
Z2 3.6427e+5 6.5007e+5 3.6582e+2 19 + 24×
Z1 : canonical form
Z2 : balanced state-space
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 28/72
69. Objectives SIF Criteria Evaluation scheme Methodology
Example – 2
¯W
ML2 ¯
Ψ ¯
G ¯
TO Nb. op.
Z1 1.9046e+7 3.3562e+7 1.186e+6 3.6764e+8 7 + 8×
Z2 3.6427e+5 6.5007e+5 3.6582e+2 19 + 24×
Z3 1.5267e+3 1.6689e+4 1.7455e+2 19 + 24×
¯
Z3 : ML2 -optimal state-space
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 28/72
70. Objectives SIF Criteria Evaluation scheme Methodology
Example – 2
¯W
ML2 ¯
Ψ ¯
G ¯
TO Nb. op.
Z1 1.9046e+7 3.3562e+7 1.186e+6 3.6764e+8 7 + 8×
Z2 3.6427e+5 6.5007e+5 3.6582e+2 19 + 24×
Z3 1.5267e+3 1.6689e+4 1.7455e+2 19 + 24×
Z4 1.6272e+3 2.7425e+3 1.1778e+2 19 + 24×
¯
Z4 : Ψ-optimal state-space
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 28/72
71. Objectives SIF Criteria Evaluation scheme Methodology
Example – 2
¯W
ML2 ¯
Ψ ¯
G ¯
TO Nb. op.
Z1 1.9046e+7 3.3562e+7 1.186e+6 3.6764e+8 7 + 8×
Z2 3.6427e+5 6.5007e+5 3.6582e+2 19 + 24×
Z3 1.5267e+3 1.6689e+4 1.7455e+2 19 + 24×
Z4 1.6272e+3 2.7425e+3 1.1778e+2 19 + 24×
Z5 1.9474e+13 1.2294e+13 3.2261e−3 19 + 24×
¯
Z5 : G -optimal state-space
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 28/72
72. Objectives SIF Criteria Evaluation scheme Methodology
Example – 2
¯W
ML2 ¯
Ψ ¯
G ¯
TO Nb. op.
Z1 1.9046e+7 3.3562e+7 1.186e+6 3.6764e+8 7 + 8×
Z2 3.6427e+5 6.5007e+5 3.6582e+2 1.1387e+5 19 + 24×
Z3 1.5267e+3 1.6689e+4 1.7455e+2 5.4111e+4 19 + 24×
Z4 1.6272e+3 2.7425e+3 1.1778e+2 3.6512e+4 19 + 24×
Z5 1.9474e+13 1.2294e+13 3.2261e−3 1.7239e+10 19 + 24×
Z6 2.8696e+3 4.5371e+3 7.9809e−3 6.0078e+0 19 + 24×
Tradeoff measure: we are looking for a good enough realization:
¯W ¯ ¯
ML2 (Z ) Ψ(Z ) G (Z )
¯
TO(Z ) + ¯ opt + ¯ opt
¯W
ML opt Ψ G
2
¯
Z6 : TO-optimal state-space
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 28/72
74. Objectives SIF Criteria Evaluation scheme Methodology
Word-lengths optimization word-length
optimization
A 2nd possible optimization concerns the hardware implementation
On FPGA or ASIC, one can use multiple wordlength paradigm
Optimal word-length
Let Z be a realization and β = (βZ , βT , βX , βY , βADD ) the
word-length
We consider J a computational cost (area, power consumption,
WCET, etc.). The optimal wordlength problem is:
β opt = arg min J (β) with SQNR SQNRmin
β∈B
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 30/72
75. Objectives SIF Criteria Evaluation scheme Methodology
Global methodology
transfer function
a) b)
structure
Structure
SIF
catalog
set of equivalent
realizations
c)
optimal
a priori measure
realization
realization a) Choose a structure
d)
implementation
scheme
fixed-point (state-space, ρDFIIt, ...)
implementation
fixed-point realization wordlength
e)
optimal
implementation
f)
code
language
generation
code
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 31/72
76. Objectives SIF Criteria Evaluation scheme Methodology
Global methodology
transfer function
a) b)
structure
Structure
SIF
catalog
set of equivalent
realizations
c)
optimal
a priori measure
realization
realization b) Formalization SIF and
d)
implementation
scheme
fixed-point set of equivalent
implementation
realizations
fixed-point realization wordlength
e)
optimal
implementation
f)
code
language
generation
code
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 31/72
77. Objectives SIF Criteria Evaluation scheme Methodology
Global methodology
transfer function
a) b)
structure
Structure
SIF
catalog
set of equivalent
realizations
c)
optimal
a priori measure
realization
realization
d)
c) Optimization of an a
implementation fixed-point
scheme implementation priori criterion
fixed-point realization wordlength
e)
optimal
implementation
f)
code
language
generation
code
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 31/72
78. Objectives SIF Criteria Evaluation scheme Methodology
Global methodology
transfer function
a) b)
structure
Structure
SIF
catalog
set of equivalent
realizations
c)
optimal
a priori measure
realization
d) Given some
realization word-lengths and an
implementation
d)
fixed-point sum-of-products evaluation
scheme implementation
scheme, the fixed-point
fixed-point realization wordlength
representation are defined
e)
optimal
implementation
f)
code
language
generation
code
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 31/72
79. Objectives SIF Criteria Evaluation scheme Methodology
Global methodology
transfer function
a) b)
structure
Structure
SIF
catalog
set of equivalent
realizations
c)
optimal
a priori measure
realization e) Optimization of the
realization
implementation:
d) optimization of a
implementation fixed-point
scheme implementation computational cost under
fixed-point realization wordlength a priori criterion constraint
e)
optimal
implementation
f)
code
language
generation
code
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 31/72
80. Objectives SIF Criteria Evaluation scheme Methodology
Global methodology
transfer function
a) b)
structure
Structure
SIF
catalog
set of equivalent
realizations
c)
optimal
a priori measure
realization
realization
d)
f) Fixed-point code
implementation fixed-point
scheme implementation generation (C, VHDL, ...)
fixed-point realization wordlength
e)
optimal
implementation
f)
code
language
generation
code
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 31/72
81. Objectives SIF Criteria Evaluation scheme Methodology
Example – 1
An other example to be implemented on 8-bit device (with 16-bit
accumulator)
0.02088z 2 + 0.04176z + 0.02088
H(z) =
z 2 − 1.651z + 0.7342
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 32/72
82. Objectives SIF Criteria Evaluation scheme Methodology
Example – 1
An other example to be implemented on 8-bit device (with 16-bit
accumulator)
0.02088z 2 + 0.04176z + 0.02088
H(z) =
z 2 − 1.651z + 0.7342
Some possible realizations:
R1 : Direct Form I
R2 : Direct Form II
R3 : Balanced state-space
2
R4 : σ∆H -optimal state-space
R5 : optimal state-space with δ-optimal
R6 : optimal ρ-Direct Form II
From controller/filter to code: the optimal implementation problem Thibault Hilaire (thibault.hilaire@lip6.fr) 32/72