Return to previous page Advance to next page
VHDL Reference Guide
Chapter 2: Design Descriptions

Entities

An entity defines the input and output ports of a design. A design can contain more than one entity. Each entity has its own architecture statement.

The syntax follows.

entity entity_name is [ generic generic_declarations );]
[ port ( port_declarations ) ;]
end [ entity_name ] ;

You cannot use the declaration of other in the entity specification.

An entity serves as an interface to other designs, by defining entity characteristics that must be known to Foundation Express before it can connect the entity to other entities and components.

For example, before you can connect a counter to other entities, you must specify the number and types of its input and output ports, as shown in the following example.

entity NAND2 is 
port(A, B: in BIT; -- Two inputs, A and B
Z: out BIT); -- One output, Z = (A and B)'
end NAND2;

Entity Generic Specifications

Generic specifications are entity parameters. Generics can specify the bit-widths of components - such as adders - or can provide internal timing values.

A generic can have a default value. It receives a nondefault value only when the entity is instantiated (see the “Declarations” section of this chapter) or configured (see the “Configurations” section of this chapter). Inside an entity, a generic is a constant value.

The syntax follows.

generic(
constant_name : type [ := value ]
{ ; constant_name : type [ := value ] }
);

Entity Port Specifications

Port specifications define the number and type of ports in the entity. The syntax follows.

port(
port_name : mode port_type
{ ; port_name : mode port_type}
);

The following example shows an entity specification for a 2-input N-bit comparator with a default bit-width of 8.

-- Define an entity (design) called COMP
-- that has 2 N-bit inputs and one output.

entity COMP is
generic(N: INTEGER := 8); -- default is 8 bits

port(X, Y:  in  BIT_VECTOR(0 to N-1);
EQUAL: out BOOLEAN);
end COMP;