Sie sind auf Seite 1von 12

1[Type text]

2
1 This tutorial provides a step-by-step guide to simulating a Verilog description of a 2-input AND gate
2 using Xilinx ISE 11.1
3 11.4.
4
5
1. Start Xilinx ISE Project Navigator
6
2. Create a new project
7
Click on File, then choose New Project on the drop down menu
8
Enter your project name, in this case the project is called AND2gate
9
Choose your project location, this project is stored at Z:\Projects\AND2gate
10
Leave the working directory entry blank.
11
Choose HDL as the source type from the Top-Level Source Type menu.
12
Click Next button
13

14
15
16
17
18
19
20
21
22
23
24
1

4[Type text]
5
25
26
273.You will be asked to select hardware and design flow for the project
28 For Family, choose Spartan3E
29
For Device, choose XC3S500E
30
For Package, choose FG320
31
For Speed, choose -4
32
For Simulator, choose ISim (VHDL/Verilog)
33
Click Next button
34
35
36
37

38
39
40
41
42
43
44
45
46
47
48
49 4.

A project summary will appear. Click on the Finish button.


2

7[Type text]
8
50

51
52
535. Now you will be have project named and2gate.v,nnext you want specify files within
54the files
55
56 Click on Simulation
57
58
59
60
61
62
63
64simulation
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
9

10[Type text]
11
81
82
83
84
85
86
87
88
89
906.
91
92
93
94
95

Now we want to add a new file to our project.


Click on Project, choose New Source
Choose Verilog Module as the file type

In the File name: box enter the desired file name, in this case the file is named
and2gate.v
Click on the Next button

96
97
98
99
1007. now you will be asked to give port names/types you can skip this step by clicking on NEXT button

12

13[Type text]
14

101
102
103
104
1058.
106
107
108
109

A project summary will appear. Click on the Finish button.

110
111
112
113
114
115
116
5

15

16[Type text]
17
117
118
119And2gate.v
120project
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146

added to

147
148
14910. Click on the and2gate.v tab to show the file contents. You are now ready to specify the
150and2gate modules functionality.
151
152
153
154
155
156
157
158
159
160
161
162
workspace
163
164
165
166
167
168
169
Click on and2gate.vtab
170
6

18

19[Type text]
20
171
172
173
174
175
176
177
178
179
180
181
182 11. Notice that the ISE has already entered a comments sections along with a couple of lines of code
183 for us.
184
The line `timescale 1ns/ 1ps is located at the top of the file. The Verilog language uses
185
dimensionless time units, and these time units are mapped to real time units within the
186
simulator. `timescale is used to map to the real time values using the statement
187
`timescale <time1> / <time2>, where <time1> indicates the time units associated with the
188
#delay values, and the <time2> indicates the minimum step time used by the simulator.
189
The and2gate module is also declared using module and2gate(); and endmodule, but
190
the ports are left for us to define.
191
We finish specifying the functionality of the and2gate module as shown below.
192
193
194
195
196
197
198
199
200
201
202
203
204
205
Module andgate(a,b,c);
206
Input a,b;
207
Output c;
208
Reg c;
209
always@(a,b)
210
begin
211
c=a&b;
212
end
213
endmodule
214
215
216
217
218
219
220
221
222
223
7

21

22[Type text]
23
224
225
226
227
228
229
230
231
23212.We also want to add test bench by following same procedure 8-11,then add functionality of it
233
234
timescale 1ns / 1p
235
module and2gate_tb();
236
reg A_t, B_t;
237
wire F_t;
238
239
and2gate and2gate_1(A_t, B_t, F_t);
240
241
initial begin
242
// case 0
243
A_t<=0; B_t<=0;
244
#1 $display("F_t = %b", F_t);
245
// case 1
246
A_t<=0; B_t<=1;
247
#1 $display("F_t = %b", F_t);
248
// case 2
249
A_t<=1; B_t<=0;
250
#1 $display("F_t = %b", F_t);
251
// case 3
252
A_t<=1; B_t<=1;
253
#1 $display("F_t = %b", F_t);
254

end

255

endmodue

24

25[Type text]
26

25613. After saving both and2gate.v and and2gate_tb.v, we want to check the syntax of
257both files.
258 Expand the ISim Simulator menu, double click on Behavioral Check Syntax
259 If the syntax was correct, a checkmark appears beside the Check Syntax menu
260 If the syntax was incorrect, the window at the bottom will list the individual errors.
261
262
263
264
265
266
267Expand Isim simulator
268and double click on the behavioural check syntax
269
270
271
272
273
274
275
276Errors will be displayed here
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298Double click in simulate behavior model
299
300
301
302
303
304
305
306
307
308
309

27

28[Type text]
29

310
31114. Now its time to simulate the design.
312 Double-click on the Simulate Behavioral Model icon
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
$display ,$monitor will be displayed here
338
339
34015. The ISim Simulator open in a new windows displaying a waveform and run a default
341simulation for some number of time units. We can now check the and2gate modules
342functionality. Further, the $display statements included in the testbench appear in the lower
343window.
344
345
346
347
348
349
350
351
352
353
354
355
35616. To view the beginning of simulation, click on the Go To Time 0 button.

30

31[Type text]
32

357
358
359
360
361
362

Click on go to

363

Time button

364
365
366
367
368
369
370
371
372
373
374
37517. We can now see the simulation waveform for the beginning of our simulation. Click on
376the Zoom Out button until you see the waveform shown in the image below.
377
378
379
380
381
382
383
384
385
386
387
388
Click on zoom out button
389
390
391
392
393
394
395
396
397
398
399
400
401
40218. To control the simulation time, we can restart the simulation and simulate for a specific
403length of time. Either click on the Restart button or select Restart from the Simulation menu.
404We will now have an empty waveform.

33

34[Type text]
35

405
406
407
408
409
410
411
412
413
414
415
416
417
418
Click on restart button
419
420
421
422
423
424
425
426
427
428
429
430
431
432
43319. To simulate for a specific length of time, enter the desired simulation time and
434click on the Run for the time specified in the toolbar button. In our case, we want to
435simulate for 10 ns.
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
Enter simulation time and click on run for
459
460
461

36

Das könnte Ihnen auch gefallen