This set of VHDL MCQs focuses on “Case Statement – 2”.
1. If one wants to perform no action, when any condition is true, then which of the following keyword can be used?
a) NO OPERATION;
Explanation: A NULL statement is generally used in CASE statement. The system will ignore the null statement and proceed to the next statement. This statement is used to explicitly state that no action is to be performed when a condition is true. Generally, this can be used in the OTHERS part of the CASE block.
2. It is not possible to use range with _________ types.
Explanation: The range used in the choices must be a discrete range. We can use the range in every data type but not with vector types. For example, if we write WHEN 000 TO 010 THEN, it will be an illegal statement. This is not synthesizable and will get an error as well.
3. The CASE statement in VHDL is similar to _________ in C.
b) If else
Explanation: In traditional programming languages like C, a Switch statement is used which is similar to the CASE statement of VHDL. In Switch, like CASE, one value from multiple possible values is chosen and the respective code is executed.
4. Which of the following operators can’t be used in the choices of a CASE?
d) Every type of operators can be used
Explanation: The choices can’t include a Relational operator in it such as less than or greater than operators. Use of these operators can result in overlapping of conditions which is not allowed in the CASE statement.
5. It is possible to use a CASE statement without OTHERS.
Explanation: The OTHERS clause is used to cover all the remaining choices. In case, when one is sure that no choice is remaining, then the OTHERS clause has no use. Then the OTHERS clause is of no use.
6. What is the main use of a CASE statement?
a) To design multiplexers
b) To design Comparators
c) To design Flip flop
d) To design state machines
Explanation: CASE is basically used in the design of state machines. Since there are various combinations of present state and next states due to which there are various choices to select from. That’s why CASE is used in the modeling of state machines.
7. Which of the following is most complex?
a) IF THEN ELSE
b) Nested IF THEN ELSE
Explanation: The nested IF ELSE statement is most complex statement. Since it needs to define If again and again inside another ELSE statement. This is the equivalent of ELSIF clause but is more complex. Using ELSIF is easier than using nested IF ELSE.
8. Which of the following is not a legal statement used Ii CASE?
a) WHEN 1 =>
b) WHEN 1 TO 3 =>
c) WHEN 1|3 =>
d) WHEN 1 THEN
Explanation: The CASE statement can either use a single value or a discrete range followed by the => operator. Apart from this, | is called the or operator which means there are two values of choices are used. In option d THEN is used instead of => which is illegal.
9. CASE is more efficient than ELSIF.
Explanation: Since CASE uses a single block to define multiple choices and there is no overlapping between two choices. The overlapping is possible in case of ELSIF. Therefore, the CASE statement is more efficient and less complex than ELSIF clause.
Sanfoundry Global Education & Learning Series – VHDL.
To practice MCQs on all areas of VHDL, here is complete set of 1000+ Multiple Choice Questions and Answers.