nixda schrieb:
> also ist es ein latch + eine komb. loop... beides ist nicht der hit, oder?
> Erstmal: Obiges funktioniert.
> ABER: 3 Typenumwandlungen kommen mir etwas viel vor.
Und du hast damit wie erwähnt eine kombinatorische Schleife. Oder einen
essentiellen Teil des Codes (namentlich den Takt) nicht mitgepostet.
Das hier:
1 | library IEEE;
|
2 | use IEEE.std_logic_1164.all;
|
3 | use IEEE.numeric_std.all;
|
4 |
|
5 | entity ASTI is
|
6 | Port ( A : inout integer range 0 to 63;
|
7 | B : in STD_LOGIC);
|
8 | end ASTI;
|
9 | architecture Behavioral of ASTI is
|
10 | begin
|
11 | A <= A + to_integer(unsigned(std_logic_vector'('0' & B)));
|
12 | end Behavioral;
|
ergibt nach der Synthese:
1 | WARNING:Xst:2170 - Unit ASTI : the following signal(s) form a combinatorial loop: A<0>.
|
2 | WARNING:Xst:2170 - Unit ASTI : the following signal(s) form a combinatorial loop: A<5>.
|
3 | WARNING:Xst:2170 - Unit ASTI : the following signal(s) form a combinatorial loop: A<4>.
|
4 | WARNING:Xst:2170 - Unit ASTI : the following signal(s) form a combinatorial loop: A<3>.
|
5 | WARNING:Xst:2170 - Unit ASTI : the following signal(s) form a combinatorial loop: A<2>.
|
6 | WARNING:Xst:2170 - Unit ASTI : the following signal(s) form a combinatorial loop: A<1>.
|
Und eine Kombinatorische Schleife ist i.A. nicht erwünscht:
http://www.lothar-miller.de/s9y/categories/36-Kombinatorische-Schleife
Wenn das Ganze also mal auf einen Takt bezogen wird (und nur das macht
Sinn), dann sind diese drei Beschreibungen absolut gleichwertig:
1 | library IEEE;
|
2 | use IEEE.std_logic_1164.all;
|
3 | use IEEE.numeric_std.all;
|
4 |
|
5 | entity ASTI is
|
6 | Port ( clk : in STD_LOGIC;
|
7 | A : inout integer range 0 to 63;
|
8 | B : in STD_LOGIC);
|
9 | end ASTI;
|
10 |
|
11 | architecture Behavioral of ASTI is
|
12 | begin
|
13 |
|
14 | -- Variante 1
|
15 | process begin
|
16 | wait until rising_edge(clk);
|
17 | A <= A + to_integer(unsigned(std_logic_vector'('0' & B)));
|
18 | end process;
|
19 |
|
20 |
|
21 | -- Variante 2
|
22 | process begin
|
23 | wait until rising_edge(clk);
|
24 | if B='1' then A<=A+1; end if;
|
25 | end process;
|
26 |
|
27 |
|
28 | -- Variante 3
|
29 | A <= A+1 when rising_edge(clk) and B='1';
|
30 |
|
31 | end Behavioral;
|