Forum Discussion
Altera_Forum
Honored Contributor
13 years agoWhat you need to do is create an internal counter that will reset itself once a second.
I would suggest making 2 counters. The first counter should count from 0 to <Clock speed in MHz - 1>. If Clock is at 100 MHz, have your first counter (counter1) count from 0 to 99. When counter1 = 99, have it reset to 0. For the second counter, when counter1 = 99, increment counter2. When counter2 = 999999 and counter1 = 99, one second has passed and you should increment tmp and reset counter2 to 0. An alternate solution would be to have your counter count from 0 to the clock speed in Hz. The only reason I might suggest avoiding this path is for timing reasons. It really isn't as hard as it may seem. Give it a try and if you have problems, keep posting. We'll get you there.