250+ TOP MCQs on Functions and Subprograms – 2 and Answers

This set of VHDL Questions and Answers for Entrance exams on “Functions and Subprograms – 2”.

1. Refer to the function defined below, a and b have respectively following data objects.

FUNCTION my_func (SIGNAL a : STD_LOGIC_VECTOR; b : STD_LOGIC) RETURN BOOLEAN IS
…..;

a) Constant, Constant
b) Constant, Signal
c) Signal, Constant
d) Signal, Signal
Answer: c
Clarification: Until the data object is not specified, the corresponding must be considered as a constant. In the above function, a is specified as a signal but b is not specified therefore, b is taken as a constant. So, a is a signal as specified and b is a constant.

2. What should be the mode of signal a in the following function definition?

FUNCTION my_func (SIGNAL a : STD_LOGIC_VECTOR) RETURN INTEGER IS
…..;

a) IN
b) OUT
c) INOUT
d) BUFFER
Answer: a
Clarification: The default and only signal mode which is applicable to a parameter of the function is the IN mode. There is no need to specify the mode at the time of definition. It is obvious that the mode is taken as IN mode. No other mode can be used in the parameter of a function.

3. Functions are called using ______ no of ________ statement(s).
a) 1, If
b) 1, Assignment
c) 2, If
d) 2, Assignment
Answer: b
Clarification: The functions are called using a single assignment statement. A function is always invoked as an expression and therefore, it is called by using an assignment statement in which function appears on the right side of the assignment operator.

4. Which of the following type can’t be a parameter of a function?
a) Signals
b) Constants
c) Files
d) Variables
Answer: d
Clarification: Apart from signals and variables, the files can also be used as a parameter to a function. The only restriction is to use a variable in the parameter of the function. One may use signal of IN mode, any constants and files in the parameter list.

5. A component may be declared and instantiated inside a function.
a) True
b) False
Answer: b
Clarification: In the declaration part of a function, one may declare a variable. But the declaration of a signal and a constant is not allowed inside a function. The constant instantiation is a concurrent statement and a function consists of sequential statements. Therefore, it is not possible to declare and instantiate a component.

6. What is the use of resolution functions?
a) Return the value of a signal with multiple drivers
b) Resolve value of a constant with multiple drivers
c) Convert one data type into another
d) Convert one data object into another
Answer: a
Clarification: Resolution function is used to resolve the value of a signal when the signal is driven by multiple drivers. It returns the new value of the signal by resolving all the drivers to give a single new value.

7. It is not possible to use multiple driver signals without a resolution function.
a) True
b) False
Answer: a
Clarification: In VHDL, it is illegal to have a signal with multiple drivers without a resolution function attached to the signal. Most of the resolution functions are predefined in the packages provided by STD and IEEE. But, if there is no resolution function then we can’t assign multiple values to the signal.

8. A resolution function is invoked when ________
a) The signal is assigned multiple values
b) All the drivers has changed their value for once at least
c) Any of the driver changes its value
d) The signal is assigned a second value
Answer: b
Clarification: A resolution function is called whenever one of the drivers for the signal has an event occurred on it. The resolution function is then executed and it returns a single value from all the driver values, that value is the new value of the signal.

9. How many parameters are there in a resolution function?
a) 3
b) 2
c) 0
d) 1
Answer: d
Clarification: A resolution function has one parameter or argument and returns a single value. The parameter is of array(unconstrained) type having the values of all the drivers attached to the signal.

10. What would be the length of array used as a parameter to the resolution function which resolves the value of a signal having 2 drivers?
a) 1
b) 2
c) 3
d) Infinite
Answer: b
Clarification: Though the array is unconstrained, but when the number of drivers is known, then the length is limited to the same number. For example, if there are two drivers for a signal, then the array used as a parameter must be of length two.

VHDL for Entrance exams, .