VHDL Questions and Answers – Procedures – 1

«
»

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

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

Answer: a
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.
advertisement

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
View Answer

Answer: c
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?
a)

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

b)

advertisement
    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;
View Answer
Answer: b
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.
a) True
b) False
View Answer

Answer: a
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.
advertisement

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
View Answer

Answer: d
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.
a) WAIT
b) IF
c) RETURN
d) CASE
View Answer

Answer: c
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.
a) True
b) False
View Answer

Answer: a
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?
a) SIGNAL
b) CONSTANT
c) VARIABLE
d) SIGNAL or VARIABLE
View Answer

Answer: b
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.
advertisement

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

Answer: a
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?
a) INTEGER
b) CONSTANT
c) VARIABLE
d) SIGNAL
View Answer

Answer: c
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.

advertisement
advertisement
advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn