Hi all, I'm trying to create a sine wave using the quarter wave symmetry property. I have followed the attached block diagram and not getting output for 1MHz frequency, which appears to have small peaks during change from one quadrant to another. I have attached the Vivado project and the output waveform. Can someone please help me to debug the code?
Edit: The issue is solved, and all files are in the zip file if anyone is interested in the project.
Their is a difference in latency between the 'pa_out' signal and the 's_lut_out', because the lookup table's output is registered.
lut_complementer # (
.N(17)
)
C2 (
.clk(clk), .rst(rst), .msb_in(pa_out[11]),
.comp_in(s_lut_out), .comp_out(s_out)
);
You want to delay pa_out[11] by one cycle.
Oh and your LUT table is slightly wrong....
Table entry x should be
table[x] = sin((2*x+1)/(2*table_size)*PI/2)
not the current
table[x] = sin(x/table_size)*PI/2)
With the current LUT values, if you walks slowly around the circle you will get what looks to be 'crossover distortion':
11111111101101001 -table[3]
11111111110011011 -table[2]
11111111111001110 -table[1]
00000000000000000 -table[0]
00000000000000000 table[0]
00000000000110010 table[1]
00000000001100101 table[2]
00000000010010111 table[3]
Their is a difference in latency between the 'pa_out' signal and the 's_lut_out', because the lookup table's output is registered.
lut_complementer # (
.N(17)
)
C2 (
.clk(clk), .rst(rst), .msb_in(pa_out[11]),
.comp_in(s_lut_out), .comp_out(s_out)
);
You want to delay pa_out[11] by one cycle.
The pa_out is also registerised if you check the phase_accum module. In top level ddfs, wire is just used to connect the internal signals.
Their is a difference in latency between the 'pa_out' signal and the 's_lut_out', because the lookup table's output is registered.
lut_complementer # (
.N(17)
)
C2 (
.clk(clk), .rst(rst), .msb_in(pa_out[11]),
.comp_in(s_lut_out), .comp_out(s_out)
);
You want to delay pa_out[11] by one cycle.
The pa_out is also registerised if you check the phase_accum module. In top level ddfs, wire is just used to connect the internal signals.
Sorry, you were right. Delaying by two clock cycles fixed the "crossover" problem. I didn't change the LUT though.
reg dly1, dly2;
always @(posedge clk or negedge rst)
begin
if (~rst)
begin
dly1 <= 0;
dly2 <= 0;
end
else
begin
dly1 <= pa_out[11];
dly2 <= dly1;
end
end
Hi all, I'm trying to create a sine wave using the quarter wave symmetry property. I have followed the attached block diagram and got all the proper outputs except the sine wave output, which appears to have small peaks during change from one quadrant to another. I have attached the Vivado project and the output waveform. Can someone please help me to debug the code?
I completed the code for both sine and cosine wave and I'm getting output for all frequencies but not 1 MHz, as you can see, there is peaks when sine goes from one quadrant to another. The output is clean for other frequencies. The frequency tuning word or fcw is calculated as:
FCW = (Fout * 2^(n))/Fclk
So, for Fout = 1 MHz, n = 20-bits and Fclk = 100 MHz, FCW = 10486. In the testbench you can put any value for FCW (Fout less than 1/10 Fclk), and you would get a proper output, just not for 1MHz, that's my issue.
Thanks.
I am pretty sure that 1,000,000 x 2^20 will cause an integer overflow.
Could that be your problem?
I am pretty sure that 1,000,000 x 2^20 will cause an integer overflow.
Could that be your problem?
Phase word is hard coded in the program and not calculated using the expression.
I am pretty sure that 1,000,000 x 2^20 will cause an integer overflow.
Could that be your problem?
Phase word is hard coded in the program and not calculated using the expression.
If you are able to post a zip of the .v files, including the testbench that demonstrates the problem, I'll have a look at it..
I am pretty sure that 1,000,000 x 2^20 will cause an integer overflow.
Could that be your problem?
Phase word is hard coded in the program and not calculated using the expression.
If you are able to post a zip of the .v files, including the testbench that demonstrates the problem, I'll have a look at it..
Everything is in the Vivado project folder bro, you just need to open the .xpr file in Xilinx vivado and everything is there.
You can find the .v files in srcs folder.
By the way, I fixed the issue. I followed the block diagram, and you can see that PA complementor outputs (k-2) bits but I coded it to output (k-2+1) bits, so that was causing the problem. Now it works for all FCW values. I updated the .zip files if you want to try it out and maybe you can do a more thorough testing?