VHDL Questions and Answers Part-6

1. SIGNED and UNSIGNED data types are defined in which package?
a) std_logic_1164 package
b) std_logic_arith package
c) std_logic package
d) standard package

Answer: b
Explanation: SIGNED and UNSIGNED data types are defined in the std_logic_arith package of the IEEE library. These data types are mainly intended for arithmetic operations. This is why they are defined in the arithmetic package.

2. What is the correct method to declare a SIGNED type signal ‘x’?
a) SIGNAL x : IN SIGNED
b) SIGNAL x : IN SIGNED
c) SIGNAL x : IN SIGNED (7 DOWNTO 0)
d) SIGNAL x : IN SIGNED_VECTOR (7 DOWNTO 0)

Answer: c
Explanation: Unlike BIT and STD_LOGIC types; SIGNED and UNSIGNED follow the syntax similar to BIT_VECTOR and STD_LOGIC_VECTOR. Also, IN and OUT are just to specify the direction of signal.

3. An UNSIGNED type is always greater than zero.
a) True
b) False

Answer: a
Explanation: In SIGNED and UNSIGNED, SIGN word refers to the positive or negative sign of any number. UNSIGNED data type has no sign and therefore, it is always positive. Therefore, an UNSIGNED number will be always greater than zero.

4. Which of the following option is completely legal, given that a and b are two UNSIGNED type signals?
a) x <= a + b; y <= a – b;
b) x <= a OR b; y <= a AND b;
c) x <= a + b; y <= a OR b;
d) x <= a OR b; y <= a + b;

Answer: a
Explanation: SIGNED and UNSIGNED data types are intended for arithmetic operations mainly and using logical operators with these data types is illegal. Therefore, only option x <= a + b; y <= a – b; is completely legal. In all other options there are logical operations so those can’t be considered as legal.

5. if a and b are two STD_LOGIC_VECTOR input signals, then legal assignment for a and b is?
a) x <= a.b
b) x <= a OR b
c) x <= a + b
d) x <= a && b

Answer: b
Explanation: Unlike SIGNED and UNSIGNED, STD_LOGIC_VECTOR data type is used mainly for logical operations and we can’t use arithmetic operations with STD_LOGIC_VECTOR. Also, && is not the sign for any operation in VHDL, if you want to perform and operation, then you have to write AND not &&.

6. SIGNAL a : REAL; which of the following is illegal assignment for a?
a) a <= 1.8
b) a <= 1.0 E10
c) a <= 1.0 E-10
d) a <=1.0 ns

Answer: d
Explanation: Units nanosecond (ns) written after the number shows that it is of type TIME and VHDL doesn’t allow TIME type to be assigned to a real Signal. So option d is illegal.

7. What do we call the data type used for representing distance, current, voltage, time, etc?
a) Integer
b) Real
c) Physical
d) Imaginary

Answer: c
Explanation: Physical type is used for representing physical values such as time, voltage, etc. by using some base unit. Physical quantities are used in various digital systems and these are important for modelling such systems. Integer and Real are the data types for numbers and there is no data type called Imaginary.

8. RECORD in VHDL is similar to________ in C
a) Array
b) File
c) Pointer
d) Structure

Answer: d
Explanation: As in C, Structures are used to collect different data types under a common name. Similarly, RECORD type in VHDL is used for collecting different data types and objects in a single object.

9. What is the difference between SIGNAL and VARIABLE?
a) The value of SIGNAL never varies whereas VARIABLE can change its value
b) SIGNAL can be used for input or output whereas VARIABLE acts as intermediate signals
c) SIGNAL depends upon VARIABLE for various operations
d) SIGNAL is global and VARIABLE is local to the process in which it is declared

Answer: d
Explanation: SIGNALs are used to pass information between entities, they act as interconnection between different entities whereas VARIABLEs can be used in the process or subprogram in which it is declared. So, VARIABLEs are local to the block in which they are declared.

10. Access types are similar to _________ in traditional programming languages.
a) Pointers
b) Arrays
c) Structures
d) Files

Answer: a
Explanation: Access types are used to hold an address of some object which is quite similar to pointers in traditional programming languages. By using the address stored in Access data type, we can access another data objects similar to pointers.