Microsoft AGB-00001 Spécifications Page 23

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 144
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 22
Language Structure
VHDL Reference Manual 2-15
process(clk)
begin
if clk and clk'event then
p <= p + 1;
end if;
end process;
end behavior;
In this example, type integer was used because the "+" operator is
defined for integers but not for bit_vectors.
The most common user-defined types are enumerated types, described
in the previous section.
Types and Logic Synthesis
In VHDL, types are used for type checking and for operator overload
resolution (a situation in which two or more operators or functions
have the same name, but specify different argument types). For logic
synthesis, each type declaration also defines the encoding and number
of wires to be generated. For subtypes, checking and overloading use
the base type of the subtype. Each subtype declaration defines a
subset of its base type and can specify the number or wires (directly or
indirectly) and possibly the encoding scheme.
During compilation, ports with types that synthesize to multiple wires
are renamed by appending _n_, where n is an incremented integer
starting from zero.
Type Conversions
Because VHDL is strongly typed, and not all operations are supported
for all standard data types, and it is sometimes necessary to convert
from one type to another. A good example of this is the previous
example, which used an integer data type to describe a counter. What
if the design required (for external interface reasons) that all I/O ports
be of type std_logic? Since there is no pre-defined + operator for non-
numeric types such as std_logic, it is necessary to either overload the
+ operator (by writing a new + function for std_logic_vector data
types) or convert the type from std_logic_vector to integer, and then
from integer back to std_logic_vector as shown below:
library ieee;
use ieee.std_logic_1164.all;
entity counter is
port (clk: in std_logic;
p: inout std_logic_vector(1 downto 0);
end counter;
library dataio;
use dataio.std_logic_ops.all;
architecture behavior of counter is
begin
process (clk)
begin
Vue de la page 22
1 2 ... 18 19 20 21 22 23 24 25 26 27 28 ... 143 144

Commentaires sur ces manuels

Pas de commentaire