J
Jon Elson
Guest
Hello, all,
I am trying to make a counter follow the value of a value sent from another
device. The value coming in is a bidirectional counter that can rollover
in either direction. The value is sampled so it is not necessarily
monotonic, but should not change greatly between samples.
I want to either increment or decrement the counter in my VHDL module
so it tracks the value coming in, and it always needs to go the "shortest"
way around the counter. I got it working on the rollover from -1 to 0
both ways, but then was confounded that it went the "wrong way" at the
half-rollover, from 011111 to 100000, for instance.
It seems like there must be a proper way to treat this so it can be done
with a simple less-than or greater-than comparison, without having to
compare the high two bits with a bunch of special case ors.
Anybody know what I'm mising here?
Thanks much,
Jon
I am trying to make a counter follow the value of a value sent from another
device. The value coming in is a bidirectional counter that can rollover
in either direction. The value is sampled so it is not necessarily
monotonic, but should not change greatly between samples.
I want to either increment or decrement the counter in my VHDL module
so it tracks the value coming in, and it always needs to go the "shortest"
way around the counter. I got it working on the rollover from -1 to 0
both ways, but then was confounded that it went the "wrong way" at the
half-rollover, from 011111 to 100000, for instance.
It seems like there must be a proper way to treat this so it can be done
with a simple less-than or greater-than comparison, without having to
compare the high two bits with a bunch of special case ors.
Anybody know what I'm mising here?
Thanks much,
Jon