VHDL Questions and Answers – Type Kind and Range Kind Attributes

«
»

This set of VHDL Multiple Choice Questions & Answers (MCQs) focuses 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
View Answer

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

2. T’BASE attribute can be used with another attribute only.
a) True
b) False
View Answer

Answer: a
Explanation: 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?

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

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

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

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

5. How many predefined attributes are there which are range kind attributes?
a) 1
b) 2
c) 3
d) 4
View Answer

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

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

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

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

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

Answer: d
Explanation: 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
View Answer

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

Sanfoundry Global Education & Learning Series – VHDL.

To practice all areas of VHDL, here is complete set of 1000+ Multiple Choice Questions and Answers.

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!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter