Problemator schrieb:
> Das Warten läuft mit einer for Schleife.
Hast du vorher mal C programmiert?
Und willst jetzt mit der selben Denkweise Hardware beschreiben?
ROTFL... :-D
VHDL ist keine Programmiersprache sondern eine Beschreibungssprache.
Du mußt dir also denken: wie würde ich so eine Verzögerung mit Logik und
Flipflops aufbauen. Und das dann beschreiben...
> Ich simuliere das ganze mit ISIM, aber stelle fest, dass die gesamte for
> Schleife einfach übersprungen wird? Warum?
Weil eine for-Schleife in VHDL in der Zeit 0 durchlaufen wird.
Zu deiner Frage:
Eine for-Schleife in VHDL bedeutet nur, dass der Block innerhalb der
for-Schleife eine bestimmte Anzahl oft dupliziert wird.
Deinen Code könntest du also auch so schreiben:
1 | CButton: process(button, clk1)
|
2 | begin
|
3 | if button'event and button='0' then
|
4 |
|
5 | if clk1'event and clk1='1' then
|
6 | tmp <= i;
|
7 | end if;
|
8 | if button='0' and i=100 and pushed='1' then
|
9 | button_control <= not(button_control);
|
10 | end if;
|
11 |
|
12 | if clk1'event and clk1='1' then
|
13 | tmp <= i;
|
14 | end if;
|
15 | if button='0' and i=100 and pushed='1' then
|
16 | button_control <= not(button_control);
|
17 | end if;
|
18 |
|
19 | if clk1'event and clk1='1' then
|
20 | tmp <= i;
|
21 | end if;
|
22 | if button='0' and i=100 and pushed='1' then
|
23 | button_control <= not(button_control);
|
24 | end if;
|
25 | :
|
26 | : und so fort, das Ganze insgesamt 101 mal...
|
27 | :
|
28 | if clk1'event and clk1='1' then
|
29 | tmp <= i;
|
30 | end if;
|
31 | if button='0' and i=100 and pushed='1' then
|
32 | button_control <= not(button_control);
|
33 | end if;
|
34 |
|
35 | end if;
|
36 | end process;
|
Davon abgesehen:
1 | CButton: process(button, clk1)
|
2 | begin
|
3 | if button'event and button='0' then
|
4 | for i in 1 to 100 loop
|
5 | if clk1'event and clk1='1' then
|
6 | tmp <= i; --- Signale werden erst am Prozessende zugewiesen
|
7 | end if;
|
8 | if button='0' and i=100 and pushed='1' then
|
9 | button_control <= not(button_control); --- Signale werden erst am Prozessende zugewiesen
|
10 | end if;
|
11 | end loop;
|
12 | end if;
|
13 | end process;
|
Hier steht also eigentlich das da:
1 | CButton: process(button, clk1)
|
2 | begin
|
3 | if button'event and button='0' then
|
4 | if clk1'event and clk1='1' then
|
5 | tmp <= 100; -- am Prozessende hat i den Wert 100
|
6 | end if;
|
7 | if button='0' and pushed='1' then -- and i=100 unnötig, Grund s.o.
|
8 | button_control <= not(button_control);
|
9 | end if;
|
10 | end if;
|
11 | end process;
|
Davon abgesehen:
1 | CButton: process(button, clk1)
|
2 | begin
|
3 | if button'event and button='0' then
|
4 | :
|
5 | if clk1'event and clk1='1' then
|
6 | :
|
Ein Double-Clock-Flipflop? Sowas gibt es nicht.
Ein Tipp:
Du hast eigentlich alles falsch gemacht, was man in 10 Zeilen falsch
machen kann. Sieh dir doch einfach mal an, wie Andere das machen. Lies
dir ein Buch zu den Grundlagen programmierbarer Logik durch...
Z.B. VHDL-Synthese von Reichardt&Schwarz