Ausgangspunkt für diesen Thread ist
http://www.mikrocontroller.net/forum/read-9-278209.html#278209.
Ich habe das Problem erstmal auf die Configuration von Generics
geschoben. Momemtan versuche ich es mit unconstrained generic entities
und bin wie inzwischen üblich auf's Schnäuzchen geflogen:
1 | entity reciprocal_counter_g is
|
2 | generic (
|
3 | RESET_ACTIVE : std_logic;
|
4 | BITWIDTH_TIME_CNTR : natural;
|
5 | BITWIDTH_EVENT_CNTR : natural);
|
6 | port (
|
7 | clk : in std_logic;
|
8 | reset : in std_logic;
|
9 | start : in std_logic;
|
10 | stop : in std_logic;
|
11 | events : in std_logic;
|
12 | time_count : out std_logic_vector;
|
13 | event_count : out std_logic_vector);
|
14 | end entity reciprocal_counter_g;
|
15 |
|
16 | architecture behavioral of reciprocal_counter_g is
|
17 | signal time_cnt : std_logic_vector(BITWIDTH_TIME_CNTR-1 downto 0);
|
18 | signal event_cnt : std_logic_vector(BITWIDTH_TIME_CNTR-1 downto 0);
|
19 | begin
|
20 | ...
|
Hier binde ich die generics erst in der architecture. Es gibt keine
Defaults, da zuvor beim Laden der configurations ein Mismatch zwischen
der dafault Portsize und der aktuellen Portsize kam (zB. Port size (32)
does not match actual size (16) for port /path/to/count'), sprich
defaults und configuration widersprachen sich.
Nun kommt die eigentliche Instanz ohne generics. Diese sollten per
Konf. ausgewählt werden damit ich bei der Postsynthese die architecture
gleich mit der synthetisierten austauschen kann:
1 | entity reciprocal_counter is
|
2 | port (
|
3 | clk : in std_logic;
|
4 | reset : in std_logic;
|
5 | start : in std_logic;
|
6 | stop : in std_logic;
|
7 | events : in std_logic;
|
8 | time_count : out std_logic_vector;
|
9 | event_count : out std_logic_vector);
|
10 | end entity reciprocal_counter;
|
11 |
|
12 | architecture behavioral of reciprocal_counter is
|
13 | component reciprocal_counter_g is
|
14 | port (
|
15 | clk : in std_logic;
|
16 | reset : in std_logic;
|
17 | start : in std_logic;
|
18 | stop : in std_logic;
|
19 | events : in std_logic;
|
20 | time_count : out std_logic_vector;
|
21 | event_count : out std_logic_vector);
|
22 | end component reciprocal_counter_g;
|
23 | begin
|
24 | reciprocal_counter_i : reciprocal_counter_g
|
25 | port map (
|
26 | clk => clk,
|
27 | reset => reset,
|
28 | start => start,
|
29 | stop => stop,
|
30 | events => events,
|
31 | time_count => time_count,
|
32 | event_count => event_count);
|
33 | end architecture behavioral;
|
Jetzt kommen die Konfigurationen:
1 | configuration counter_24_cfg of reciprocal_counter is
|
2 | for behavioral
|
3 | for all : reciprocal_counter_g
|
4 | use entity work.reciprocal_counter_g(behavioral)
|
5 | generic map (
|
6 | RESET_ACTIVE => '1',
|
7 | BITWIDTH_TIME_CNTR => 24,
|
8 | BITWIDTH_EVENT_CNTR => 24);
|
9 | end for;
|
10 | end for;
|
11 | end counter_24_cfg;
|
12 |
|
13 | configuration synthese_cfg of reciprocal_counter is
|
14 | for behavioral
|
15 | for all : reciprocal_counter_g
|
16 | use entity work.reciprocal_counter_g(structural);
|
17 | end for;
|
18 | end for;
|
19 | end synthese_cfg;
|
Alles compiliert in MXE sauber durch, will ich aber eine Konfiguration
laden kommt:
Port 'time_count' is not constrained. Was zuvor durch die Defaults zu
früh gebunden wurde, wird nun überhaupt nicht mehr gebunden.
Für mich stellt sich die Frage, wann werden die Configuration denn
eigentlich gemappt? Zur Compiliertzeit, zur Simuzeit (d.h. der compiler
müsste für alle Konfigurationen jeweils das generic file compilieren)
oder wann? Irgendwie scheine ich ein falsches Verständis für die
generics und configs entwickelt zu haben. Die comp.lnag.VHDL FAQ hält
sich in solchen Fragen auch sehr zurück.
Viele Grüße
Olaf