Case Statement

VHDL

This set of VHDL Multiple Choice Questions & Answers (MCQs) focuses on “Case Statement – 1”.

1. What is the problem with IF statement?
a) Overlapping of conditions
b) No default value
c) The condition can be Boolean only
d) Restriction on number of ELSE statement

2. In which of the following statements, all the branches are equal in priority?
a) IF
b) CASE
c) WAIT
d) LOOP

3. In case any of the conditions is not covered by ‘cases’ in the case statement, which of the following keyword can be used to cover all those conditions?
a) ELSE
b) ELSIF
c) REMAINING
d) OTHERS

4. CASE is a sequential statement, which is similar to _________ concurrent statement.
a) Concurrent assignment
b) PORT MAP
c) WHEN
d) THEN

5. Which of the following is correct syntax for CASE statement?
a)

    CASE expression IS
     WHEN choice_1 <=
     Sequential_statements;
     WHEN choice_2 <=
     Sequential_statements;
     ….
    WHEN OTHERS <=
    Sequential_statements;
    END CASE;

b)

    CASE expression IS
     WHEN choice_1 =>
     Sequential_statements;
     WHEN choice_2 =>
     Sequential_statements;
     ….
    WHEN OTHERS =>
    Sequential_statements;
    END CASE;

c)

    CASE expression IS
     IF choice_1 <=
     Sequential_statements;
     ELSIF choice_2 <=
     Sequential_statements;
     ….
    ELSIF OTHERS <=
    Sequential_statements;
    END CASE;

d)

    CASE expression IS
     IF choice_1 =>
     Sequential_statements;
     ELSIF choice_2 =>
     Sequential_statements;
     ….
    ELSIF OTHERS =>
    Sequential_statements;
    END CASE;

6. The expression used in a keyword must be of a Boolean type.
a) True
b) False

7. What will be the value of Z in the following code?

ENTITY case_1 IS
Port (a, b, c, y : IN INTEGER range 0 TO 31
           z              : OUT INTEGER range 0 TO 31)
ARCHITECTURE example OF case_1 IS
BEGIN
y <= 2;
a <= 4;
b <= 5;
c <=6;
PROCESS(a, b, c, y)
BEGIN
CASE y+1 IS
WHEN 1 =>
z <= a;
WHEN 2 =>
z <= b;
WHEN 3 =>
z <= c;
WHEN OTHERS =>
Z <= 0;
END CASE;
END PROCESS;
END example;

a) 2
b) 4
c) 5
d) 6

8. What should be the type of choices in the CASE statement?
a) Boolean
b) Integer
c) Same as expression
d) No restriction on the type

9. It is possible to use a range in the choice part of the CASE statement.
a) True
b) False

10. 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;

11. It is not possible to use range with _________ types.
a) Integer
b) BIT_VECTOR
c) STD_LOGIC
d) Natural

12. The CASE statement in VHDL is similar to _________ in C.
a) Switch
b) If else
c) Pointers
d) Arrays

13. 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

14. It is possible to use a CASE statement without OTHERS.
a) True
b) False

15. 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

16. Which of the following is most complex?
a) IF THEN ELSE
b) Nested IF THEN ELSE
c) ELSIF
d) CASE

17. 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

18. CASE is more efficient than ELSIF.
a) True
b) False

Leave a Reply

Your email address will not be published. Required fields are marked *