FPGARelated.com
Forums

Fast counting in Spartan 3

Started by Preben February 13, 2005
Hi everyone,

I would like to count very fast (100MHz) using an 19-bit counter in 
spartan 3 - any ideas how to make such a fast counter!
One idea is to use the Chinese Remainder Theorem to count, but that 
make's a "hit-rate" of only 60% or so, if the timing is restricted.

The other Idea is to make a pipelined counter, but that make's the whole 
design a lot more complicated.

Any other Ideas?


I use the Spartan 3 digilent starter board!


Thanks in advance!

/ Preben
Preben, have you done the timing analysis on a straightforward
implementation?
I have run longer counters at higher frequency in Spartan 3...There is
a built-in carry structure!
Is your counter loadable? if not, your counter might be implemented as
a ripple ( or a partially-ripple) counter, then you can count several
hundred MHz ( use the Q as clock source for the next slice, or next
group of 4 flip-flops.) If you do this, you have to wait out the ripple
delay before you use or decode the counter output.
Thre are many ways to achieve 100 MHz, or 2x, or 4x that performance,
it all depends on your real requirements.
Peter Alfke, Xilinx Applications.

"Preben" <64bitNOspamNO@mailme.dk> wrote in message 
news:420fab6f$0$12714$edfadb0f@dread14.news.tele.dk...
> Hi everyone, > > I would like to count very fast (100MHz) using an 19-bit counter in > spartan 3 - any ideas how to make such a fast counter! > One idea is to use the Chinese Remainder Theorem to count, but that make's > a "hit-rate" of only 60% or so, if the timing is restricted. > > The other Idea is to make a pipelined counter, but that make's the whole > design a lot more complicated. >
!00 MHz does not sound that fast for a Spartan III. Did you try a HDL synthesys and P&R with time constraint?
> Any other Ideas?
Perhaps an 8 bit prescaler with a pipelined clock enable to an 11 bit counter. 20 bit counter using block RAM http://www.synplicity.com/literature/syndicated/pdf/spartan_3_v3_i3.pdf Have fun -Newman
> > > I use the Spartan 3 digilent starter board! > > > Thanks in advance! > > / Preben
"Preben" <64bitNOspamNO@mailme.dk> schrieb im Newsbeitrag
news:420fab6f$0$12714$edfadb0f@dread14.news.tele.dk...
> Hi everyone, > > I would like to count very fast (100MHz) using an 19-bit counter in > spartan 3 - any ideas how to make such a fast counter!
Just a straight forward approach. Been there, done this recently. It was a 32 Bit counter, running at 130 MHz and still having some timing margin left. Regards Falk
Preben <64bitNOspamNO@mailme.dk> wrote:
> Hi everyone,
> I would like to count very fast (100MHz) using an 19-bit counter in > spartan 3 - any ideas how to make such a fast counter! > One idea is to use the Chinese Remainder Theorem to count, but that > make's a "hit-rate" of only 60% or so, if the timing is restricted.
Spartan 3, 100MHz and ... fast? I think you are kidding. Did you try to implement the counter? I guess it will run much faster Bye -- Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Like everyone say, 100MHz is trivial. If you had to go much faster there 
are many clever ways (depending on how you can compromise).  Here are 
two O(1) counters:

1. Linear feedback shift register.  Of course, when you really need the 
count the conversion back is expensive.

2. Carry-save addition.  Maintain the count y as x1-x2, where x1 and x2 
are two n-bit integers.  To increase y, assign (in parallel)

   x1 <= x2 ^ ~x1;
   x2 <= (x2 | ~x1) << 1;

This time the conversion back is cheap & trivial. For how and why this 
works, see page 32 of Knuth's MMIX introduction: 
http://www-cs-faculty.standford.edu/~knuth/mmix-doc.ps.gz

I think I've seen Peter pull some really clever counter tricks (though 
more FPGA specific).

Tommy


Uwe Bonnes wrote:
> Preben <64bitNOspamNO@mailme.dk> wrote: > >>Hi everyone, > > >>I would like to count very fast (100MHz) using an 19-bit counter in >>spartan 3 - any ideas how to make such a fast counter! >>One idea is to use the Chinese Remainder Theorem to count, but that >>make's a "hit-rate" of only 60% or so, if the timing is restricted. > > > Spartan 3, 100MHz and ... fast? I think you are kidding. Did you try to > implement the counter? I guess it will run much faster > > Bye >
"Tommy Thorn" <foobar@nowhere.void> wrote in message 
news:GdTPd.6680$m31.81473@typhoon.sonic.net...

> > This time the conversion back is cheap & trivial. For how and why this > works, see page 32 of Knuth's MMIX introduction: > http://www-cs-faculty.standford.edu/~knuth/mmix-doc.ps.gz >
I got a 401 on that.
Tommy Thorn wrote:
> Like everyone say, 100MHz is trivial. If you had to go much faster there > are many clever ways (depending on how you can compromise). Here are > two O(1) counters: > > 1. Linear feedback shift register. Of course, when you really need the > count the conversion back is expensive. > > 2. Carry-save addition. Maintain the count y as x1-x2, where x1 and x2 > are two n-bit integers. To increase y, assign (in parallel) > > x1 <= x2 ^ ~x1; > x2 <= (x2 | ~x1) << 1; > > This time the conversion back is cheap & trivial. For how and why this > works, see page 32 of Knuth's MMIX introduction: > http://www-cs-faculty.standford.edu/~knuth/mmix-doc.ps.gz
Transcriping URL's by hand and mispelling, grief: http://www-cs-faculty.stanford.edu/~knuth/mmix-doc.ps.gz Sorry. Tommy
On Sun, 13 Feb 2005 18:02:25 -0800, "Pete Fraser" <pfraser@covad.net>
wrote:

> >"Tommy Thorn" <foobar@nowhere.void> wrote in message >news:GdTPd.6680$m31.81473@typhoon.sonic.net... > >> >> This time the conversion back is cheap & trivial. For how and why this >> works, see page 32 of Knuth's MMIX introduction: >> http://www-cs-faculty.standford.edu/~knuth/mmix-doc.ps.gz >> > >I got a 401 on that. >
Just remove the extra "d" in stanford. I am curious how it got there though. I can't imagine anyone actually typing that url.
Maybe you've got one of those fancy new layout keyboards, but on my QWERTY 
version D is next to F. Perhaps the perp pressed two adjacent keys at the 
same time when they meant to press just oner. Not exactly CSI is it?  ;-)
Cheers, Syms.
"mk" <kal*@dspia.*comdelete> wrote in message 
news:92f011hp912jnbn8lo06sq1tu4sapga197@4ax.com...
> Just remove the extra "d" in stanford. I am curious how it got there > though. I can't imagine anyone actually typing that url. >