250+ TOP MCQs on Type Kind and Range Kind Attributes and Answers

This set of VHDL Multiple Choice Questions & Answers (MCQs) on “Type Kind and Range Kind Attributes”.

1. Which of the following is only a predefined type kind attribute?
a) ‘TYPE
b) ‘BASE
c) ‘RANGE
d) ‘RIGHT
Answer: b
Clarification: Type attributes return values of a kind type. There is only one type attribute which is T’BASE where T is any object. T’BASE will return the base type of object T. This object can be single, variable or constant.

2. T’BASE attribute can be used with another attribute only.
a) True
b) False
Answer: a
Clarification: T’BASE attribute returns the base type of a type or subtype. It can be used as the prefix to another attribute. It is available for all types and can’t be used independently. It must have a value kind or function kind attribute attached to it.

3. What will x’BASE and y’BASE return in the code given below?

TYPE color IS (red, blue, green, yellow, brown)
SUBTYPE color_gun IS color RANGE red TO green
VARIABLE x : color;
VARIABLE y : color_gun;

a) color, color_gun
b) color_gun, color
c) color, color
d) red, color
Answer: c
Clarification: As specified before, ‘BASE attribute will return the base type of any type or subtype. Here x is of the type color so x’BASE will return color. Similarly, y’BASE is of type color_gun which is a subtype with its base type color. So, y’BASE will also return color.

4. What will be the value of a in the statements given below?

TYPE color IS (red, green, blue, yellow, brown, black);
VARIABLE a : color;
a := color’BASE’RIGHT;

a) red
b) color
c) green
d) black
Answer: d
Clarification: Since ‘BASE attribute can’t be used independently, here it is used in conjunction with ‘RIGHT attribute. So, first of all color’BASE will return type color and then the ‘RIGHT attribute will return the rightmost value in the specified type. So, a will be assigned with black.

5. How many predefined attributes are there which are range kind attributes?
a) 1
b) 2
c) 3
d) 4
Answer: b
Clarification: There are two predefined attributes in VHDL which return a value kind of range. These two attributes are called Range kind attributes. The predefined range kind attributes are a’RANGE and a’REVERSE_RANGE.

6. The object of a range kind attribute can be __________
a) Any signal, variable or constant
b) An array
c) A constrained array
d) An unconstrained array
Answer: c
Clarification: Range kind attributes works only on constrained array types. The arrays which have defined bounds are called constrained array types. These attributes return the range of the given array.

7. Which of the following is the most appropriate use of range kind attributes?
a) In implementing CASE
b) In implementing LOOP
c) In implementing IF
d) In implementing ASSERT
Answer: b
Clarification: Since range kind attributes return a range of an array. This range can be used in defining the LOOP structure. For loop needs a counter which needs a range like 1 TO n. This range can be provided by the range kind attribute.

8. What will be the value of array16’RANGE and array16’REVERSE_RANGE, if the array16 is an object defined as below?

TYPE array16 IS ARRAY(15 DOWNTO 0) OF BIT

a) 15 DOWNTO 0, 0 TO 15
b) 0 TO 15, 15 DOWNTO 0
c) 0 TO 15, 0 TO 15
d) 15 DOWNTO 0, 15 DOWNTO 0
Answer: a
Clarification: ‘RANGE attribute will just give the range of array to which it is attached to. In this case, the range of array16 is 15 DOWNTO 0. The reverse range will just give the range in reverse order, which will be 0 TO 15.

9. Which of the following is a new predefined attribute in VHDL 93?
a) T’BASE
b) T’RANGE
c) T’EVENT
d) T’ASCENDING
Answer: d
Clarification: T’ASCEDING is defined in the VHDL-93 which returns a value of BOOLEAN type. It returns true if a constrained array has range defined in ascending order. Otherwise, if the range is defined like 15 DOWNTO 0 then it will return false.

10. Which of the following attribute is not synthesizable?
a) ‘RANGE
b) ‘EVENT
c) ‘BASE
d) ‘REVERSE_RANGE
Answer: c
Clarification: Since ‘BASE requires another attribute to use it. It is not supported by the logic synthesis tools. Only predefined attributes which are synthesizable are ‘RANGE, ‘REVERSE_RANGE, ‘LENGTH, ‘EVENT, ‘LEFT, ‘RIGHT, ‘HIGH, ‘LOW, LAST_VALUE and ‘STABLE.