Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20644 Discussions

Long counter (30s) in VHDL, balancing a clock divide and counter size

bigcheesefuzz
Beginner
1,142 Views

I need to add a timer to an application running on a Cyclone V with a long (30s) period.

 

I can easily write an integer counter that counts the clock (30MHz) x 30s = 90,000,000 which uses ~150 LUTs.

 

However I'm looking to reduce the amount of LUTs, I can divide the 30MHz clock down (say 100 or 1000) and the my counter only need to count the equivalent amount.

 

Are there any rules / guides to the ratio of clock divide-to- counter size to best implement a design ? Particularly for the smallest amount of LUTs ?

 

Plus running the counter slower would surely better from a timing perspective ?

0 Kudos
1 Reply
ak6dn
Valued Contributor III
342 Views

If you need just a fixed duration counter (ie, don't need to load arbitrary count values) I would examine use of an LFSR approach to use a minimal number of cells. The number of cells will basically track the length of the counter. A 30 bit counter could have a period of 2^30-1 clocks (this is what is know as a maximal length LFSR). Here is a good quick reference: https://en.wikipedia.org/wiki/Linear-feedback_shift_register

0 Kudos
Reply