Ich habe gerade Folgendes festgestellt: Wenn Ich einen 16 Bit Vector, also "15 downto 0" mit einem zu großen Wert initialisiere, erhalte ich umgeklappte Werte: negative_maximum <= std_logic_vector (to_signed (-32769,16)); liefert einen Wert von 32767 positiv und damit funktioniert nichts. Aus Bit-Sichtweise ist es richtig, was da passiert, aber sollte der Compiler nicht erkennen, dass die Initialisierung falsch ist? Es ist ja ein Überlauf?
W.S. schrieb: > sollte der Compiler nicht erkennen, dass die Initialisierung falsch ist? Das macht der Simulator:
1 | # Loading std.standard |
2 | # Loading std.textio(body) |
3 | # Loading ieee.std_logic_1164(body) |
4 | # Loading ieee.numeric_std(body) |
5 | # Loading work.test_negative_overflow(test)#1 |
6 | run -all |
7 | # ** Warning: NUMERIC_STD.TO_SIGNED: vector truncated |
8 | # Time: 0 ps Iteration: 0 Instance: /test_negative_overflow |
Duke
Das ist schön! Was ist das für ein Compiler? Ich verwende den ModelSIM Altera und der meldet "no Errors , no warnings" - die files sind alle auf "check Synthesis" gesetzt - "suppress warnings" ist sowohl für die IEEE als uch Synopsis AUS - bei "report warnings" sind alle 5 check boxen aktiv was kann man noch tun?
W.S. schrieb: > was kann man noch tun? Das Design simulieren (run -all). Dabei kommt das Problem ans Licht.
Markus F. schrieb: > W.S. schrieb: >> was kann man noch tun? > > Das Design simulieren (run -all). Dabei kommt das Problem ans Licht. Genau, bei dem Problem handelt es sich aus VHDL/Modelsim-Sicht um ein Laufzeitfehler und kein Compilefehler. Das '<=' ist eine Signalzuweisung, wird also erst zur Laufzeit "ausgeführt"; bei ":=" also Variablen, Constanten erfolgt dagegen die Ausführung "sofort". Es ist also keine "Initialisierung" wie der TO es nennt. Bei Initialisierungen wird ein ":=" verwendet. Das Problem liegt wohl auch darin, das der TO von einem "Compiler" im Sinne von C-Compoiler spricht. Es aber ein Simulator/Interpreter oder ein Synthesetool ist das den VHDL-Code verarbeitet. besser könnte es also sein, hier nicht von "Compiler" zu sprechen. > was kann man noch tun? Den Code durch das Synthesetool jagen, das könnte eine Warning/Info in den Syntheseloogs hinterlassen.
C. A. Rotwang schrieb: > Den Code durch das Synthesetool jagen, das könnte eine Warning/Info in > den Syntheseloogs hinterlassen. Schön wärs, wenn da der Output brauchbar wäre. Leider wird man gerade bei Xilinx mit Warnungen nur so zugeschüttet. Die wirklich wichtgen Warnungen muß ich mir mit grep aus den log-Dateien ziehen. > Das '<=' ist eine Signalzuweisung, wird also erst zur Laufzeit > "ausgeführt"; bei ":=" also Variablen, Constanten > erfolgt dagegen die Ausführung "sofort". Ja, aber der Modelsimcompiler meckert trotzdem nicht. Dafür warnt der Simulator (vsim und run -all) jetzt zweimal... W.S. schrieb: > was kann man noch tun? Du könntest mal GHDL probieren. Da werden teilweise verständlichere Fehlermeldungen generiert. Duke
Duke Scarring schrieb: > Das macht der Simulator Active HDL sagt dazu:
1 | # Simulation has been initialized |
2 | # Selected Top-Level: test_negative_overflow (test) |
3 | run |
4 | # KERNEL: WARNING: NUMERIC_STD.TO_SIGNED: vector truncated |
5 | # KERNEL: Time: 0 ps, Iteration: 0, Instance: /test_negative_overflow, Process: line__13. |
6 | # KERNEL: Simulation has finished. There are no more test vectors to simulate. |
Diese Meldung kommt aus der numeric_std:
1 | -- Id: D.4
|
2 | function TO_SIGNED(ARG: INTEGER; SIZE: NATURAL) return SIGNED is |
3 | variable RESULT: SIGNED (SIZE-1 downto 0) ; |
4 | variable b_val : STD_LOGIC:= '0' ; |
5 | variable i_val : INTEGER:= ARG ; |
6 | begin
|
7 | if (SIZE < 1) then return NAS; end if; |
8 | if (ARG<0) then |
9 | b_val := '1' ; |
10 | i_val := -(ARG+1) ; |
11 | end if ; |
12 | for i in 0 to RESULT'left loop |
13 | if (i_val MOD 2) = 0 then |
14 | RESULT(i) := b_val; |
15 | else
|
16 | RESULT(i) := not b_val ; |
17 | end if; |
18 | i_val := i_val/2 ; |
19 | end loop; |
20 | if ((i_val/=0) or (b_val/=RESULT(RESULT'left))) then |
21 | assert NO_WARNING |
22 | report "numeric_std.TO_SIGNED : vector truncated" --<<<----- |
23 | severity WARNING ; |
24 | end if; |
25 | return RESULT; |
26 | end TO_SIGNED; |
C. A. Rotwang schrieb: > Es ist also keine "Initialisierung" wie der TO es nennt. Bei > Initialisierungen wird ein ":=" verwendet. Und blöderweise stört sich nicht jeder Compiler an der fehlerhaften Initialisierung, und gibt auch die Warnung aus der numeric_std nicht aus... Duke Scarring schrieb: > Dafür warnt der Simulator (vsim und run -all) jetzt zweimal... Der Compiler vom Active-HDL stört sich auch nicht an der Initialisierung (0 Errors, 0 Warnings). Aber der Simulator warnt zweimal, einmal bei der Elaboration (wg. Initialisierung) und einmal zur Runtime (wg Zuweisung). Man muss aber auch dort schon sehr genau hinschauen:
1 | restart |
2 | # ELBREAD: Elaboration process. |
3 | # ELBREAD: Elaboration time 0.0 [s]. |
4 | # |
5 | # KERNEL: Main thread initiated. |
6 | # KERNEL: Kernel process initialization phase. |
7 | # KERNEL: Time resolution set to 1ps. |
8 | # ELAB2: Elaboration final pass... |
9 | # ELAB2: Create instances ... |
10 | # KERNEL: WARNING: NUMERIC_STD.TO_SIGNED: vector truncated |
11 | # KERNEL: Time: 0 ps, Iteration: 0, TOP instance. |
12 | # ELAB2: Create instances complete. |
13 | # SLP: Started |
14 | # SLP: Elaboration phase ... |
15 | # SLP: Elaboration phase ... skipped, nothing to simulate in SLP mode : 0.0 [s] |
16 | # SLP: Finished : 0.0 [s] |
17 | # ELAB2: Elaboration final pass complete - time: 0.0 [s]. |
18 | # KERNEL: Warning: You are using the Active-HDL Lattice Edition. The performance of simulation is running at a reduced rate. |
19 | # KERNEL: Warning: Contact Aldec for available upgrade options - sales@aldec.com. |
20 | # KERNEL: Kernel process initialization done. |
21 | # Allocation: Simulator allocated 5948 kB (elbread=1023 elab2=4775 kernel=149 sdf=0) |
22 | # KERNEL: ASDB file was created in location C:\Projekte\FPGA\Lattice\ConversionOverflow\neg_overflow\src\wave.asdb |
23 | # 12:50, Mittwoch, 13. September 2017 |
24 | # Simulation has been initialized |
25 | # Selected Top-Level: test_negative_overflow (test) |
26 | # Waveform file 'untitled.awc' connected to 'C:/Projekte/FPGA/Lattice/ConversionOverflow/neg_overflow/src/wave.asdb'. |
27 | run 100 ns |
28 | # KERNEL: WARNING: NUMERIC_STD.TO_SIGNED: vector truncated |
29 | # KERNEL: Time: 0 ps, Iteration: 0, Instance: /test_negative_overflow, Process: line__13. |
30 | # KERNEL: stopped at time: 100 ns |
31 | # KERNEL: Simulation has finished. There are no more test vectors to simulate. |
:
Bearbeitet durch Moderator
Duke Scarring schrieb: > W.S. schrieb: >> was kann man noch tun? > Du könntest mal GHDL probieren. Da werden teilweise verständlichere Das wäre eine Möglichkeit, ja. Wobei: Bisher hatte Ich eigentlich schon Vertrauen in den ModelSIM.
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
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.