Post by Mike Treseler"If an engineer is willing to limit all modules
to a single always block, blocking assignments can be used
to correctly model, simulate and synthesize the desired logic."
I am willing.
In fact I prefer to describe all logic this way
Whoa! There's a little too much reading-between-lines
going on here, and a slightly worrying error in your
example (see the last two paragraphs of this post).
Let me begin by saying that I totally understand your
position, Mike: you want to write a software-like description
of functionality, with software-like variable update semantics,
and have the synth tool do whatever it takes to make hardware
out of that. Great stuff.
Note, though, that (if I'm not mistaken) you reached this
viewpoint based on a *VHDL* coding style. In VHDL, variables -
with their immediate-update semantics - simply cannot leak out
of a process; the language doesn't permit it. (Yes, I know about
shared variables; most synth tools won't handle them, which is
just as well. Let's put them to one side for the time being.)
So you write your sequential software-like process, doing all
your work with variables; and then, at the last possible moment,
you drive some of those variables' values out on to signals
so that they can flow out of the process and be used in other
processes, possibly in other module (entity) instances.
Signals have delayed update semantics that guarantee
race-free behaviour of multiple processes triggered by the
same clock, whether those two processes are in the same
module instance or in widely separated locations in the
module hierarchy.
So far, so good. What's more, you can very easily replicate
this VHDL coding style in Verilog clocked processes by....
- making BLOCKING assignment to variables declared locally
within the clocked process, ensuring that those variables
are not referenced by any other process;
- making NONBLOCKING assignment to variables declared outside
the process, which therefore can be referenced/read in other
processes.
Sadly, Cliff Cummings rejects this possibility out-of-hand
(see Example 24 on page 17 of the paper) without giving any
good reasoning. In this respect he is simply wrong. Provided
the variables that you write with blocking assignment are
strictly localised to the process, all is well.
Post by Mike Treseler"If an engineer is willing to limit all modules
to a single always block, blocking assignments can be used
to correctly model, simulate and synthesize the desired logic."
is also just plain wrong. If a variable written in a clocked
process by blocking assignment is read in ANY other process
clocked by the same clock, whether it's in the same module
or a different one, then there is a read/write simulation race.
[In fairness to Cliff, that was a throw-away line in the paper
and his ultimate conclusion is perfectly clear: in clocked
processes, use nonblocking assignment for all writes.]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It's this last consideration that leads me to believe that
there is an error in your Verilog example 'count_enable.v'.
The "update_port" block ought to make *nonblocking* assignments
to q_a, q_b, q_c, but you have written them using *blocking*
assignment. If those signals are read in any other process
clocked by (posedge clock) then there will be a read/write race
on them in simulation. I know that you intend there should be
no such process elsewhere in the same module, but it seems very
likely that there may be other modules in the design that have
processes triggered by the same clock. Synthesis, by contrast,
will reliably respect your design intent, because synthesis
infers logic from each process separately.
In your equivalent example in VHDL this problem does
not arise, because the ports q_a/q_b/q_c are signals
with their delayed (i.e. nonblocking) update semantics.
It's important to emulate this behaviour correctly when
migrating to Verilog.
--
Jonathan Bromley, Consultant
DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services
Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
***@MYCOMPANY.com
http://www.MYCOMPANY.com
The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.