VHDL Programming

(C. Jardin) #1

Subprograms and Packages 141


Functions vect_to_intand int_to_st16must be declared ahead of
function addto compile correctly. All functions must be declared before
they are used to compile correctly.

SUMMARY


In this chapter, we discussed the different kinds of subprograms and some
of the uses for them. Specifically, we covered the following:

How subprograms consist of functions and procedures. Functions
have only input parameters and a single return value; procedures
can have any number of in, out, and inout parameters.

How functions can be used as conversion functions to convert from
one type to another.

How functions can be used as resolution functions to calculate the
proper value on a multiple-driven network.

How procedures are considered statements; functions are usually
part of an expression. Procedures can exist alone; functions are
usually called as part of a statement.

How packages are used to encapsulate information that is to be
shared among multiple design units.

How packages consist of a package declaration in which all of the
type, subprogram, and other declarations exist and a package body
in which subprogram bodies and deferred constants exist.

In the next chapter, we discuss how attributes can make some de-
scriptions easier to read and more compact.
Free download pdf