Simple explanation of the principle of DDS in FPGA[Copy link]
This post was last edited by Jacktang on 2019-4-12 09:06 DDS (Direct Digital Synthesizer) is a digital synthesizer. It can easily achieve frequency, phase, and amplitude control by modifying FWORD (frequency control word) and PWORD (phase control word). It is widely used in the communication field. The schematic diagram is shown in the figure below
The following is an explanation of the principle of this diagram in the form of code Assume that the Clk clock frequency is 100MHZ and the period is 10ns, and assume that data can form a 32-point sine wave signal always@(posedge Clk) time <= time +1'b1 ; case(time) 0:data = 0 1:data = 1 2: data = 2.5 3: data = 3.7 Omitted here 31: data = 0 ; It can be seen that: the period of a sine wave is 32*10, that is, 320ns, and the frequency is 1/320 * 10^9 hz. To make it a sine wave with a period of 160ns, we know that one point is output every 10ns. To make the period of 160ns, 160/10 points, that is, 16 points, need to be output. How do we control the system to output 16 points? If you think about it carefully, you will know that you only need to change time <= time + 1; to time <= time + 2; and time <= time + B corresponds exactly to the circuit diagram of the accumulator, which is exactly the idea of DDS. In order to further understand the principle of DDS, we still understand it in the form of code. In general, FWORD is 32 bits, and ROM is 11 bits wide, that is, 2048 points to form a sine wave, which means that a fixed sine wave period is 2048*10ns. To generate a sine wave with a frequency of Fout, you can only change the number of points of the sine wave to be displayed. How to change the number of points of the sine wave to be displayed? We can only use time to perform sampling at intervals according to different needs, so we can get Fout = Fclk *2^N / B; The above formula can be understood as follows: it is known that the time required to output a point is 1/Fclk, so how many points should be output to control a sine wave period of 1/Fout? That is, by changing the B value, you can find out the number of output points, that is, 1/Fclk * (actual number of output points) = 1/Fout; and the actual number of output points is 2^N /B (simple mathematical knowledge can be understood as follows: 2^N points are output in total, and one point is output every B points. How many points are output in total? It can be easily understood) So we can get: Fout = Fclk *2^N /B; The phase control word is equivalent to a bit cheaper sine wave composed of 2048 points. If the actual address is +1024, it is equivalent to flipping 180 degrees. By changing the phase control word, you can change the starting point you want to display, that is, change the phase of the sine wave you want to display.