F
FPGA
Guest
On Feb 15, 3:21 pm, John_H <newsgr...@johnhandwork.com> wrote:
the suggested changes and let you guys know how it went.
This is for simulation only. Thanks for all your comments. I will makeOn Feb 15, 10:53 am, FPGA <FPGA.unkn...@gmail.com> wrote:
On Feb 15, 12:45 pm, John_H <newsgr...@johnhandwork.com> wrote:
On Feb 15, 8:11 am, FPGA <FPGA.unkn...@gmail.com> wrote:
I have written a process to generate sine wave. I am getting a
distorted wave and not a pure sine wave. I am not sure if this has
anything to do with the simulator.
two : process
variable phase_temp,result : real;
constant scale : real := 2.0*real(bw);
begin
phase_temp := phase_sin; --phase_sin;
l1 : for i in 1 to samples_sin loop --number_of_samples loop
result := scale*(amp_sin*(sin(frq_sin + phase_temp)));
sine_real <= (amp_sin*(sin(frq_sin + phase_temp)));
sinWave <= toSigned(result,bw);
phase_temp := phase_temp+incr_sin;
wait for 5 ns;
end loop l1;
end process two;
generic value : phase_sin : real := 0.0; samples_sin : integer :> > > > 1000; incr_sin : real := 1.0;
frq_sin : real := 1000.0;
I dont see the frequency of the wave change if the frq_sin is changed.
Same happens when samples_sin is changed. I am not sure what is going
wrong. Please help
Your frq_sin value is actually just a phase offset. There is no time
associated with this constant to feed the sin(). The phase_temp, on
the other hand, is effectively t*incr_sin where t is a cycle count.
To see the frequency change, change the incr_sin value instead.
In what way is your sine distorted?
- John_H- Hide quoted text -
- Show quoted text -
How can I pass time parameter to the sineWave? I was able to remove
the distortion by reducing the incr_sin value. Still not clear on the
frequency and time parameter that you are talking about.- Hide quoted text -
- Show quoted text -
Phase accumulators are used to mark the prograssion of time. You want
sin(f*T) which is sin(f*n*deltaT) where deltaT is your clock period.
f*n*deltaT is the same as sum from 1 to n of f*deltaT, this last item
being a constant.
That's what you're doing with the incr_sin, isn't it? If you have an
increment of 1/100 of a sinusoidal period, the sum of 100 increments
will be one sinusoidal period bringing you right back to the
beginning.
You *are* doing this for simulation only, aren't you?
- John_H- Hide quoted text -
- Show quoted text -
the suggested changes and let you guys know how it went.