Weng said:
Rick,
"If you are detecting the state of a signal and hold the value of
the signal to its same value, isn't that a latch???"
Answer is no.
For example, there is state machine that has 10 states. And designer
uses 2 parts of pattern to design a state machine, one is for
NextState, another for registers;
Now I often met the situations: where I forgot to assign a value to
NextState. Then compiler claims it will establish a latch.
I think it can do another way:
For a missing assignment of NextState, it can "add an NextState
assignment statement" at the missing place with current state value. So
NextState doesn't have to become a latch. Usually latch is more costly
than combinatorial logic for NextState as compiler knows so that it
often gives warning: a latch is established.
But that is what you don't seem to understand. The compiler has no way
of knowing the "current" state of NextState. Your case statement is
looking at CurState not NextState! Unless you knew something more about
NextState than is apparent in the code, (which you, the designer, will
know) there is no way to "keep" the current value other than to use a
latch.
I will say this once very clearly and then I want you to stop posting
about it until you understand. There is no way for the compiler to know
what state you want assigned to NextState based on the value of
CurState. YOU know what you want, but the tool does not know that
CurState and NextState are related by anything other than the code you
write. If you don't give the code a default, the tool can't know what
you want.
If you want NextState to default to the value of CurState, then you
should use a default assignment... NextState <= CurState; Then if you
omit an assignment, the tool will know what you want.
Actually a latch reference usually means a code error, not the desire
of programmers.
I only read one case where a latch is used for Asynchronous FIFO. I
never see it elsewhere except compiler treats any missing assignment of
NextState as a latch or a register without an initial value when reset
is asserted.
If you don't want a latch, then don't specify one. A missing assignment
specifies a latch.
--
Rick "rickman" Collins
(e-mail address removed)
Ignore the reply address. To email me use the above address with the XY
removed.
Arius - A Signal Processing Solutions Company
Specializing in DSP and FPGA design URL
http://www.arius.com
4 King Ave 301-682-7772 Voice
Frederick, MD 21701-3110 301-682-7666 FAX