A
Andy
Guest
On May 1, 8:11 pm, glen herrmannsfeldt <g...@ugcs.caltech.edu> wrote:
turn off state machine optimization, or invoke other "safe" state
machine synthesis settings. One of the optimizations most any
synthesizer worth its salt will do is remove "unreachable" states
(those states that do not have a coded assignment or path to them.)
Thus since "others" is not directly reachable, it gets optimized out,
along with anything it was doing.
There are multiple ways of dealing with this, most depend either on
invoking synthesis tool settings or turning off state machine
optimizations and manually handling it yourself in the RTL (such as
with a "when others". Be careful though; some of the simplest to code
methods result in the worst utilization and performance.
However, it is best to handle the root of the problem, which is an
improperly synchronized asynchronous input.
The term for this problem is not "race condition" it is an "improper
parallel synchronizer", or a circuit that clocks the same
asynchronous input into more than one register in parallel.
A "race condition" is when proper operation requires that one
combinatorial path must be faster than another.
Andy
Including a "when others => state <= reset"; will not help unless youTim Wescott <t...@seemywebsite.com> wrote:
On Wed, 02 May 2012 00:46:56 +0200, Frank Buss wrote:
glen herrmannsfeldt wrote:
Frank Buss <f...@frank-buss.de> wrote:
(snip)
But you should latch the rx input, to avoid metastability problems. I
don't know how to do this in Verilog, something like declare another
reg with the name "rx", rename the raw input signal and copy it on
rising clock edge to "rx".
Can you explain the problem that you are considering?
(snip)
Not that slow logic can't have metastability problems,
but in this case I wouldn't expect it.
My experience differs: I've used my simple UART receiver in a design
with 115,200 baud, and without the buffer, the state machine halted
(going to an invalid state, as I debugged with an "other" case branch,
which was logically impossible) once every some hour.
OK, I suppose I could have looked at the actual logic before writing.
Yes, if one isn't careful with a state machine, it can have
metastability problems even with a slow clock.
There is also that Quartus likes to rearrange state machines logic,
such that it isn't like it is written. Some years ago, I found a
bug in Quartus where it converted to a one-hot state machine even
though I was using the state value in the design. (It had four
states, and as written two state bits. Quartus converted to one-hot
and gave two of the four as state bits.)
There was lots of
high-speed logic behind the receiver and I've used only the classic
timing analyzer of an old version of Quartus, so maybe in simpler
designs, and with proper timing constraints for the rx signal, there
would be no problem.
But it is good design practice to buffer just any signal, which is fed
asynchronously to the FPGA, then you don't have such problems, even if
you didn't calculate and define all timing constraints.
Yes, if the design is such that more than one FF latches the same
input, and can fail if different values are latched on the same
clock cycle.
It might be a good practice to have that "other" case statement feeding
a master reset or some other more sensible response to a bad state than
wedging the FPGA, too.
That seems to be the easy way to fix it.
Now, it is likely that one additional clock cycle won't affect much,
but one does have to consider that in terms of the overall logic.
-- glen
turn off state machine optimization, or invoke other "safe" state
machine synthesis settings. One of the optimizations most any
synthesizer worth its salt will do is remove "unreachable" states
(those states that do not have a coded assignment or path to them.)
Thus since "others" is not directly reachable, it gets optimized out,
along with anything it was doing.
There are multiple ways of dealing with this, most depend either on
invoking synthesis tool settings or turning off state machine
optimizations and manually handling it yourself in the RTL (such as
with a "when others". Be careful though; some of the simplest to code
methods result in the worst utilization and performance.
However, it is best to handle the root of the problem, which is an
improperly synchronized asynchronous input.
The term for this problem is not "race condition" it is an "improper
parallel synchronizer", or a circuit that clocks the same
asynchronous input into more than one register in parallel.
A "race condition" is when proper operation requires that one
combinatorial path must be faster than another.
Andy