This set of VHDL Multiple Choice Questions & Answers (MCQs) focuses on “Procedures – 1”.
1. Procedures are invoked as _________
Explanation: Unlike functions, procedures are invoked as statement. Functions are always invoked as expressions as a part of assignment statement but procedures are directly called as statements only. No assignment operator is needed.
2. Procedures are useful when _________
a) Functions are not synthesizable
b) Signals are needed to be declare
c) Multiple values are needed as result
d) Architecture can’t contain some statement
Explanation: Procedures usually returns many values, which is not possible with the case of function. So, procedures are useful when there are multiple results coming from the procedure. Note that procedure can return single value as well.
3. Which of the following is correct syntax for procedure body?
PROCEDURE procedure_name (parameter_list) IS BEGIN declarations; sequential_statements; END PROCEDURE;
PROCEDURE procedure_name (parameter_list) IS declarations; BEGIN sequential_statements; END procedure_name;
PROCEDURE procedure_name (parameter_list) IS declarations; BEGIN sequential_statements; concureent_statements; END PROCEDURE;
PROCEDURE procedure_name (parameter_list) IS declarations; BEGIN sequential_statements; concurrent_statements; END procedure_name;
Explanation: The procedure definition is very similar to the function definition. It starts with the keyword PROCEDURE followed by the name of procedure and then the parameter list. Then local declarations are made within the procedure body, which are separated from the statements part by the keyword begin. Then the procedure body is ended by the keyword END followed by name of procedure.
4. Procedure doesn’t have a return type.
Explanation: Functions always have a return type which specifies the type of value which is returned by the function. But, procedures return multiple values; therefore, it is not possible to use a single return type. So, There is no return type for a procedure.
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
Explanation: A procedure may have any of three objects in its parameter list. A SIGNAL, CONSTANT as well as a VARIABLE can be used as a parameter to a procedure. In functions, only signals and constants can be parameters.
6. A procedure can’t contain a _______ statement.
Explanation: A procedure, unlike functions, may contain WAIT statement but it doesn’t include any return statement. The assignments made in the procedure are considered as the values which are needed to be returned to the main code.
7. The parameter of a procedure can have any of the three modes.
Explanation: A procedure can have any number of IN, OUT or INOUT parameters which can be signals, constants or variables. There is no restriction on the mode of the signal It may be any of the three modes which are IN, OUT or INOUT.
8. Which of the following is default class of any parameter with its mode as IN?
d) SIGNAL or VARIABLE
Explanation: The default class for any IN mode parameter is CONSTANT. It means that if no mode is specified the parameters of mode IN are interpreted as class CONSTANT.
9. Which of the following is the default mode of a parameter of procedure?
d) IN or INOUT
Explanation: If no mode is specified in the front of a parameter, then it is considered as an input signal or of a mode IN. So, The default mode for a parameter of a procedure is IN mode which is similar to the functions.
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 belongs?
Explanation: The CONSTANT is the default class for the parameters of mode IN only. For other parameters which have their mode either as OUT or as INOUT the default class is considered as VARIABLE class.
Sanfoundry Global Education & Learning Series – VHDL.
To practice all areas of VHDL, here is complete set of 1000+ Multiple Choice Questions and Answers.