C
Charles Steinkuehler
Guest
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm trying to do something with type definitions in a package, and it
seems like I need something like generics, but they don't seem to be
supported in packages.
The setting:
In my package, I define an enumerated global configuration type which is
used to specifiy which 'flavor' the design compiles to (ie: controls
number of active DMA channels, buffer sizes, etc). The top-level design
file passes the configuration type down the physical design tree as a
generic parameter, and functions in the package are used to control
generate statements, interface widths, etc. All this works fine.
The problem:
I'm trying to define some array subtypes in the package that depend on
which 'flavor' of chip is being built (a buffer-pointer address type,
which is a subtype of unsigned with it's length dependent on the
particular configuration being built).
ie:
package my_Pkg is
type conf_T is (BabyBear, MamaBear, PapaBear);
type SettingType_T is (DMA_PBUF_SIZE, DMA_PBUF_BITS);
function get_param (config : conf_T;
setting : SettingType_T) return natural;
subtype Buf_Addr_T is unsigned(12 downto 0);
type DMA_Buf_IF_T is record
req : std_logic;
ack : std_logic;
done : std_logic;
ptr : Buf_Addr_T;
end record DMA_Buf_IF_T;
end package my_Pkg;
....except I need to be able to configure the length of the Buf_Addr_T
subtype "dynamically" (at compile time) based on the selected conf_T type.
I could simply use my existing configuration functions to control the
declaration of unsigned (instead of Buf_Addr_T) types where needed, but
that would leave me without the DMA_Buf_IF_T type (which doesn't like to
compile with ptr as an unconstrained array).
The question:
Is there any way to declare a record type that contains an array who's
length depends on the environment (ie: a generic or similar)? I tried
breaking the above code into two packages, one with the get_param
function and one with the Buf_Addr_T and DMA_Buf_IF_T type declarations,
but there's no way (that I've found) to pass my compile-time conf_T
value to the package (or to do something similar).
- --
Charles Steinkuehler
cstein@newtek.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
iD8DBQFEahhQenk4xp+mH40RAufCAJ9hd2hZbaaJWdn2pm+txl0N/D4v3wCdH2sh
yy9Rz0mbSBTyUqNSabX69No=
=KQo0
-----END PGP SIGNATURE-----
Hash: SHA1
I'm trying to do something with type definitions in a package, and it
seems like I need something like generics, but they don't seem to be
supported in packages.
The setting:
In my package, I define an enumerated global configuration type which is
used to specifiy which 'flavor' the design compiles to (ie: controls
number of active DMA channels, buffer sizes, etc). The top-level design
file passes the configuration type down the physical design tree as a
generic parameter, and functions in the package are used to control
generate statements, interface widths, etc. All this works fine.
The problem:
I'm trying to define some array subtypes in the package that depend on
which 'flavor' of chip is being built (a buffer-pointer address type,
which is a subtype of unsigned with it's length dependent on the
particular configuration being built).
ie:
package my_Pkg is
type conf_T is (BabyBear, MamaBear, PapaBear);
type SettingType_T is (DMA_PBUF_SIZE, DMA_PBUF_BITS);
function get_param (config : conf_T;
setting : SettingType_T) return natural;
subtype Buf_Addr_T is unsigned(12 downto 0);
type DMA_Buf_IF_T is record
req : std_logic;
ack : std_logic;
done : std_logic;
ptr : Buf_Addr_T;
end record DMA_Buf_IF_T;
end package my_Pkg;
....except I need to be able to configure the length of the Buf_Addr_T
subtype "dynamically" (at compile time) based on the selected conf_T type.
I could simply use my existing configuration functions to control the
declaration of unsigned (instead of Buf_Addr_T) types where needed, but
that would leave me without the DMA_Buf_IF_T type (which doesn't like to
compile with ptr as an unconstrained array).
The question:
Is there any way to declare a record type that contains an array who's
length depends on the environment (ie: a generic or similar)? I tried
breaking the above code into two packages, one with the get_param
function and one with the Buf_Addr_T and DMA_Buf_IF_T type declarations,
but there's no way (that I've found) to pass my compile-time conf_T
value to the package (or to do something similar).
- --
Charles Steinkuehler
cstein@newtek.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
iD8DBQFEahhQenk4xp+mH40RAufCAJ9hd2hZbaaJWdn2pm+txl0N/D4v3wCdH2sh
yy9Rz0mbSBTyUqNSabX69No=
=KQo0
-----END PGP SIGNATURE-----