On Jul 26, 10:24 am, Mike Treseler <mtrese...@gmail.com> wrote:
> benn wrote:
> > I have a 25Mhz clock that I wish to divide down to around 1.5Mhz..
>
> I would use a larger counter and a larger increment constant.
> Read up on phase accumulators.
>
> -- Mike Treseler
If the OP only wanted "around" 1.5 MHz, the code posted
should work fine. What you need to avoid is gating the
outputs of the counter. Using any single bit of a
counter will not have glitches. If you need a function
of the counter bits, the best bet is to register
the function with the input clock and define the function
accordingly if the extra clock of latency matters.
For example if you wnated to divide your clock by 18 but
have a 50% duty cycle, you could not just use the MSB
of the counter. Your logic would necessarily be a function
of more than one bit (unless you use non-binary coding or
two counters). In that case you would want to run the
combinatorial function through another flip-flop before
using it as a clock.
By the way, I'm surprised that Mike didn't give his usual
spiel about not using multiple clocks and just creating a
clock enable at 1.5 MHz instead...