VHDL Questions and Answers – Case Statement – 2

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;
b) NOP;
c) NULL;
d) NEXT;
View Answer

Answer: c
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.
a) Integer
b) BIT_VECTOR
c) STD_LOGIC
d) Natural
View Answer

Answer: b
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.
a) Switch
b) If else
c) Pointers
d) Arrays
View Answer

Answer: a
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.
advertisement
advertisement

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
View Answer

Answer: c
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.
a) True
b) False
View Answer

Answer: a
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.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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
View Answer

Answer: d
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
c) ELSIF
d) CASE
View Answer

Answer: b
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.
advertisement

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
View Answer

Answer: d
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.
a) True
b) False
View Answer

Answer: a
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.
advertisement

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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.