Hallo, da ich mit der Simulation bzw. der korrekten Erzeugung eines Testbenchs immer Schwierigkeiten hatte, habe ich versucht, eine Funkuhr ohne Simulation zu programmieren. Zum Testen habe ich anhand mehrerer LEDs den Zustand der einzelnen Module überwacht. Allerdings ist der Code jetzt doch relativ umfangreich geworden, abgesehen davon habe ich Schwierigkeiten mit der Auswertung. Deswegen werde ich um eine richtige Simulation wohl nicht herum kommen. Zu meiner Frage: Wenn ich ein Testbench Waveform in ISE erstelle, habe ich ja nur eingeschränkte Möglichkeiten. Wie kann ich sinnvoll ein TB erstellen? Müsste ich das von Hand schreiben? Und, wie macht man das, dass man bestimmte Teile des Programms so schreibt, dass Sie nur für den Simulator sichtbar sind, und andere Teile, dass Sie nur für die Synthese sichtbar sind? Das wäre besonders für meine Taktteilungen wichtig, da ich das DCF-Signal mit 1 kHz abtaste, dies jedoch in der Simulation aufgrund der Auslastung Unfug wäre. Und ich will mir nicht jedes Mal neu überlegen, wie ich die Werte für die Taktteilung und Auswertung ändern muss, wenn ich nur simulieren möchte. Viele Grüße Andy
bestimmte teile kann man z.b. mit --pragma synthesis on/off für die synthese ein und ausschalten soweit ich weiß. die genauen pragmas und wie diese für ise bzw. modelsim lauten weiß ich nicht genau. müsste aber irgendwo in dem pdf-dschungel etwas zu finden sein. generell wirst du um eine simulation mit tb nicht drum herumkommen. hab im moment dasselbe problem. nur bei mir ists noch etwas grundlegender (kann z.b. keine instanziierten komponenten vernünftig simulieren). wenn du den dcf mit 1 khz tastest kannst du doch einfach die auflösung der tb ändern. müsste unter modelsim bei den projekteinstellungen stehen. du brauchst ja keine pico-sekunden. kannst den ja einfach auf us stellen und dann geht die simulation auch deutlich fixer. tbs werden eigentlich immer von hand geschrieben. bei der simulation hat man dann auch die ganzen möglichkeiten die sich in der hardware nicht synthetisieren lassen (dateien, gleitkommazahlen, prozeduren, wait anweisungen usw)
Hi, I want to simulate a CAN softcore written in Verilog, using ISE Simulator. I know how to construct an input signal by constructing the waveform provided by ISE simulator, however this method is not very efficient if one wants to give a long bit sequence as input (I am talking about over a 50 messages, each containing about 100 bits). However, it can be very easily done if i can give an input signal using an input file or something similar, in which i can list the input bytes and corresponding timings or something similar. I currently dont know of such a method and will highly appreciate if someone can guide me about it. Thanks and regards, Zeeshan
in der Testbench kannst du wie im folgenden Beispiel Files einbinden woraus dann die Inputs eingelesen werden können. file Input_Signal_Name: text open read_mode is"textfile.txt";
The suggested command was: file Input_Signal_Name: text open read_mode is"textfile.txt"; I wrote the following command in the Tcl Shell Window: file rd_i: text open read_mode is"inputfile.txt"; (assuming I should write the name of the input signal in place of 'Input_Signal_Name' and name of the input text file in place of "textfile.txt") the response I get is: bad option "rd_i:": must be atime, attributes, channels, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, link, lstat, mtime, mkdir, nativename, normalize, owned, pathtype, readable, readlink, rename, rootname, separator, size, split, stat, system, tail, type, volumes, or writable What am I doing wrong here ? How should I do it correctly ? I have already tried to search for the "file" command, but couldn't find anything helpful. Thanks.
write the following line direct into the architecture of the VHDL-testbench file. not in a TCL-script. file Input_Signal_Name: text open read_mode is"textfile.txt"; with commands like "read" or "readline" can you read from the file.
Can you point to some reading/help material, which lists and explains the commands (like the "read" and "readline" mentioned by you) related to VHDL Testbench file programming. Thanks again.
i have found these commands in an automatic generated testbench were all stimuli and results are in external ascii-files. the important parts of the testbench are following:
1 | library ieee; |
2 | use ieee.std_logic_1164.all; |
3 | use ieee.numeric_std.all; |
4 | use std.textio.all; |
5 | use IEEE.std_logic_textio.all; |
6 | |
7 | entity test_InvPend is |
8 | end test_InvPend; |
9 | |
10 | architecture beh of test_InvPend is |
11 | |
12 | component InvPend |
13 | port ( |
14 | clk : in std_logic; |
15 | GlobalReset : in std_logic; |
16 | GlobalEnable1 : in std_logic; |
17 | Control_Synplify_Port_In : in std_logic_vector(15 downto 0); |
18 | Control_Synplify_Port_In1 : in std_logic_vector(15 downto 0); |
19 | Control_Synplify_Port_In2 : in std_logic_vector(15 downto 0); |
20 | Control_Synplify_Port_Out : out std_logic_vector(15 downto 0) |
21 | );
|
22 | --
|
23 | end component; |
24 | .
|
25 | .
|
26 | .
|
27 | file logFile: text open write_mode is"simlog.txt"; |
28 | file Control_Synplify_Port_InFile: text open read_mode is"Inport_InvPend_Control_Synplify_Port_In.dat"; |
29 | file Control_Synplify_Port_In1File: text open read_mode is"Inport_InvPend_Control_Synplify_Port_In1.dat"; |
30 | file Control_Synplify_Port_In2File: text open read_mode is"Inport_InvPend_Control_Synplify_Port_In2.dat"; |
31 | file Control_Synplify_Port_OutRefFile: text open read_mode is"Outport_InvPend_Control_Synplify_Port_Out.dat"; |
32 | file Control_Synplify_Port_OutOutFile: text open write_mode is"Simout_InvPend_Control_Synplify_Port_Out.dat"; |
33 | .
|
34 | .
|
35 | .
|
36 | .
|
37 | -- Apply Input Vectors -----
|
38 | if (rising_edge(clk_int)) then |
39 | if (isNotFirstRise1) then |
40 | if (endfile(Control_Synplify_Port_InFile)) then |
41 | isSimulationEnd1 <= true; |
42 | else
|
43 | readline(Control_Synplify_Port_InFile, VectorLine); |
44 | read(VectorLine, tmp_Control_Synplify_Port_In, good => VectorValid); |
45 | Control_Synplify_Port_In_int <= tmp_Control_Synplify_Port_In; |
46 | end if; |
47 | end if; |
48 | if (isNotFirstRise1) then |
49 | if (endfile(Control_Synplify_Port_In1File)) then |
50 | isSimulationEnd1 <= true; |
51 | else
|
52 | readline(Control_Synplify_Port_In1File, VectorLine); |
53 | read(VectorLine, tmp_Control_Synplify_Port_In1, good => VectorValid); |
54 | Control_Synplify_Port_In1_int <= tmp_Control_Synplify_Port_In1; |
55 | end if; |
56 | end if; |
57 | if (isNotFirstRise1) then |
58 | if (endfile(Control_Synplify_Port_In2File)) then |
59 | isSimulationEnd1 <= true; |
60 | else
|
61 | readline(Control_Synplify_Port_In2File, VectorLine); |
62 | read(VectorLine, tmp_Control_Synplify_Port_In2, good => VectorValid); |
63 | Control_Synplify_Port_In2_int <= tmp_Control_Synplify_Port_In2; |
64 | end if; |
65 | end if; |
66 | end if; |
67 | if (rising_edge(clk_int) and (GlobalReset_int='0'))then |
68 | if(loop_cnt1 >= 0) then |
69 | if (endfile(Control_Synplify_Port_OutRefFile)) then |
70 | isSimulationEnd1 <= true; |
71 | else
|
72 | readline(Control_Synplify_Port_OutRefFile, VectorLine); |
73 | read(VectorLine, ref_Control_Synplify_Port_Out, good => VectorValid); |
74 | |
75 | tmp_Control_Synplify_Port_Out := Control_Synplify_Port_Out_int; |
76 | |
77 | write(OutLine, tmp_Control_Synplify_Port_Out); |
78 | writeline(Control_Synplify_Port_OutOutFile, OutLine); |
79 | |
80 | end if; |
81 | if(not(tmp_Control_Synplify_Port_Out = ref_Control_Synplify_Port_Out)) then |
82 | misFlg := TRUE; |
83 | write(OutLine, string'("Vector failed for port: Control_Synplify_Port_Out")); writeline(logFile, OutLine); |
84 | write(OutLine, string'("Expecting: ")); write(OutLine, ref_Control_Synplify_Port_Out); writeline(logFile, OutLine); |
85 | write(OutLine, string'("Actual: ")); write(OutLine, tmp_Control_Synplify_Port_Out); writeline(logFile, OutLine); |
86 | end if; |
87 | |
88 | if(misFlg) then |
89 | mismatch1 <= mismatch1 + 1; |
90 | write(OutLine, string'("Mismatch at clk cycle no ")); |
91 | write(OutLine, loop_cnt1); |
92 | writeline(logFile, OutLine); |
93 | write(OutLine, string'("-----------------------------")); |
94 | writeline(logFile, OutLine); |
95 | end if; |
96 | end if; |
97 | |
98 | loop_cnt1 <= loop_cnt1 + 1; |
99 | end if; |
100 | end process; |
i hope the code will help. i have no other material at the moment. look at the libraries. for these commands you need the std.textio library.
Thanks for the example code... Can you kindly send the complete testbench ? I will need it to understand e.g. the role of some of the temp variables etc.
if you can post an email adress, for exapmle one where you can put all your spam to, then can i send you the whole project files.
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.