VHDL Programming

(C. Jardin) #1

116 Chapter Five


directly to the component ports. A conversion function is needed to convert
between the two value systems.
If the ports are all of mode IN, then only one conversion is needed to map
from the containing entity type to the contained entity type. In this example,
if all of the ports were of mode input, then only function convert4valwould
be required.
If the component has output ports as well, then the output values of
the contained entity need to be converted back to the containing entity
type. In this example, the qport of component dffis an output port. The
type of the output values is fourvalue. These values cannot be mapped
to the type fourvalports of entity xregister. Function convert4value
converts from a fourvaluetype to a fourvaltype. Applying this function
on the output ports allows the port mapping to occur.
There are four component instantiations that use these conversion
functions: components U1 through U4. Notice that the input ports use the
convert4valconversion function; the output ports use the convert4value
conversion function.
Using the named association form of mapping for component instanti-
ation, U1 would look like this:

U1: dff PORT MAP (
d => convert4val( a(0) ),
clk => convert4val( clk ),
clr => convert4val( clr ),
convert4value(q) => q(0) );

What this notation shows is that, for the input ports, the conversion
functions are applied to the appropriate input signals (ports) before being
mapped to the dffports, and the output port value is converted with the
conversion function before being mapped to the output port q(0).
Conversion functions free the designer from generating a lot of temporary
signals or variables to perform the conversion. The following example
shows another method for performing conversion functions:

temp1 <= convert4val( a(0) );
temp2 <= convert4val( clk );
temp3 <= convert4val( clr );

U1: dff PORT MAP (
dlk => temp1,
clk => temp2,
clr => temp3,
qlk => temp4);

q(0) <= convert4value(temp4);
Free download pdf