Forum Discussion
Altera_Forum
Honored Contributor
16 years agoGenerating a Sine Wave
Hello Friends, I am a newbie.. hope you dont mind if my query is odd.. i wanted to the know like how can we generate a SINE WAVE.. by writing a verilog or vhdl code. i browsed throug...
Altera_Forum
Honored Contributor
16 years agoThank you Ketan :) once again..
i am working on this just for my understanding..as i am a newbie i wanted to plot or display a sine wave from Look Up Table.. as you have said i have taken 2*pi/20 and completed 20 samples i converted them into integers upto 3 digits and took 2's compliment. these i generated in excel sheet 2*pi/20 Sin((2*Pi/3600)*S.No) I2 * 1000 INT(J2) 2's Compliment 1) 0.314159265 0.309016994 309.0169944 309 0100110101 2) 0.628318531 0.587785252 587.7852523 587 1001001011 3) 0.942477796 0.809016994 809.0169944 809 1100101001 4) 1.256637061 0.951056516 951.0565163 951 1110110111 5) 1.570796327 1 1000 1000 1111101000 6) 1.884955592 0.951056516 951.0565163 951 1110110111 7) 2.199114858 0.809016994 809.0169944 809 1100101001 8) 2.513274123 0.587785252 587.7852523 587 1001001011 9) 2.827433388 0.309016994 309.0169944 309 0100110101 10)3.141592654 3.67523E-15 0 0 0000000000 11)3.455751919 -0.309016994 -309.0169944 -310 0011001010 12)3.769911184 -0.587785252 -587.7852523 -588 0110110100 13)4.08407045 -0.809016994 -809.0169944 -810 0011010110 14)4.398229715 -0.951056516 -951.0565163 -952 0001001000 15)4.71238898 -1 -1000 -1000 0000011000 16)5.026548246 -0.951056516 -951.0565163 -952 0001001000 17)5.340707511 -0.809016994 -809.0169944 -810 0011010110 18)5.654866776 -0.587785252 -587.7852523 -588 0110110100 19)5.969026042 -0.309016994 -309.0169944 -310 0011001010 20)6.283185307 -7.35046E-15 -7.35046E-12 0 0000000000 does this work, also the kind of DAC what we r having is 12 bit DAC , but before that i just wanted to display (probabily plot sinewave) using these values.. so can i read the above binary values using $readmemb command and also later how can i tell simulator that i have negative numbers..please can you help me with this situation.. i think you can understand that i am a newbiein programming. if i am wrong in any way can you suggest me more. waiting for your reply Thanks in advance :) Pradeep