Re: Continous assign statement in clock: is it safe?
Paul Uiterlinden wrote:
> I have a general question: is it safe to have a continuous assign
> statement in a clock line, or does this introduce a race condition?
It can certainly introduce a race condition. Actually, to be correct,
the design contains a race condition, and putting a continuous assign
in a clock path may cause it to be exposed, i.e. produce a different
result by changing the order that changes occur. In general, putting
a continuous assignment in a clock path may delay the output to a later
point in the same time slice.
> A certain simulation (which has an assignment in a clock line) passes
in
> ModelSim, but fails in ncsim (only when delay_mode is set to unit, as
I
> found out later).
Different results in different simulators indicates either a bug in one
of them, or a race condition in your design.
> Below is some code that I created to reproduce the error. Whatever I
try
> though, q1, q2 and q3 correctly clock in the data from before the
rising
> clock edge, so I'm not quite sure whether the assign im the clock is
a
> prolem or not.
Since your sample code uses nonblocking assignments, which introduce a
delay into the data path that is guaranteed to be greater than any
number
of zero-delay continuous assignments in series, it should not have any
races between clock and data.
Presumably your actual design is different from this sample code in
some way.
|