Blocking Always with Sensitivity List

R

rejeesh

Guest
Hi,

I was wondering: what are the differences w.r.t Simulation and
Synthesis, if any between these two always blocks??

1.

always @(a)
begin
b = a;
c = b;
end

2.

always @(a)
begin
c = a;
end

My guess is that both are fine. This is a case where a task has to be
converted to an always block. The inputs of the task are put in the
sensitivity list, however the internal variables are not. (The task is
purely combinatorial and do NOT use any delay/edge construct. Adding b
to the sensitive list is going to make many simulation tools crib - an
infinite iterative loop. I just want to make sure both are right and
produce the same results in all simulation/synthesis tools.

Thanks,
Rejeesh
 
rejeesh@tenesix.com (rejeesh) wrote in message news:<4b4a9b59.0406201712.2ce562db@posting.google.com>...
Adding b
to the sensitive list is going to make many simulation tools crib - an
infinite iterative loop.
I assume that you are concerned that writing to b would cause the
always block to wake itself up again, leading to your infinite loop.

This is a misunderstanding of how always blocks work. If an always
block is writing to b, then it is not waiting at the event control,
so the write to b has no effect on it. There is only one process for
the always block, and it is executing at one place. When it executes
back to the point of the event control, then it would start waiting
on b again. But by then it is finished changing b. Since b does not
change after the process starts waiting on it, it won't be woken up
on b.

Now if you are inlining this code into several always blocks, and they
all share the same intermediate variable b, then you would have a
problem. These are independent processes, and they can wake each other
up. If the always block did a nonblocking assignment to b, then it
could also wake itself up. This is because the value of b would not be
updated until the end of the time slice, by which time the always block
process would be waiting at the event control for b to happen.

It is still probably best from a simulation standpoint to leave the
local intermediate variables out of the "sensitivity list". I just
wanted to point out that it isn't necessarily a problem if you don't.
 

Welcome to EDABoard.com

Sponsor

Back
Top