This set of VHDL Multiple Choice Questions & Answers (MCQs) on “Value Kind Attributes”.
1. What does a value kind attribute return?
a) A single value
b) A signal
c) A function
d) A type
Answer: a
Clarification: Value kind attributes to return a single value. This value can give information about anything like an array, a block or a type. This can be used to return the length of an array or some related information.
2. Value attributes are classified into _______ subclasses.
a) 1
b) 2
c) 3
d) 4
Answer: c
Clarification: Value kind attributes are further broken down into three subclasses. This classification is done on the basis of the information they provide. For example, if an attribute is providing the information about an array then it is called Value array attribute.
3. Which of the following is not a category of Value kind attribute?
a) Value type attributes
b) Value array attributes
c) Value block attributes
d) Value function attributes
Answer: d
Clarification: The Value kind attributes are divided into three categories which are Value type attributes (which returns the value of a type), Value array attributes (information about array) and Value Block attributes (information about block).
4. If T is an object, then T’LEFT attribute returns ________
a) Upper bound of object
b) Leftmost value of object
c) Leftmost value of an array
d) Lower bound of the object
Answer: b
Clarification: T’LEFT is an attribute which returns the left bound or the leftmost value of the object T. This object can be any predefined type, array or any block as well. Similarly, T’RIGHT returns the rightmost value of array.
5. What does the attribute T’HIGH returns?
a) Upper bound of the object
b) Lower bound of the object
c) Highest value of the object
d) Rightmost value of the object
Answer: a
Clarification: T’HIGH is another value kind attribute which gives information about the type, array or block. It returns the upper bound of the type or array. In a similar manner T’LOW will returns the lower bound of the object T.
6. What will be the value of x and y?
TYPE my_type IS ARRAY (15 DOWNTO 0) OF BIT; … VARIABLE x, y : INTEGER; x := my_type’LEFT; y := my_type’HIGH; …
a) 0, 0
b) 0, 15
c) 15, 0
d)15, 15
Answer: d
Clarification: Since the attribute used is for the type, so it is value type attribute. ‘LEFT will give the left bound of the type or the leftmost value which is 15. Here my_type is described as a data type which has bound 0 to 15. So, HIGH will return the upper bound which is 15. So, x and y both will be 15 in this case.
7. What will be the value of x and y in the code given below?
TYPE bit_range IS ARRAY (0 TO 15) OF BIT; VARIABLE x, y : INTEGER; x := bit_range’RIGHT; y := bit_range’LOW; …
a) 0, 0
b) 0, 15
c) 15, 0
d) 15, 15
Answer: c
Clarification: T’RIGHT returns the rightmost value of any type. So, x will be 15. Similarly, T’LOW retruns the lower bound of the same. Here the bounds of the array are 0 and 15 as lower and upper bound. So, the resulting value of y will be 0.
8. What will be the type of value returned by the attribute T’LENGTH?
a) BIT
b) INTEGER
c) STD_LOGIC
d) BOOLEAN
