Hallo,
ich habe ein kleines Modul geschrieben, dass eine generische Anzahl von
Modulo Countern erzeugen soll:
1 | ENTITY counter_block IS
|
2 | GENERIC(
|
3 | g_num_counters : INTEGER);
|
4 | PORT(
|
5 | clk : IN STD_LOGIC;
|
6 | rst_n : IN STD_LOGIC;
|
7 | -- counter settings
|
8 | i_counter_max : IN STD_LOGIC_VECTOR(g_num_counters*32-1 DOWNTO 0);
|
9 | -- counter control
|
10 | i_counter_enable : IN STD_LOGIC_VECTOR(g_num_counters-1 DOWNTO 0);
|
11 | i_counter_reset : IN STD_LOGIC_VECTOR(g_num_counters-1 DOWNTO 0);
|
12 | -- counter output
|
13 | o_counters : OUT STD_LOGIC_VECTOR(g_num_counters*32-1 DOWNTO 0)
|
14 | );
|
15 | END ENTITY counter_block;
|
16 |
|
17 | ARCHITECTURE rtl OF counter_block IS
|
18 |
|
19 | SIGNAL s_counters : STD_LOGIC_VECTOR(g_num_counters*32-1 DOWNTO 0);
|
20 |
|
21 | BEGIN
|
22 |
|
23 | o_counters <= s_counters;
|
24 |
|
25 | p_count : PROCESS (clk, rst_n)
|
26 | BEGIN -- PROCESS p_cnount
|
27 | IF (rst_n = '0') THEN
|
28 | s_counters <= (OTHERS => '0');
|
29 | ELSIF (clk'EVENT AND clk = '1') THEN
|
30 |
|
31 | FOR i IN 0 TO g_num_counters-1 LOOP
|
32 |
|
33 | IF (i_counter_reset(i) = '1') THEN
|
34 | s_counters(i*32+31 DOWNTO i*32) <= (OTHERS => '0');
|
35 | ELSIF (i_counter_enable(i) = '1') THEN
|
36 | IF (s_counters(i*32+31 DOWNTO i*32) < i_counter_max(i*32+31 DOWNTO i*32)) THEN
|
37 | s_counters(i*32+31 DOWNTO i*32) <= s_counters(i*32+31 DOWNTO i*32) + 1;
|
38 | ELSE
|
39 | s_counters(i*32+31 DOWNTO i*32) <= (OTHERS => '0');
|
40 | END IF;
|
41 | END IF;
|
42 |
|
43 | END LOOP; -- i
|
44 |
|
45 | END IF;
|
46 | END PROCESS p_count;
|
47 |
|
48 | END ARCHITECTURE rtl;
|
Über den i_counter_max Eingang möchte ich jedem Counter einen eigen
Maximalwert zuweisen. Mit i_counter_enable sollen die einzelnen Counter
hochzählen.
Diesen Block verwende ich in meinem Design mit g_num_counters = 64.
Dabei ist aber i_counter_enable(31 downto 7) konstant null, es sollen
also nur 7 Counter verwendet werden. Für diese ist i_counter_max jeweils
konstant auf X"0000ffff" gesetzt.
Eigentlich habe ich also erwartet erwartet dass im ISE nach der
Optimierung 7 16 Bit Counter übrig bleiben, tatsächlich bekomme ich
aber:
inferred 2048 D-type flip-flop(s).
inferred 64 Adder/Subtractor(s).
inferred 64 Comparator(s).
Wie code ich das ganze so, dass ISE das macht was ich will?