Case Statement – 1 MCQ’s

Electronics & Communication Engineering VHDL

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

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

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

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

4. Which of the following is correct syntax for CASE statement?

    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;

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

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

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

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

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

Leave a Reply

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