HDL & Verification
In combinational logic, how does a long if/else-if chain compare with a case statement whose conditions are mutually exclusive?
- AAn if/else-if chain implies priority on earlier conditions and tends to be deep and slow, while a case tends to become parallel selection
- BBoth styles always synthesize to exactly the same circuit
- Ccase cannot be synthesized; only if can
Show answer and explanation
Answer: A. An if/else-if chain implies priority on earlier conditions and tends to be deep and slow, while a case tends to become parallel selection
An if/else-if chain means "if the first condition holds take it, otherwise check the next", implying a priority circuit like a priority encoder, with one multiplexer per condition in series and long delay. A case selecting on mutually exclusive values tends to become a parallel structure like a single large multiplexer and is faster. Modern synthesis tools, however, often optimize either form.
- A. Correct. The difference is whether conditions have priority.
- B. Circuits can differ depending on priority.
- C. case is synthesizable too.