Moin in die Runde,
Ich habe eine Konstante in einem Package, die aber erst in einer
Funktion, in Abhängigkeit einer anderen Konstante, im Package Body
initialisiert wird. Mit dieser Konstanten will ich im selben Package für
ein Record einen Vector constrainen. Als Beispiel ungefähr so :
1 | library ieee;
|
2 | use ieee.std_logic_1164.all;
|
3 | use ieee.numeric_std.all;
|
4 |
|
5 | package test_pkg is
|
6 |
|
7 | ----------------------------------------------------------------------------
|
8 | constant test_big_vect_c : boolean := true;
|
9 | constant test_bits_c : natural; -- init below in function
|
10 | function init_test_bits_f return natural;
|
11 |
|
12 | type test_record is record
|
13 | test1 : std_logic;
|
14 | test_vector : std_logic_vector(test_bits_c-1 downto 0);
|
15 | end record;
|
16 |
|
17 | end package;
|
18 |
|
19 | package body test_pkg is
|
20 |
|
21 | function init_test_bits_f return natural is
|
22 | begin
|
23 | if test_big_vect_c then
|
24 | return 64;
|
25 | else
|
26 | return 32; -- @suppress "Dead code"
|
27 | end if;
|
28 | end function;
|
29 |
|
30 | constant test_bits_c : natural := init_test_bits_f;
|
31 |
|
32 | end package body;
|
Leider geht das nicht, da die Konstante erst im Body festgelegt wird.
Den Record im Body definieren geht auch nicht. Subtypes im Body habe ich
auch schon vergeblich probiert.
hat vielleicht noch jemand eine simple Idee auf die ich gerade nicht
komme?
Viele Grüße in die Runde