This application is based upon and claims the benefit of priority from France Patent Application No. 07 56038, filed Jun. 26, 2007, the entire contents of which are incorporated herein by reference.
The invention relates to a method and a device for numerically generating a digital signal of a given frequency.
To numerically generate a frequency, one solution consists in generating the discrete values of one or more trigonometric functions, for example cosine and sine, corresponding to the frequency to be generated, these discrete values corresponding to points situated on the curves of the trigonometric functions used.
Among the various existing digital frequency generation procedures, there is one, dubbed “recursive” or “iterative”, which is based on calculating sines and cosines of consecutive angles. This procedure relies on the following trigonometric identity:
e
jφ
=e
j(kφ
+φ
)
=e
j[(k−1)φ
+φ
]
·e
jφ
=e
jφ
·e
jφ
(1)
where
Putting xk=cos φk and yk=sin φk.
It follows from identity (1) that:
−xk=xk−1·cos φs−yk−1·sin φs (2)
−yk=yk−1·cos φs+xk−1·sin φs (3)
Thus, the initial phase φ0 and the phase gap φs being known, the sine and cosines values of the following phases φk for k=1, 2, 3, 4, . . . are deduced recursively, from the cosine and sine values of the initial phase φ0. Stated otherwise, it is possible to calculate the values of the pairs (xk, yk) recursively, from the initial pair (x0, y0).
By way of illustrative example, we shall describe the calculation of the sines and cosines for k=1, k=2 and k=3, with an initial phase φ0=0° and a phase gap φs=1°. For the requirements of the calculations, the cosine and the sine of the angle φs=1° are calculated and stored: cos(1°)=0.999848 and sin(1°)=0.017452.
Initially, for k=0, we have cos φ0=1 and sin φ0=0.
Thereafter, for k=1, cos φ1 and sin φ1 are calculated from cos φ0 and sin φ0 with the aid of equations (2) and (3):
x
1
=x
0·cos(1°)−y0·sin(1°)=1·cos(1°)−0·sin(1°)=0.999848
y
1
=y
0·cos(1°)+x0·sin(1°)=0·cos(1°)+1·sin(1°)=0.017452
Thereafter, for k=2, cos φ2 and sin φ2 are calculated from cos φ1 and sin φ1 with the aid of equations (2) and (3):
Thereafter, for k=3, cos φ3 and sin φ3 are calculated from cos φ2 and sin φ2 with the aid of equations (2) and (3):
The procedure thus makes it possible to recursively calculate the sines and cosines of consecutive angles.
Trigonometric calculations using standard trigonometric functions consume a great deal of calculation time. With the recursive procedure which has just been described for the trigonometric calculation of consecutive angles, the results of the sines and cosines of consecutive angles are calculated without calling upon trigonometric functions. Specifically, the calculations use the results of the sines and cosines of the phase gap φs and require that only multiplication and addition operations be carried out. This procedure thus exhibits the advantage of being able to be implemented with simple hardware and/or software means and of offering a constant calculation speed, independently of the precision required for the frequency generated. Its use is therefore particularly beneficial.
However, such a procedure for the trigonometric calculation of consecutive angles exhibits a major drawback: it is numerically unstable. This drawback is related to the fact that it is recursive, that is to say it calculates the values (xk, yk) from the previously calculated result (xk−1, yk−1), and that the numerical calculation means impose a finite precision for the calculations. In particular, the calculations of the values (xk, yk) are carried out on the basis of rounded values with the finite precision used of the values (xk−1, yk−1) and of the cosines and sines of the phase gap φs. Furthermore, the result provided by the calculation means for the pair of values (xk, yk) is itself a rounded value, an approximation of the real result of the calculations. Such approximations produce, at each phase increment k, an error in the calculations. This error feeds into the following calculations, corresponding to the phase increment (k+1), which amplify it further. As a function of the initial values of the pairs (x0, y0) and (xs, ys), the pair of calculated values (xk, yk) may either degenerate towards zero, or increase towards the infinity. This entails an evolving vicious circle producing a “snowball effect” which considerably and rapidly degrades the precision of the calculations. This is the reason why this procedure for numerically generating the frequency of consecutive angles is unusable in practice.
The present invention proposes a method of numerically generating a given frequency, in which
which makes it possible to solve the numerical instability problem explained in the preceding paragraph.
For this purpose, a number N of rounded results of the trigonometric function for said phase gap φS and respective probabilities pi of selecting said N rounded results being provided, the invention resides in the fact of selecting one of the N rounded results for the phase gap φS, and of calculating the result of the trigonometric function for the phase of index k taking account of the determined selection probabilities pi.
The invention therefore consists in selecting each of the N rounded results of the trigonometric function for the phase gap with a predefined selection probability. The probabilities of drawing, or of selecting, the various rounded results can thus be chosen so as to ensure numerical stability of the iterative calculation method. Instead of accumulating and therefore amplifying, the successive rounding errors compensate one another and mutually cancel one another.
In a particular embodiment, to select one of the N rounded results for the phase gap φS taking account of the determined selection probabilities pi,
By virtue of this, the respective probabilities of selecting the various rounded results are taken into account in a simple and effective manner to select these rounded results during the iterative calculation process.
Advantageously, the rounded results being calculated with a finite precision of w bits on the fractional part, it being assumed that the results are represented using a fixed decimal point with w bits after the decimal point, the result of the trigonometric function for the phase of index k, obtained by multiplication of the rounded results of the trigonometric function for the previous phase of index k−1 and for the phase gap respectively, is rounded by truncating the fractional part of said result for the phase of index k by a portion of w bits and the value represented by the portion of the w truncated bits in the reference interval is determined so as to generate the random number.
The invention also relates to a device for numerically generating a given frequency comprising iterative calculation means designed to repeat the calculation of at least one trigonometric function for consecutive phases separated by a phase gap φS which is dependent on the frequency to be generated, the calculation of said trigonometric function for a phase of index k, k representing a phase incrementation index according to the phase gap φS, being carried out on the basis of a rounded result of the trigonometric function for the previous phase of index k−1 and of a rounded result of the trigonometric function for said phase gap respectively, characterized in that it comprises
The invention will be better understood with the aid of the following description of the method and of the device for numerically generating a given frequency according to the invention, with reference to the appended drawings in which:
The method of the invention makes it possible to generate a digital signal with a given digital frequency, denoted fc, by calculating at least one trigonometric function for consecutive angles. In the particular example of the description, the trigonometric function used is the complex exponential function defined in the following manner:
e
jz=cos(z)+j sin(z)
Let us first recall the following trigonometric identity:
e
jφ
=e
j(kφ
+φ
)
=e
j[(k−1)φ
+φ
]
·e
jφ
=e
jφ
·e
jφ
(1)
where
The signal generated by the frequency generator is a digital signal, sampled at the sampling frequency fs. In order to comply with the Nyquist-Shannon criterion, the frequencies fs and fc are such that
It follows from this that the phase gap is such that φs≦π.
The initial phase φ0 being zero, the following trigonometric identity is obtained:
e
jφ
=e
jφ
·e
jφ
(2)
From relation (2), the complex exponential function ejφ
Putting:
−xk=cos φk
−yk=sin φk
Then, it is possible to express the complex exponential function in the following manner:
e
jφ
=x
k
+j·y
k
Additionally, for the sake of conciseness, we put:
x
k
+j·y
k=(xk,yk)
The mathematical identity relation (2) yields the following relations:
In practice, the calculations are carried out with finite precision. In the nonlimiting particular example described here, this involves a precision of w bits on the fractional part (that is to say on the part of the number situated after the decimal point). Thus, the result of the calculation of the complex exponential function ejφ
Let Qw
be a rounding operator with w bits on the fractional part. The function of this rounding operator, represented by the notation Qw[.], is to round a number, having an integer part and a fractional part coded on a certain number of bits, by truncating the fractional part of the lowest order bits so as to preserve only the w bits of the fractional part of highest orders. The result obtained is an approximate result, that will also subsequently be called a “rounded result” or “approximation”, of the number considered, with a finite precision of w bits on the fractional part.
The result of the calculation of the complex exponential function, with finite precision of w bits on the fractional part, for the phase of index k is therefore:
Q
w[(xk,yk)]=Qw[Qw[(xk−1,yk−1)]·Qw[(cos φs, sin φs)]] (4)
A particular embodiment of the method of the invention will now be described with reference to
The method comprises a preliminary phase Φ comprising
Represented in
Also represented in the complex plane of
Ultimately, the phase rotation vector {right arrow over (rv)} models the complex exponential function for the phase gap φs, that is to say ejφ
Represented in a more detailed manner in
{right arrow over (ev
The sub-step Φ2 of determining the respective probabilities of selecting the four possible approximation vectors {right arrow over (rv
This system of equations conveys several conditions that the selection probabilities p1, p2, p3, p4 must comply with.
Equation (a) conveys the condition according to which the sum of the selection probabilities p1, p2, p3, p4 must be equal to 1.
Equations (b) and (c) convey the condition according to which, on average, the approximation error must be zero.
Equation (d) conveys the condition according to which the variance of the error, which corresponds to the energy of the error, must be a minimum.
To solve this system of equations, we proceed in the following manner:
Finally, since we are dealing with probabilities, a check is made to verify that pi≧0 for i=1, 2, 3, 4. If this is not the case, the value 0 is assigned to each probability pi which is negative and equations (a), (b) and (c) are solved to calculate the remaining unknown probabilities.
Solving this system of equations thus makes it possible to obtain the respective values of the selection probabilities p1, p2, p3, p4 for the vectors {right arrow over (rv
Following this initial phase Φ of calculating the respective probabilities of selecting the four approximations of the result of the function ejφ
This loop comprises the repetition of a step of calculating the complex exponential function for consecutive phases φk, for k=0, 1, 2 . . . . Two consecutive phases are separated from one another by the phase gap φs; stated otherwise we have the relation: φk=φk−1+φs
The loop comprises a first step β0, termed the initialization step, for the index k=0.
During this step β0, the value of Qw[ejφ
Step β0 is followed by a step β1 corresponding to the incrementation index k=1 of calculating the complex exponential function for the phase φ1=φ0+φS. During this step β1, the following sub-steps are carried out so as to calculate a rounding of ejφ
Qw[ejφ
Q
w
[Q
w
[e
jφ
]·Q
w
[e
jφ
]]=Q
w
[e
jφ
]
Step β1 is followed by a succession of steps βk for k=2, 3, . . . .
A calculation step βk for k=2, 3, . . . , calculates a rounding, or approximate result, with a precision of w bits on the fractional part of the complex exponential function for the phase φk. This approximate result is denoted Qw[ejφ
I1=[0,p1[
I
2
=[p
1
,p
1
+p
2[
I
3
=[p
1
+p
2
,p
1
+p
2
+p
3[
I
4
=[p
1
+p
2
+p
3
,p
1
+p
2
+p
3
p
4]
During sub-step βk,1, the random number lk can be generated by a pseudo-random number generator, known to the person skilled in the art. To generate this random number lk, it is also possible to use a batch of w bits truncated by the rounding operator Qw[·] in the previous calculation step βk−1, and more precisely in sub-step βk−1,4. In fact, in the previous calculation step βk−1, the rounding operator has calculated two rounded results: one on the real part and the other on the imaginary part. The rounding operator therefore produces two batches of w truncated bits. To generate the random number lk, it is possible to use one of these two batches or even a concatenation of w/2 bits of one of the batches and of w/2 bits of the other batch. The value represented is determined by the batch of w bits truncated in the reference interval Iref, here Iref=[0,1]. For example, if we take w=4 and 4 truncated bits equalling 1 0 1 1, the value represented by these bits in the interval [0,1] is 2−1+2−3+2−4=0.6875. Stated otherwise, the w truncated bits are translated into a value included in the reference interval Iref. This value constitutes the random number lk of index k.
The calculation step βk is thus repeated for consecutive phases φk separated pairwise by a phase gap φS so long as a digital signal of frequency fc has to be generated. A test step τk for verifying whether the frequency fc still has to be generated is therefore carried out at the end of each step βk. If it is appropriate to continue the generation of frequency fc, step βk+1 is executed. Otherwise, the method is interrupted.
A particular form of realization of the device for generating a digital frequency, able to implement the method which has just been described, will now be described with reference to
The device represented in
The storage memory 1 is here a shift register intended to receive and to provisionally store the result of each calculation step βk, stated otherwise the rounding Qw[ejφ
The selection module 2 comprises
The sub-module 20 for determining a selection index j comprises
The sub-module 20 is designed to implement sub-step βk,1. During operation, in each calculation step βk, the generator 204 generates the random number lk uniformly distributed over the reference interval [0,1] and provides it to the block 205 for determining a selection index j. The block 205 determines the sub-interval to which the number lk belongs from among the four sub-intervals I1, I2, I3 and I4 of the reference interval [0,1] which are defined by the probabilities p1, p2, p3, p4 in the following manner:
I1=[0,p1[; I2=[p1,p1+p2[; I3=[p1+p2,p1+p2+p3[; I4=[p1+p2+p3,p1+p2+p3+p4]
The random number lk belonging to the interval Ij, the sub-module 20 allocates the value j to the selection index and provides the latter to the sub-module 21.
In the case where the random number lk is generated from the w truncated bits in the previous calculation step βk−1, the device comprises a connection between an additional output of the rounding operator, intended to deliver the w bits truncated by the rounding operator in each calculation step βk, and an additional input of the sub-module 20 for determining the selection index j. Furthermore, the sub-module 20 comprises a memory for storing the w truncated bits provided at each calculation step by the rounding operator 4 and means for determining the value represented by these w truncated bits, which corresponds to the random number used during the following calculation step to determine the selection index j.
Furthermore, during the initial step β0 of the calculation loop (that is to say for k=0), the module 20 for determining a selection index j is designed to allocate to the selection index j the value of the index i of the highest probability pi out of the four probabilities p1, p2, p3, p4.
The sub-module 21 for providing an approximate result of the complex exponential function for the phase gap φS comprises
The multiplexer 214 is designed to select one of the four approximations of the complex exponential function for the phase gap φS stored in the memories 210 to 213, as a function of the value of the selection index j transmitted by the sub-module 20. During operation, the multiplexer selects the approximation rjejφ
During operation, in calculation sub-step βk, the approximate result of the complex exponential function for the phase φk−1, stored in the memory 1, and the approximate result of the complex exponential function for the phase gap φS, provided by the sub-module 21, are fed as input to the multiplier 3. It multiplies the two approximate results (Qw[ejφ
The digital frequency generation device also comprises a configuration module 5 and a control module 6, in this instance a microprocessor.
The configuration module 5 is designed to implement the two steps Φ1, Φ2 of the preliminary phase Φ, so as to determine, on the basis of a phase gap φS provided, the four approximations r1ejφ
Furthermore, the configuration module 5 is designed to reinitialize the memory 1, by recording therein the approximate result, stored in memory, of the complex exponential function for the initial phase φ0, at the start of each new calculation loop. The frequency generation device could itself be adapted for calculating the initialization value Qw[ejφ
All the elements of the device are connected to the control module 6 which is designed to control the operation thereof.
The elements 204 and 205 of the selection module, the multiplexer 214, the multiplier 3, the rounding operator 4 and the configuration module 5 are, in the particular example described, software modules forming a computer program. The invention therefore also relates to a computer program for a device for numerically generating a given frequency comprising software instructions for implementing the method described above, when said program is executed by the device. The program can be stored in or transmitted by a data medium. The latter can be a hardware storage medium, for example a CD-ROM, a magnetic diskette or a hard disk, or else a transmissible medium such as an electrical, optical or radio signal. The invention also relates to a recording medium readable by a computer on which the program is recorded.
As a variant, these software modules could at least partially be replaced with hardware means.
The digital frequency generation device described above can be integrated into radiocommunication equipment.
In the preceding description, the number N of rounded results of the complex exponential function for the phase gap is equal to four. The invention is not however limited to this particular exemplary embodiment. Of course, the invention could use a number N of rounded results that is less than or greater than four.
The invention applies to all the techniques requiring the numerical generation of a frequency: digital musical instruments, audio synthesis, radiocommunication. In the field of radiocommunications, the invention can be used within the framework of the following operations:
In the preceding description, a new procedure for generating random numbers has been explained. According to this new procedure, to generate a succession of random numbers, use is made of the w bits truncated by the rounding operator of the fractional part of the results successively obtained, for consecutive phases φk (with k=1, 2, . . . ) separated by the phase gap φS, by multiplication between the two rounded results of a trigonometric function respectively for the phase φk and for the phase gap φS. Such a procedure for generating random numbers can be used in applications requiring the generation of random numbers, apart from frequency generation. It can be implemented in a pseudo-random generator having the initial phase φ0 and the phase gap φS as configuration parameters.
Number | Date | Country | Kind |
---|---|---|---|
07 56038 | Jun 2007 | FR | national |