This set of VHDL Questions and Answers for Entrance exams focuses 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
Explanation: Until the data object is not specified, the corresponding must be considered as a constant. In the above function, a is specified as an 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 …..;
Explanation: 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
Explanation: 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?
Explanation: 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.
Explanation: 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
Explanation: 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 a multiple driver signals without a resolution function.
Explanation: 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
Explanation: 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?
Explanation: 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?
Explanation: Though the array is unconstrained, but the 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 an parameter must be of length two.
Sanfoundry Global Education & Learning Series – VHDL.
To practice all areas of VHDL for Entrance exams, here is complete set of 1000+ Multiple Choice Questions and Answers.