Zudem ist die Sensitivliste des Prozesses (wie üblich) überdefiniert:
1 | process(clk, toAdd, toDelete)
|
Weil der Prozess nur auf clk sensitiv ist (also nur bei einer Änderung
von clk neu berechnet werden muß), reicht hier:
Zudem hat die Variable cnt keinen Initialwert. Es ist also
undefiniert, wo der Zähler zu zählen beginnt... :-o
EDIT:
1 | cnt := to_integer(unsigned(count));
|
Das geht nicht, weil count ein OUT-Port ist.
Am besten also so:
1 | library ieee;
|
2 | use ieee.std_logic_1164.all;
|
3 | use ieee.numeric_std.all;
|
4 | :
|
5 | architecture rtl of Counter is
|
6 | signal cnt : integer range MIN_COUNT to MAX_COUNT;
|
7 | begin
|
8 | process(clk) begin
|
9 | if(clk'event and clk = '1')then
|
10 | if(toAdd = '1' and toDelete = '0' and cnt<MAX_COUNT) then
|
11 | cnt <= cnt + 1;
|
12 | end if;
|
13 |
|
14 | if(toDelete = '1' and toAdd = '0' and cnt>MIN_COUNT)then
|
15 | cnt <= cnt - 1;
|
16 | end if;
|
17 | end if;
|
18 | end process;
|
19 |
|
20 | count <= std_logic_vector(to_unsigned(cnt,3));
|
21 | end rtl;
|