Forum: FPGA, VHDL & Co. VHDL Configuration und Generics


von ope (Gast)


Lesenswert?

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

von Klaus F. (kfalser)


Lesenswert?

Wenn Du deinen generischen Counter so definierst
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(BITWIDTH_TIME_CNTR-1 downto
13
0);
14
      event_count : out std_logic_vector(BITWIDTH_TIME_CNTR-1 downto
15
0));
16
end entity reciprocal_counter_g;
17
18
architecture behavioral of reciprocal_counter_g is
19
   signal time_cnt  : std_logic_vector(BITWIDTH_TIME_CNTR-1 downto 0);
20
   signal event_cnt : std_logic_vector(BITWIDTH_TIME_CNTR-1 downto 0);
21
begin
22
   ...

und Deinen synthetisierbaren 24 Bit Counter
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[23 downto 0];
9
      event_count : out std_logic_vector[23 downto 0]);
10
end entity reciprocal_counter;
11
12
architecture behavioral of reciprocal_counter is
13
   component reciprocal_counter_g is
14
   generic (
15
      RESET_ACTIVE        : std_logic;
16
      BITWIDTH_TIME_CNTR  : natural;
17
      BITWIDTH_EVENT_CNTR : natural);
18
   port (
19
      clk         : in  std_logic;
20
      reset       : in  std_logic;
21
      start       : in  std_logic;
22
      stop        : in  std_logic;
23
      events      : in  std_logic;
24
      time_count  : out std_logic_vector(BITWIDTH_TIME_CNTR-1 downto
25
0);
26
      event_count : out std_logic_vector(BITWIDTH_TIME_CNTR-1 downto
27
0));
28
   end component reciprocal_counter_g;
29
begin
30
   reciprocal_counter_i : reciprocal_counter_g
31
      generic map (
32
         RESET_ACTIVE        => '1',
33
         BITWIDTH_TIME_CNTR  => 24,
34
         BITWIDTH_EVENT_CNTR => 24);
35
      port map (
36
         clk         => clk,
37
         reset       => reset,
38
         start       => start,
39
         stop        => stop,
40
         events      => events,
41
         time_count  => time_count,
42
         event_count => event_count);
43
end architecture behavioral;
44
[C]
45
46
dann müsstest Du mit diesen Konfiguration umschalten können
47
[C]
48
configuration behavioral_cfg of reciprocal_counter is
49
   for behavioral
50
      for all : reciprocal_counter_g
51
         use entity work.reciprocal_counter_g(behavioral)
52
      end for;
53
   end for;
54
end behavioral_cfg;
55
56
configuration synthese_cfg of reciprocal_counter is
57
   for behavioral
58
      for all : reciprocal_counter_g
59
         use entity work.reciprocal_counter_g(structural);
60
      end for;
61
   end for;
62
end synthese_cfg;

Hoffentlich habe ich keine Tippfehler gemacht.
Grüße
Klaus

von Klaus F. (kfalser)


Lesenswert?

Halt, halt, halt, da habe ich jetzt übereilt geschrieben und gedacht.

In der Konfiguration für deine TESTBENCH kannst Du jetzt für die
Instanz  deines 24 Bit Zählers (DUT) einmal die architecture
"behavioral" und einmal die architecture "structural" aufrufen.

Entschuldigung
Klaus

von ope (Gast)


Angehängte Dateien:

Lesenswert?

vielen Dank Klaus!

Wenn ich es richtig verstanden habe, nehme ich die generics im wahrsten
Sinne des Wortes als reine Schablonen, die ich mit den jeweiligen
entities bzw. deren architectures instanziere. Damit benutze ich die
Configurationen nur zum Umschalten zwischen den einzelnen
architectures.

Lt. div. Seiten soll das mappen von generics aber auch in den configs
machbar sein, bis hin zum port mapping. Ich bin aber froh, wenn es
erstmal so funktioniert.

Leider bekomme ich beim Aufruf der jeweiligen Konfiguration die
Meldung:

Generic 'reset_active' has not been given a value.
Instance: /tb_counter/tb/uut File:
source/vhdl/reciprocal_counter_g.vhd

BTW, das renaming (UUT nach DUT zB) in ISE/8.1sp1 scheint nicht zu
klappen.

Momentan sieht's so aus:
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(BITWIDTH_TIME_CNTR-1 downto
13
0);
14
      event_count : out std_logic_vector(BITWIDTH_EVENT_CNTR-1 downto
15
0));
16
end entity reciprocal_counter_g;
17
18
architecture behavioral of reciprocal_counter_g is
19
   ...

und der Instanz als 24-bitter:
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(23 downto 0);
9
      event_count : out std_logic_vector(23 downto 0));
10
end entity reciprocal_counter;
11
12
architecture behavioral of reciprocal_counter is
13
   component reciprocal_counter_g is
14
      generic (
15
         RESET_ACTIVE        : std_logic;
16
         BITWIDTH_TIME_CNTR  : natural;
17
         BITWIDTH_EVENT_CNTR : natural);
18
      port (
19
         clk         : in  std_logic;
20
         reset       : in  std_logic;
21
         start       : in  std_logic;
22
         stop        : in  std_logic;
23
         events      : in  std_logic;
24
         time_count  : out std_logic_vector(BITWIDTH_TIME_CNTR-1 downto
25
0);
26
         event_count : out std_logic_vector(BITWIDTH_EVENT_CNTR-1
27
downto 0));
28
   end component reciprocal_counter_g;
29
begin
30
   reciprocal_counter_i : reciprocal_counter_g
31
      generic map (
32
         RESET_ACTIVE        => '1',
33
         BITWIDTH_TIME_CNTR  => 24,
34
         BITWIDTH_EVENT_CNTR => 24)
35
      port map ( ... );
36
37
end architecture behavioral;

und den TB als generic
1
entity TB_counter_g is
2
   generic (
3
      RESET_ACTIVE : std_logic := '1';
4
      COUNT_DEPTH  : natural   := 24);
5
end entity TB_counter_g;
6
7
architecture behavioral of TB_counter_g is
8
   constant BITWIDTH_TIME_CNTR  : natural := COUNT_DEPTH;
9
   constant BITWIDTH_EVENT_CNTR : natural := COUNT_DEPTH;
10
   component reciprocal_counter is
11
      port ( ... );
12
   end component reciprocal_counter;
13
   ...
14
begin
15
   UUT : reciprocal_counter
16
      port map ( ... );
17
   ...

und den Konfigurationen
1
configuration TB_counter_24_behavioral_cfg of TB_counter_g is
2
   for behavioral
3
      for UUT : reciprocal_counter
4
         use entity work.reciprocal_counter_g(behavioral);
5
      end for;
6
   end for;
7
end TB_counter_24_behavioral_cfg;
8
9
configuration TB_counter_24_synthesis_cfg of TB_counter_g is
10
   for behavioral
11
      for UUT : reciprocal_counter
12
         use entity work.reciprocal_counter(structural);
13
      end for;
14
   end for;
15
end TB_counter_24_synthesis_cfg;

So recht kann ich es nicht nachvollziehen, da ich imo für reset_active
defaults angegeben habe.

Ohne Configuration klicken in MXE aus ISE heraus klappt die Simu aber
direkt! Erst beim Auswählen einer der beiden Configs kommt obiger
Fehler.

Anbei das komplette Bsp. was nach der Synthese nicht mehr funzt, aber
das ist ein anderes Thema :/

Viele Grüße
Olaf

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.