The 2 if/else
statements behave the same way; the first condition to be true has the highest priority. Once a condition evaluates to true, all the following else
clauses are ignored. Therefore, z <= 1
if both wire1_is_enabled
and wire2_is_enabled
are true. This is easy to prove to yourself with a simple simulation.
This is not a poor coding habit. This situation is common in Verilog. When you say programming
, perhaps you are thinking of software languages. Keep in mind that these are hardware signals instead of software variables.
CLICK HERE to find out more related problems solutions.