KJ,
I don't think I agree. While >= 4 seems to produce similar results
to the bit comparison, what about >= 5? If I did my kmaps right -
yikes this is digging back some, decoding the general sense of >= 5
requires:
((Count(2) and Count(0)) or (Count(2) and Count(1))
OTOH, if I count up to 5 and think "=" rather than ">=", due to
properties of counters, I can decode just the bits that are 1
and the resulting logic is:
(Count(2) and Count(0)) ='1'.
For =5 or >=5 to do as good as decoding bits, you need a smart
compiler. OTOH, in a LUT based design, will I notice the
difference of 1 LUT pin? Probably not - unless I have alot
of counters.
Cheers,
Jim
I think I agree with KJ, but for different reasons. In many of my
designs, a counter typically indicates how long to remain in one state
of a FSM, or else is used to loop through a shortened (not a full
power of two) sequence, like pixel or line count in video. I've always
felt that decoding (n >= k) instead of (n=k) gives me more of a safety
net to get back more quickly to the restart state or get back into the
main loop in case I reach an unreachable state (defined for this
purpose as n > k). This might happen because I messed up some obscure
corner case in my multiple-interconnected-FSM control logic, in which
I freely admit I'm at fault. But it's been my experience that getting
your chassis hit with 20 kV from an ESD gun during product compliance
testing can do unusual things to your flops, which you should still
recover from ASAP. It seems to me that on the balance of probability,
if I include a "free" check (in the source code sense of free) for
unreachable states (e.g. NTSC_LINE_NUMBER >= 525 in preference to
NTSC_LINE_NUMBER=525) then I have a better chance of not getting stuck
forever when I go into the weeds.
There are a lot of cases where writing stuff in the source (like a
redundant 'when others' case in an otherwise fully covered case stmt
decoding an enumerated state type) has zero semantic meaning in VHDL.
In these cases, one can argue back and forth, and inconclusively, that
a tool ought to or ought not to take extra steps to take the hint to
cover unreachable states, but there's no clear, LRM-traceable
justification for this. But comparing against a counter in a power-of-
two modulus bit vector seems to give a pretty clear mandate to the
synthesizer.
Clearly this design style trick is nowhere near a rigorous proof of
recovery (not like a proper CTL model checking run, by any means), but
it helps. My next statement will probably offend the hard-core gate
bangers, but here goes: I'm too old to care about optimizing the last
p-term out of one comparison -- I tend to be more concerned with
correctness, recoverability and reliability. I'd much rather it never
locks up and recovers quickly when I fuzz test it.
- Kenn