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?
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?
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
CASE expression IS WHEN choice_1 <= Sequential_statements; WHEN choice_2 <= Sequential_statements; …. WHEN OTHERS <= Sequential_statements; END CASE;
CASE expression IS WHEN choice_1 => Sequential_statements; WHEN choice_2 => Sequential_statements; …. WHEN OTHERS => Sequential_statements; END CASE;
CASE expression IS IF choice_1 <= Sequential_statements; ELSIF choice_2 <= Sequential_statements; …. ELSIF OTHERS <= Sequential_statements; END CASE;
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
6. The expression used in a keyword must be of a Boolean type.
7. What should be the type of choices in the CASE statement?
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;
9. It is possible to use a range in the choice part of the CASE statement.