This set of VHDL MCQs 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;
b) NOP;
c) NULL;
d) NEXT;
Answer: c
Clarification: 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.
a) Integer
b) BIT_VECTOR
c) STD_LOGIC
d) Natural
Answer: b
Clarification: 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.
a) Switch
b) If else
c) Pointers
d) Arrays
Answer: a
Clarification: 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?
a) Arithmetic
b) Logical
c) Relational
d) Every type of operators can be used
Answer: c
Clarification: 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.
a) True
b) False
Answer: a
Clarification: 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
Answer: d
Clarification: 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
c) ELSIF
d) CASE
Answer: b
Clarification: 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
