Chapter start Previous page Next page 10.7 Interface DeclarationsAn interface declaration declares interface objects that may be interface constants, signals, variables, or files [VHDL 87LRM4.3.3, 93LRM4.3.2]. Interface constants are generics of a design entity, a component, or a block, or parameters of subprograms. Interface signals are ports of a design entity, component, or block, and parameters of subprograms. Interface variables and interface files are parameters of subprograms. Each interface object has
a mode that indicates the direction of information flow. The most common
modes are
There are other special-case rules for reading and updating interface signals, constants, variables, and files that I shall cover in the following sections. The situation is like the spelling rule, "i before e except after c." Table 10.10 corresponds to the rule "i before e." 10.7.1 Port DeclarationInterface objects that are signals are called ports [VHDL 93LRM1.1.1.2]. You may think of ports as "connectors" and you must declare them as follows: port (port_interface_list) interface_list ::= port_interface_declaration {; port_interface_declaration} A port interface declaration is a list of ports that are the inputs and outputs of an entity, a block, or a component declaration: interface_declaration ::= [signal] identifier {, identifier}:[in|out|inout|buffer|linkage] subtype_indication [bus] [:= static_expression] Each port forms an implicit
signal declaration and has a port mode. I shall discuss entity Association_1 is port (signal X, Y : in BIT := '0'; Z1, Z2, Z3 : out BIT); end; In the preceding declaration
the keyword You use a port map and either
positional association or named association to connect the formals of an
entity with the locals of a component. Port maps also associate (connect)
the locals of a component with the actuals of an instance. For an example
of formal, local, and actual ports, and explanation of their function, see
Section 10.5, where we declared an entity use work.all; -- makes analyzed design entity AndGate(Simple) visible. architecture Netlist of Association_1 is -- The formal port clause for entity AndGate looks like this: -- port (And_in_1, And_in_2: in BIT; And_out : out BIT); -- Formals. component AndGate port (And_in_1, And_in_2 : in BIT; And_out : out BIT); -- Locals. end component; begin -- The component and entity have the same names: AndGate. -- The port names are also the same: And_in_1, And_in_2, And_out, -- so we can use default binding without a configuration. -- The last (and only) architecture for AndGate will be used: Simple. A1:AndGate port map (X, Y, Z1); -- positional association A2:AndGate port map (And_in_2=>Y, And_out=>Z2, And_in_1=>X); -- named A3:AndGate port map (X, And_out => Z3, And_in_2 => Y); -- both end; The interface object rules
of Table 10.10 apply to ports. The rule that forbids updating an interface
object of mode entity ClockGen_1 is port (Clock : out BIT); end; architecture Behave of ClockGen_1 is begin process variable Temp : BIT := '1'; begin -- Clock <= not Clock; -- Illegal, you cannot read Clock (mode out), Temp := not Temp; -- use a temporary variable instead. Clock <= Temp after 10 ns; wait for 10 ns; if (now > 100 ns) then wait; end if; end process; end; Table 10.10 lists the restrictions on reading and updating interface objects including interface signals that form ports. Table 10.11 lists additional special rules for reading and updating the attributes of interface signals. There is one more set of rules
that apply to port connections [VHDL
LRM 1.1.1.2]. If design entity Notice that the allowed connections
diagrammed in Table 10.12 (looking from inside to the outside) are
a superset of those of Table 10.10 (looking from the outside to the
inside). Only the seven types of connections shown in Table 10.12 are
allowed between the ports of nested design entities. The additional rule
that ports of mode
10.7.2 GenericsPorts are signals that carry changing information between entities. A generic is similar to a port, except generics carry constant, static information [VHDL LRM1.1.1.1]. A generic is an interface constant that, unlike normal VHDL constants, may be given a value in a component instantiation statement or in a configuration specification. You declare generics in an entity declaration and you use generics in a similar fashion to ports. The following example uses a generic parameter to alter the size of a gate: entity AndGateNWide is generic (N : NATURAL := 2); port (Inputs : BIT_VECTOR(1 to N); Result : out BIT); end; Notice that the generic interface list precedes the port interface list. Generics are useful to carry timing (delay) information, as in the next example: entity AndT is generic (TPD : TIME := 1 ns); port (a, b : BIT := '0'; q: out BIT); end; architecture Behave of AndT is begin q <= a and b after TPD; end; entity AndT_Test_1 is end; architecture Netlist_1 of AndT_Test_1 is component MyAnd port (a, b : BIT; q : out BIT); end component; signal a1, b1, q1 : BIT := '1'; begin And1 : MyAnd port map (a1, b1, q1); end Netlist_1; configuration Simplest_1 of AndT_Test_1 is use work.all; for Netlist_1 for And1 : MyAnd use entity AndT(Behave) generic map (2 ns); end for; end for; end Simplest_1; The configuration declaration,
There was initially no standard in VHDL for how timing generics should be used, and the lack of a standard was a major problem for ASIC designers. The IEEE 1076.4 VITAL standard addresses this problem (see Section 13.5.5). 1. There are additional rules for interface objects that are signals (ports)--see Tables 10.11 and 10.12. 2. A signal of mode inout can be updated by any number of sources [VHDL 87LRM4.3.3, 93LRM4.3.2]. 3. A signal of mode buffer can be updated by at most one source [VHDL LRM1.1.1.2]. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|