Procedures

VHDL

This set of VHDL Multiple Choice Questions & Answers (MCQs) focuses on “Procedures”.

1. Procedures are invoked as _________
a) Statements
b) Expressions
c) Values
d) Assignments

2. Procedures are useful when _________
a) Functions are not synthesizable
b) Signals are needed to be declare
c) Multiple values are needed as a result
d) Architecture can’t contain some statement

3. Which of the following is correct syntax for procedure body?
a)

    PROCEDURE procedure_name (parameter_list) IS
    BEGIN
    declarations;
    sequential_statements;
    END PROCEDURE;

b)

    PROCEDURE procedure_name (parameter_list) IS
    declarations;
    BEGIN
    sequential_statements;
    END procedure_name;

c)

    PROCEDURE procedure_name (parameter_list) IS
    declarations;
    BEGIN
    sequential_statements;
    concureent_statements;
    END PROCEDURE;

d)

    PROCEDURE procedure_name (parameter_list) IS
    declarations;
    BEGIN
    sequential_statements;
    concurrent_statements;
    END procedure_name;

4. Procedure doesn’t have a return type.
a) True
b) False

5. Which of the following could be the objects in the parameter list of a procedure?
a) CONSTANTS, VARIABLES
b) VARIABLES, SIGNALS
c) CONSTANTS, SIGNALS
d) CONSTANT, SIGNALS, VARIABLES

6. A procedure can’t contain a _______ statement.
a) WAIT
b) IF
c) RETURN
d) CASE

7. The parameter of a procedure can have any of the three modes.
a) True
b) False

8. Which of the following is the default class of any parameter with its mode as IN?
a) SIGNAL
b) CONSTANT
c) VARIABLE
d) SIGNAL or VARIABLE

9. Which of the following is the default mode of a parameter of procedure?
a) IN
b) OUT
c) INOUT
d) IN or INOUT

10. It is given that the mode of a parameter is OUT mode but its class is not specified by the user. To which class does it belong?
a) INTEGER
b) CONSTANT
c) VARIABLE
d) SIGNAL

11. Which of the following is not similar in both functions as well as procedures?
a) One can’t declare signals in functions as well as procedures
b) One can’t declare components in functions and procedures
c) In both, the WAIT statement is not synthesizable
d) Both can be declared inside a package

12. The mode and class of the following parameters are respectively ________

my_procedure( SIGNAL a : IN INTEGER; b : OUT INTEGER; c : BIT);

a) IN, SIGNAL; OUT, SIGNAL; IN, CONSTANT
b) IN, SIGNAL; OUT, CONSTANT; IN, VARIABLE
c) IN, SIGNAL; OUT, VARIABLE; IN, CONSTANT
d) IN, SIGNAL; OUT, CONSTANT; OUT, CONSTANT

13. Which of the following is true about both functions and procedures?
a) WAIT statement can’t be used
b) When declared in a package, both require package body
c) SIGNALs can’t be declared
d) RETURN is used in both

14. A user is encountering some error with his design, among which of the following the debugging must be easy?
a) In a code containing no functions or procedures
b) In a code containing functions but no procedures
c) In a code containing procedures but no functions
d) In a code containing both functions as well as procedures

15. A procedure is called concurrently. It will execute when ________
a) Any of its parameters change
b) Any of its OUT parameters change
c) Any of its IN parameters change
d) Any of its IN or INOUT parameter change

16. In which of the following cases, the procedure can’t contain WAIT statement?
a) When called from inside a process
b) When called from inside a process with a sensitivity list
c) When called from architecture
d) When called from a LOOP statement

17. A procedure can have a label in front of it.
a) True
b) False

18. In which of the following case, the code will not be synthesizable?
a) Code containing a WAIT statement inside a process
b) Code containing a WAIT statement inside a procedure
c) Code containing a RETURN statement inside a function
d) Code containing a CASE statement inside a function

19. Which of the following may be specified by the code given?

TYPE op_code is ( ADD, SUB, MUL, DIV, LT, LE, EQ );
PROCEDURE first_unit ( A, B : in integer; op : in op_code;
Z : out integer; ZCOMP : out boolean ) is
BEGIN
CASE op IS
WHEN ADD => Z := A + B;
WHEN SUB => Z := A - B;
WHEN MUL => Z := A * B;
WHEN DIV => Z := A / B;
WHEN LT =&gt; ZCOMP := A < B;
WHEN LE =&gt; ZCOMP := A <= B;
WHEN EQ =&gt; ZCOMP := A = B;
WHEN others =&gt; Z := Z;
END case;
END first_unit;

a) CPU
b) CU
c) ALU
d) Memory

20. How many types of the output are returned by the code given?

TYPE op_code is ( ADD, SUB, MUL, DIV, LT, LE, EQ );
PROCEDURE first_unit ( A, B : in integer; op : in op_code;
Z : out integer; ZCOMP : out boolean ) is
BEGIN
CASE op IS
WHEN ADD =&gt; Z := A + B;
WHEN SUB =&gt; Z := A - B;
WHEN MUL =&gt; Z := A * B;
WHEN DIV =&gt; Z := A / B;
WHEN LT =&gt; ZCOMP := A < B;
WHEN LE =&gt; ZCOMP := A <= B;
WHEN EQ =&gt; ZCOMP := A = B;
WHEN others =&gt; Z := Z;
END case;
END first_unit;

a) 0
b) 1
c) 2
d) 3

Leave a Reply

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