VHDL Questions and Answers – Functions and Subprograms – 2

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

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

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

Answer: a
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.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

3. Functions are called using ______ no of ________ statement(s).
a) 1, If
b) 1, Assignment
c) 2, If
d) 2, Assignment
View Answer

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

4. Which of the following type can’t be a parameter of a function?
a) Signals
b) Constants
c) Files
d) Variables
View Answer

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

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

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

Answer: a
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 multiple driver signals without a resolution function.
a) True
b) False
View Answer

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

Answer: b
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?
a) 3
b) 2
c) 0
d) 1
View Answer

Answer: d
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?
a) 1
b) 2
c) 3
d) Infinite
View Answer

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

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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.