VHDL Questions and Answers – Procedures – 2

This set of VHDL Questions and Answers for Aptitude test focuses on “Procedures – 2”.

1. Which of the following is not similar in both functions as well as procedures?
a) One can’t declare signals in functions as well as procedures
b) One can’t declare components in functions and procedures
c) In both, the WAIT statement is not synthesizable
d) Both can be declared inside a package
View Answer

Answer: a
Explanation: The signals can be declared inside a procedure which is not possible with functions. However, all other things are common in both functions and procedures. One can use WAIT statement inside a procedure but it not synthesizable and both can be declared inside a package.

2. The mode and class of the following parameters are respectively ________

my_procedure( SIGNAL a : IN INTEGER; b : OUT INTEGER; c : BIT);

a) IN, SIGNAL; OUT, SIGNAL; IN, CONSTANT
b) IN, SIGNAL; OUT, CONSTANT; IN, VARIABLE
c) IN, SIGNAL; OUT, VARIABLE; IN, CONSTANT
d) IN, SIGNAL; OUT, CONSTANT; OUT, CONSTANT
View Answer

Answer: c
Explanation: The default mode for any parameter is IN mode. So, the mode of C is IN mode and those of other two are specified. The class of a is specified as SIGNAL. The parameter b is of OUT mode so it will be considered as a VARIABLE and c is considered as a CONSTANT.
advertisement
advertisement

3. Which of the following is true about both functions and procedures?
a) WAIT statement can’t be used
b) When declared in a package, both require package body
c) SIGNALs can’t be declared
d) RETURN is used in both
View Answer

Answer: b
Explanation: When function or procedure is placed in a package, then it is necessary to write the package body so that functions and procedures can be defined. However, WAIT can be used in procedures and same is true about signals. RETURN is not used in a procedure.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

4. A user is encountering some error with his design, among which of the following the debugging must be easy?
a) In a code containing no functions or procedures
b) In a code containing functions but no procedures
c) In a code containing procedures but no functions
d) In a code containing both functions as well as procedures
View Answer

Answer: b
Explanation: The debugging is easy with the use of functions. However, procedures also divide the code into small segments but there are some side effects with the procedures. For example, the change in value of a signal without being an argument of the procedure.

5. A procedure is called concurrently. It will execute when ________
a) Any of its parameters change
b) Any of its OUT parameters change
c) Any of its IN parameters change
d) Any of its IN or INOUT parameter change
View Answer

Answer: d
Explanation: If the procedure is called outside a process then it is considered as a concurrent call. In that case, the procedure call statement executes whenever any of its parameter change with the mode IN or INOUT. There is no execution if the OUT parameter is changed.
advertisement

6. In which of the following cases, the procedure can’t contain WAIT statement?
a) When called from inside a process
b) When called from inside a process with a sensitivity list
c) When called from architecture
d) When called from a LOOP statement
View Answer

Answer: b
Explanation: The WAIT statement can be used inside a procedure until it is called from a process containing a sensitivity list. Also, if the procedure is called from a function, then the use of WAIT statement is not possible.

7. A procedure can have a label in front of it.
a) True
b) False
View Answer

Answer: a
Explanation: In VHDL 93, the availability of labels in front of any special statement is made available. One may use an optional label in front of a procedure call or procedure definition to make it more readable. This is possible in VHDL.
advertisement

8. In which of the following case, the code will not be synthesizable?
a) Code containing a WAIT statement inside a process
b) Code containing a WAIT statement inside a procedure
c) Code containing a RETURN statement inside a function
d) Code containing a CASE statement inside a function
View Answer

Answer: b
Explanation: The design is synthesizable if the procedure doesn’t have any WAIT statement in it. Also, a process can have wait statement until it doesn’t have a sensitivity list. Moreover, Function should have RETURN statement to be synthesizable.

9. Which of the following may be specified by the code given?

TYPE op_code is ( ADD, SUB, MUL, DIV, LT, LE, EQ );
PROCEDURE first_unit ( A, B : in integer; op : in op_code;
Z : out integer; ZCOMP : out boolean ) is
BEGIN
CASE op IS
WHEN ADD => Z := A + B;
WHEN SUB => Z := A - B;
WHEN MUL => Z := A * B;
WHEN DIV => Z := A / B;
WHEN LT =&gt; ZCOMP := A < B;
WHEN LE =&gt; ZCOMP := A <= B;
WHEN EQ =&gt; ZCOMP := A = B;
WHEN others =&gt; Z := Z;
END case;
END first_unit;

a) CPU
b) CU
c) ALU
d) Memory
View Answer

Answer: c
Explanation: It is clear from the code in which two parameters are showing inputs (A and B) on which different operations are being performed. Therefore, It is the case of ALU unit of the CPU.

10. How many types of the output are returned by the code given?

TYPE op_code is ( ADD, SUB, MUL, DIV, LT, LE, EQ );
PROCEDURE first_unit ( A, B : in integer; op : in op_code;
Z : out integer; ZCOMP : out boolean ) is
BEGIN
CASE op IS
WHEN ADD =&gt; Z := A + B;
WHEN SUB =&gt; Z := A - B;
WHEN MUL =&gt; Z := A * B;
WHEN DIV =&gt; Z := A / B;
WHEN LT =&gt; ZCOMP := A < B;
WHEN LE =&gt; ZCOMP := A <= B;
WHEN EQ =&gt; ZCOMP := A = B;
WHEN others =&gt; Z := Z;
END case;
END first_unit;

a) 0
b) 1
c) 2
d) 3
View Answer

Answer: c
Explanation: There are 2 types of the outputs. In the arithmetic operations the output is of INTEGER and for logical operations the output is logical or of BOOLEAN type which may be either true or false.

Sanfoundry Global Education & Learning Series – VHDL.

To practice all areas of VHDL for Aptitude test, 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.