Where to declare a constant or type used in declaring an object?

If I do not quite understand this completely, a constant or type cannot be declared at the top level of the file. Only packages, objects, architectures et.c. can be announced there. They can be declared in essence, but not up to port and general articles.

Often you want to define a type or constant for use in a port or general sentence of an entity, but since it is impossible to declare at the top level of the file, and not inside the object, where should it be declared?

+3
source share
2 answers

They are usually declared in the package that is included at the beginning of your file, just as you would include standard VHDL packages, i.e.:

library ieee;

use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.math_real.all;

use work.My_Custom_Types_Pkg.all;

entity My_Entity is
    port (
        ...

.

+4

, , .. . package. , / . entity architecture ( SO)

, , VHDL, , , / , use , ( , ).

0

All Articles