I use VHDL for a few months and I sometimes build that kind of process with non-nested if statements when I want some conditions to be evaluated sequentially :
process(clk)
begin
if rising_edge(clk) then
if CONDITION1 then
(some instructions)
end if;
if CONDITION2 then
(some instructions)
end if;
end if;
end process;
It seems to work well in both simulation and synthesis, but I hardly ever see that kind of structure when looking for examples on the web. I had doubts about the sequential execution of those statements but the IEEE Standard VHDL Language Reference Manual Std 1076-2008 states :
Sequential statements are used to define algorithms for the execution of a subprogram or process; they execute in the order in which they appear.
And the if
statement is in the list of sequential statements.
Why can't I find more examples of this? Is this a bad practice?
if
with either anelsif
or anelse
. Why do I recommend not doing it? Because there is a chance that your synthesiser thinks that there are circumstances where neitherCONDITION1
orCONDITION2
is true so it puts latches in, even if they are not necessary. (And if you end up with anelsif
, to avoid latches, don't you also need anelse
or a default assignment.) - Matthew TaylorCONDITION1
could be sync enable andCONDITION2
sync reset, and it allows you to chose which signals have enable and reset separately.if..else
forces all signals to be connected to both. - Tricky