C
Cory Shol
Hi all,
Another problem from the two year FPGA newbie.
I am working on a new work project that does all this magnificent things and now I am a little stumped on a rather easy to understand problem.
I need to calculate how many pulses per minute of an input to display out of a Seven segment display.
I have completed all the user interface stuff and it works fine etc...
The problem is with the calculation.
I am running at 25 Mhz clock. 40 ns period.
Basically I wait for a rising edge of the first pulse and reset my counter. Every rising edge of my 25 Mhz clock I increment the counter until the next rising edge of the pulse.
Basically the Pulse can be as slow as 15 ppm to 1000 ppm. So if you have a 1000 ppm pulse inputting you would see 1500000 25 Mhz clock counts.
The hard part is converting 1500000 counts into a PPM.
I know the math is easy : 60 /[(count)*(Period of Clk)] = PPM
60/ (1500000 *(0.00000004))= 1000 ppm
Doing division in VHDL seems to be tough.
I have one algorithm idea of doing basically the basic of all basics.
which is: 60/clkPeriod = 1.5 billion
initially do this:
newCount <= newCount - count;
quotient <= quotient + 1;
Then after initial do this:
if(newCount >= Count) then
newCount <= newcount -count;
quotient <= quotient + 1;
else
finalanswer <= quotient;
end if;
Are there any other easy algorithms that are relatively easy to implement? Or a standard way the VHDL community does divisions?
Thanks
Cory
Another problem from the two year FPGA newbie.
I am working on a new work project that does all this magnificent things and now I am a little stumped on a rather easy to understand problem.
I need to calculate how many pulses per minute of an input to display out of a Seven segment display.
I have completed all the user interface stuff and it works fine etc...
The problem is with the calculation.
I am running at 25 Mhz clock. 40 ns period.
Basically I wait for a rising edge of the first pulse and reset my counter. Every rising edge of my 25 Mhz clock I increment the counter until the next rising edge of the pulse.
Basically the Pulse can be as slow as 15 ppm to 1000 ppm. So if you have a 1000 ppm pulse inputting you would see 1500000 25 Mhz clock counts.
The hard part is converting 1500000 counts into a PPM.
I know the math is easy : 60 /[(count)*(Period of Clk)] = PPM
60/ (1500000 *(0.00000004))= 1000 ppm
Doing division in VHDL seems to be tough.
I have one algorithm idea of doing basically the basic of all basics.
which is: 60/clkPeriod = 1.5 billion
initially do this:
newCount <= newCount - count;
quotient <= quotient + 1;
Then after initial do this:
if(newCount >= Count) then
newCount <= newcount -count;
quotient <= quotient + 1;
else
finalanswer <= quotient;
end if;
Are there any other easy algorithms that are relatively easy to implement? Or a standard way the VHDL community does divisions?
Thanks
Cory