OK. Generally I don't like that variables change their meaning (because
they've been assigned to and update immediately) when they are assigned to
in several places in a long hunk-o-code with all kinds of paths through it.
Of course nobody writes such code
My bigger gripe is the lack of history
though.
Assertions don't tell you the root cause of what is wrong, just that a
particular bad something has occurred. Many times one can tell simply by
looking at what assertion failed and quickly deduce the root cause of the
problem, but many times it's not so simple to see what incorrect logic led
to the assertion having failed. In any case, the information that one needs
to debug the failed condition lies in the past (i.e. the simulation history
up to that point) not in the future so stepping through code or really
anything other than analysis of the prior state of (possibly) everything in
the design and testbench is required. Signals, variables and log/trace
output files are the evidence that you use for that forensic analysis.
Things that hinder that analysis typically slows down debug. Wave windows
assist in the forensics as a good analytical tool, for investigating the
scene of the crime (i.e. the failed assert). The two are complementary in
that regard.....having said that though, I realize that the beginner will be
debugging using waves alone (until they recognize the value of asserting
darn near everything that they can instead).
I didn't mean to imply that if, after initial design creation, the
realization sets in that some lower level entity has a 'need to know' about
something and that the interface to that entity couldn't simply be changed
to include that new signal and now the previously hidden info is known. No
need to go global.
The downside to that is that the state machine code itself gets bloated and
hard to maintain because you end up with lots of signal assignments
intertwined with the various 'case' and 'if' branches typical of a state
machine. In any case, a state variable is just another signal and is
deserving of no more or less respect than any other signal or variable in
the design. Changes to the code on any signal will have repercussions
downstream, not just changes to state variables.
Maintenance has more to do with readability then it does with dogma about
scoping rules that apply to 'special' signals like state variables that
inexplicitly do not apply to other signals.
A multiple screen long state machine filled with signal assignments in the
various branches of the state machine code is a much poorer design (in my
opinion), since it requires paging back and forth to understand the various
reasons why something can be set or reset. I'd much rather have a 1000 line
file where the logic defining any given signal can be viewed and understood
within a single screen than having to wade through that same file searching
for all the possible places that the signal might get assigned.
Words of wisdom
KJ