OpenCores
URL https://opencores.org/ocsvn/gpib_controller/gpib_controller/trunk

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [vhdl/] [test/] [gpib_SeriallPoll_Test.vhd] - Blame information for rev 5

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 Andrewski
--------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer:
4
--
5
-- Create Date:   23:21:05 10/21/2011
6
-- Design Name:   
7
-- Module Name:   /windows/h/projekty/elektronika/USB_to_HPIB/usbToHpib/test_scr//gpibInterfaceTest.vhd
8
-- Project Name:  usbToHpib
9
-- Target Device:  
10
-- Tool versions:  
11
-- Description:   
12
-- 
13
-- VHDL Test Bench Created by ISE for module: gpibInterface
14
-- 
15
-- Dependencies:
16
-- 
17
-- Revision:
18
-- Revision 0.01 - File Created
19
-- Additional Comments:
20
--
21
-- Notes: 
22
-- This testbench has been automatically generated using types std_logic and
23
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends
24
-- that these types always be used for the top-level I/O of a design in order
25
-- to guarantee that the testbench will bind correctly to the post-implementation 
26
-- simulation model.
27
--------------------------------------------------------------------------------
28
LIBRARY ieee;
29
USE ieee.std_logic_1164.ALL;
30
USE ieee.std_logic_unsigned.all;
31
USE ieee.numeric_std.ALL;
32
use ieee.std_logic_arith.all;
33
 
34
use work.gpibComponents.all;
35
use work.helperComponents.all;
36
 
37
 
38
ENTITY gpib_SeriallPoll_Test IS
39
END gpib_SeriallPoll_Test;
40
 
41
ARCHITECTURE behavior OF gpib_SeriallPoll_Test IS
42
 
43
        -- Component Declaration for the Unit Under Test (UUT)
44
 
45
        component gpibCableEmulator is port (
46
                -- interface signals
47
                DIO_1 : in std_logic_vector (7 downto 0);
48
                output_valid_1 : in std_logic;
49
                DIO_2 : in std_logic_vector (7 downto 0);
50
                output_valid_2 : in std_logic;
51
                DIO : out std_logic_vector (7 downto 0);
52
                -- attention
53
                ATN_1 : in std_logic;
54
                ATN_2 : in std_logic;
55
                ATN : out std_logic;
56
                -- data valid
57
                DAV_1 : in std_logic;
58
                DAV_2 : in std_logic;
59
                DAV : out std_logic;
60
                -- not ready for data
61
                NRFD_1 : in std_logic;
62
                NRFD_2 : in std_logic;
63
                NRFD : out std_logic;
64
                -- no data accepted
65
                NDAC_1 : in std_logic;
66
                NDAC_2 : in std_logic;
67
                NDAC : out std_logic;
68
                -- end or identify
69
                EOI_1 : in std_logic;
70
                EOI_2 : in std_logic;
71
                EOI : out std_logic;
72
                -- service request
73
                SRQ_1 : in std_logic;
74
                SRQ_2 : in std_logic;
75
                SRQ : out std_logic;
76
                -- interface clear
77
                IFC_1 : in std_logic;
78
                IFC_2 : in std_logic;
79
                IFC : out std_logic;
80
                -- remote enable
81
                REN_1 : in std_logic;
82
                REN_2 : in std_logic;
83
                REN : out std_logic
84
        );
85
        end component;
86
 
87
        -- inputs common
88
        signal clk : std_logic := '0';
89
        signal reset : std_logic := '0';
90
        signal T1 : std_logic_vector(7 downto 0) := "00000100";
91
 
92
        -- inputs 1
93
        signal data_1 : std_logic_vector(7 downto 0) := (others => '0');
94
        signal status_byte_1 : std_logic_vector(7 downto 0) := (others => '0');
95
        signal rdy_1 : std_logic := '0';
96
        signal nba_1 : std_logic := '0';
97
        signal ltn_1 : std_logic := '0';
98
        signal lun_1 : std_logic := '0';
99
        signal lon_1 : std_logic := '0';
100
        signal ton_1 : std_logic := '0';
101
        signal endOf_1 : std_logic := '0';
102
        signal gts_1 : std_logic := '0';
103
        signal rpp_1 : std_logic := '0';
104
        signal tcs_1 : std_logic := '0';
105
        signal tca_1 : std_logic := '0';
106
        signal sic_1 : std_logic := '0';
107
        signal rsc_1 : std_logic := '0';
108
        signal sre_1 : std_logic := '0';
109
        signal rtl_1 : std_logic := '0';
110
        signal rsv_1 : std_logic := '0';
111
        signal ist_1 : std_logic := '0';
112
        signal lpe_1 : std_logic := '0';
113
 
114
        -- inputs 2
115
        signal lpeUsed_2 : std_logic := '0';
116
        signal data_2 : std_logic_vector(7 downto 0) := (others => '0');
117
        signal status_byte_2 : std_logic_vector(7 downto 0) := (others => '0');
118
        signal rdy_2 : std_logic := '0';
119
        signal nba_2 : std_logic := '0';
120
        signal ltn_2 : std_logic := '0';
121
        signal lun_2 : std_logic := '0';
122
        signal lon_2 : std_logic := '0';
123
        signal ton_2 : std_logic := '0';
124
        signal endOf_2 : std_logic := '0';
125
        signal gts_2 : std_logic := '0';
126
        signal rpp_2 : std_logic := '0';
127
        signal tcs_2 : std_logic := '0';
128
        signal tca_2 : std_logic := '0';
129
        signal sic_2 : std_logic := '0';
130
        signal rsc_2 : std_logic := '0';
131
        signal sre_2 : std_logic := '0';
132
        signal rtl_2 : std_logic := '0';
133
        signal rsv_2 : std_logic := '0';
134
        signal ist_2 : std_logic := '0';
135
        signal lpe_2 : std_logic := '0';
136
 
137
        -- outputs 1
138
        signal dvd_1 : std_logic;
139
        signal wnc_1 : std_logic;
140
        signal tac_1 : std_logic;
141
        signal lac_1 : std_logic;
142
        signal cwrc_1 : std_logic;
143
        signal cwrd_1 : std_logic;
144
        signal clr_1 : std_logic;
145
        signal trg_1 : std_logic;
146
        signal atl_1 : std_logic;
147
        signal att_1 : std_logic;
148
        signal mla_1 : std_logic;
149
        signal lsb_1 : std_logic;
150
        signal spa_1 : std_logic;
151
        signal ppr_1 : std_logic;
152
        signal sreq_1 : std_logic;
153
        signal isLocal_1 : std_logic;
154
        signal currentSecAddr_1 : std_logic_vector (4 downto 0);
155
 
156
        -- outputs 2
157
        signal dvd_2 : std_logic;
158
        signal wnc_2 : std_logic;
159
        signal tac_2 : std_logic;
160
        signal lac_2 : std_logic;
161
        signal cwrc_2 : std_logic;
162
        signal cwrd_2 : std_logic;
163
        signal clr_2 : std_logic;
164
        signal trg_2 : std_logic;
165
        signal atl_2 : std_logic;
166
        signal att_2 : std_logic;
167
        signal mla_2 : std_logic;
168
        signal lsb_2 : std_logic;
169
        signal spa_2 : std_logic;
170
        signal ppr_2 : std_logic;
171
        signal sreq_2 : std_logic;
172
        signal isLocal_2 : std_logic;
173
        signal currentSecAddr_2 : std_logic_vector (4 downto 0);
174
 
175
        -- common
176
        signal DO : std_logic_vector (7 downto 0);
177
        signal DI_1 : std_logic_vector (7 downto 0);
178
        signal output_valid_1 : std_logic;
179
        signal DI_2 : std_logic_vector (7 downto 0);
180
        signal output_valid_2 : std_logic;
181
        signal ATN_1, ATN_2, ATN : std_logic;
182
        signal DAV_1, DAV_2, DAV : std_logic;
183
        signal NRFD_1, NRFD_2, NRFD : std_logic;
184
        signal NDAC_1, NDAC_2, NDAC : std_logic;
185
        signal EOI_1, EOI_2, EOI : std_logic;
186
        signal SRQ_1, SRQ_2, SRQ : std_logic;
187
        signal IFC_1, IFC_2, IFC : std_logic;
188
        signal REN_1, REN_2, REN : std_logic;
189
 
190
        -- gpib reader 1
191
        signal rd1_buf_interrupt : std_logic;
192
        signal rd1_data_available : std_logic;
193
        signal rd1_last_byte_addr : std_logic_vector (3 downto 0);
194
        signal rd1_end_of_stream : std_logic;
195
        signal rd1_byte_addr : std_logic_vector (3 downto 0);
196
        signal rd1_data_out : std_logic_vector (7 downto 0);
197
        signal rd1_reset_buffer : std_logic := '0';
198
        signal dataSecAddr_1 : std_logic_vector (4 downto 0);
199
 
200
        -- gpib reader 2
201
        signal buf_interrupt : std_logic;
202
        signal data_available : std_logic;
203
        signal last_byte_addr : std_logic_vector (3 downto 0);
204
        signal end_of_stream : std_logic;
205
        signal byte_addr : std_logic_vector (3 downto 0);
206
        signal data_out : std_logic_vector (7 downto 0);
207
        signal reset_buffer : std_logic := '0';
208
        signal dataSecAddr_2 : std_logic_vector (4 downto 0);
209
 
210
        -- gpib writer
211
        signal w_last_byte_addr : std_logic_vector (3 downto 0)
212
                := (others => '0');
213
        signal w_end_of_stream : std_logic := '0';
214
        signal w_data_available : std_logic := '0';
215
        signal w_buf_interrupt : std_logic;
216
        signal w_data_in : std_logic_vector (7 downto 0);
217
        signal w_byte_addr : std_logic_vector (3 downto 0);
218
        signal w_reset_buffer : std_logic := '0';
219
        type WR_BUF_TYPE is
220
                array (0 to 15) of std_logic_vector (7 downto 0);
221
        signal w_write_buffer : WR_BUF_TYPE;
222
 
223
        -- gpib writer 2
224
        signal w_last_byte_addr_2 : std_logic_vector (3 downto 0)
225
                := (others => '0');
226
        signal w_end_of_stream_2 : std_logic := '0';
227
        signal w_data_available_2 : std_logic := '0';
228
        signal w_buf_interrupt_2 : std_logic;
229
        signal w_data_in_2 : std_logic_vector (7 downto 0);
230
        signal w_byte_addr_2 : std_logic_vector (3 downto 0);
231
        signal w_reset_buffer_2 : std_logic := '0';
232
        type WR_BUF_TYPE_2 is
233
                array (0 to 15) of std_logic_vector (7 downto 0);
234
        signal w_write_buffer_2 : WR_BUF_TYPE;
235
 
236
        -- serial poll coordinator
237
        signal rec_stb : std_logic := '0';
238
        signal stb_received : std_logic;
239
        signal spc_ATN_in : std_logic;
240
        signal spc_out_valid_in : std_logic;
241
 
242
        -- Clock period definitions
243
        constant clk_period : time := 2ps;
244
 
245
BEGIN
246
 
247
        -- Instantiate the Unit Under Test (UUT)
248
        gpib1: gpibInterface PORT MAP (
249
                clk => clk,
250
                reset => reset,
251
                isLE => '0',
252
                isTE => '0',
253
                lpeUsed => '0',
254
                fixedPpLine => "000",
255
                eosUsed => '0',
256
                eosMark => "00000000",
257
                myListAddr => "00001",
258
                myTalkAddr => "00001",
259
                secAddrMask => (others => '0'),
260
                data => data_1,
261
                status_byte => status_byte_1,
262
                T1 => T1,
263
                rdy => rdy_1,
264
                nba => nba_1,
265
                ltn => ltn_1,
266
                lun => lun_1,
267
                lon => lon_1,
268
                ton => ton_1,
269
                endOf => endOf_1,
270
                gts => gts_1,
271
                rpp => rpp_1,
272
                tcs => tcs_1,
273
                tca => tca_1,
274
                sic => sic_1,
275
                rsc => rsc_1,
276
                sre => sre_1,
277
                rtl => rtl_1,
278
                rsv => rsv_1,
279
                ist => ist_1,
280
                lpe => lpe_1,
281
                dvd => dvd_1,
282
                wnc => wnc_1,
283
                tac => tac_1,
284
                lac => lac_1,
285
                cwrc => cwrc_1,
286
                cwrd => cwrd_1,
287
                clr => clr_1,
288
                trg => trg_1,
289
                atl => atl_1,
290
                att => att_1,
291
                mla => mla_1,
292
                lsb => lsb_1,
293
                spa => spa_1,
294
                ppr => ppr_1,
295
                sreq => sreq_1,
296
                isLocal => isLocal_1,
297
                currentSecAddr => currentSecAddr_1,
298
                DI => DO,
299
                DO => DI_1,
300
                output_valid => spc_out_valid_in,
301
                ATN_in => ATN,
302
                ATN_out => spc_ATN_in,
303
                DAV_in => DAV,
304
                DAV_out => DAV_1,
305
                NRFD_in => NRFD,
306
                NRFD_out => NRFD_1,
307
                NDAC_in => NDAC,
308
                NDAC_out => NDAC_1,
309
                EOI_in => EOI,
310
                EOI_out => EOI_1,
311
                SRQ_in => SRQ,
312
                SRQ_out => SRQ_1,
313
                IFC_in => IFC,
314
                IFC_out => IFC_1,
315
                REN_in => REN,
316
                REN_out => REN_1
317
                );
318
 
319
        -- Instantiate the Unit Under Test (UUT)
320
        gpib2: gpibInterface PORT MAP (
321
                clk => clk,
322
                reset => reset,
323
                isLE => '0',
324
                isTE => '0',
325
                lpeUsed => lpeUsed_2,
326
                fixedPpLine => "001",
327
                eosUsed => '0',
328
                eosMark => "00000000",
329
                myListAddr => "00010",
330
                myTalkAddr => "00010",
331
                secAddrMask => (others => '0'),
332
                data => data_2,
333
                status_byte => status_byte_2,
334
                T1 => T1,
335
                rdy => rdy_2,
336
                nba => nba_2,
337
                ltn => ltn_2,
338
                lun => lun_2,
339
                lon => lon_2,
340
                ton => ton_2,
341
                endOf => endOf_2,
342
                gts => gts_2,
343
                rpp => rpp_2,
344
                tcs => tcs_2,
345
                tca => tca_2,
346
                sic => sic_2,
347
                rsc => rsc_2,
348
                sre => sre_2,
349
                rtl => rtl_2,
350
                rsv => rsv_2,
351
                ist => ist_2,
352
                lpe => lpe_2,
353
                dvd => dvd_2,
354
                wnc => wnc_2,
355
                tac => tac_2,
356
                lac => lac_2,
357
                cwrc => cwrc_2,
358
                cwrd => cwrd_2,
359
                clr => clr_2,
360
                trg => trg_2,
361
                atl => atl_2,
362
                att => att_2,
363
                mla => mla_2,
364
                lsb => lsb_2,
365
                spa => spa_2,
366
                ppr => ppr_2,
367
                sreq => sreq_2,
368
                isLocal => isLocal_2,
369
                currentSecAddr => currentSecAddr_2,
370
                DI => DO,
371
                DO => DI_2,
372
                output_valid => output_valid_2,
373
                ATN_in => ATN,
374
                ATN_out => ATN_2,
375
                DAV_in => DAV,
376
                DAV_out => DAV_2,
377
                NRFD_in => NRFD,
378
                NRFD_out => NRFD_2,
379
                NDAC_in => NDAC,
380
                NDAC_out => NDAC_2,
381
                EOI_in => EOI,
382
                EOI_out => EOI_2,
383
                SRQ_in => SRQ,
384
                SRQ_out => SRQ_2,
385
                IFC_in => IFC,
386
                IFC_out => IFC_2,
387
                REN_in => REN,
388
                REN_out => REN_2
389
                );
390
 
391
        ce: gpibCableEmulator port map (
392
                -- interface signals
393
                DIO_1 => DI_1,
394
                output_valid_1 => output_valid_1,
395
                DIO_2 => DI_2,
396
                output_valid_2 => output_valid_2,
397
                DIO => DO,
398
                -- attention
399
                ATN_1 => ATN_1, ATN_2 => ATN_2, ATN => ATN,
400
                DAV_1 => DAV_1, DAV_2 => DAV_2, DAV => DAV,
401
                NRFD_1 => NRFD_1, NRFD_2 => NRFD_2, NRFD => NRFD,
402
                NDAC_1 => NDAC_1, NDAC_2 => NDAC_2, NDAC => NDAC,
403
                EOI_1 => EOI_1, EOI_2 => EOI_2, EOI => EOI,
404
                SRQ_1 => SRQ_1, SRQ_2 => SRQ_2, SRQ => SRQ,
405
                IFC_1 => IFC_1, IFC_2 => IFC_2, IFC => IFC,
406
                REN_1 => REN_1, REN_2 => REN_2, REN => REN
407
        );
408
 
409
        gr1: gpibReader generic map (ADDR_WIDTH => 4) port map (
410
                clk => clk, reset => reset,
411
                ------------------------------------------------------------------------
412
                ------ GPIB interface --------------------------------------------------
413
                ------------------------------------------------------------------------
414
                data_in => DO, dvd => dvd_1, lac => lac_1, lsb => lsb_1, rdy => rdy_1,
415
                ------------------------------------------------------------------------
416
                ------ external interface ----------------------------------------------
417
                ------------------------------------------------------------------------
418
                isLE => '0', secAddr => (others => '0'), dataSecAddr => dataSecAddr_1,
419
                buf_interrupt => rd1_buf_interrupt, data_available => rd1_data_available,
420
                last_byte_addr => rd1_last_byte_addr, end_of_stream => rd1_end_of_stream,
421
                byte_addr => rd1_byte_addr, data_out => rd1_data_out,
422
                reset_buffer => rd1_reset_buffer
423
        );
424
 
425
        gr2: gpibReader generic map (ADDR_WIDTH => 4) port map (
426
                clk => clk, reset => reset,
427
                ------------------------------------------------------------------------
428
                ------ GPIB interface --------------------------------------------------
429
                ------------------------------------------------------------------------
430
                data_in => DO, dvd => dvd_2, lac => lac_2, lsb => lsb_2, rdy => rdy_2,
431
                ------------------------------------------------------------------------
432
                ------ external interface ----------------------------------------------
433
                ------------------------------------------------------------------------
434
                isLE => '0', secAddr => (others => '0'), dataSecAddr => dataSecAddr_2,
435
                buf_interrupt => buf_interrupt, data_available => data_available,
436
                last_byte_addr => last_byte_addr, end_of_stream => end_of_stream,
437
                byte_addr => byte_addr, data_out => data_out,
438
                reset_buffer => reset_buffer
439
        );
440
 
441
        w_data_in <= w_write_buffer(conv_integer(w_byte_addr));
442
 
443
        gw: gpibWriter generic map (ADDR_WIDTH => 4) port map (
444
                clk => clk, reset => reset,
445
                ------------------------------------------------------------------------
446
                ------ GPIB interface --------------------------------------------------
447
                ------------------------------------------------------------------------
448
                data_out => data_1, wnc => wnc_1, spa => spa_1, nba => nba_1,
449
                endOf => endOf_1, tac => tac_1, cwrc => cwrc_1,
450
                ------------------------------------------------------------------------
451
                ------ external interface ----------------------------------------------
452
                ------------------------------------------------------------------------
453
                isTE => '0', secAddr => (others => '0'), dataSecAddr => (others => '0'),
454
                last_byte_addr => w_last_byte_addr, end_of_stream => w_end_of_stream,
455
                data_available => w_data_available, buf_interrupt => w_buf_interrupt,
456
                data_in => w_data_in, byte_addr => w_byte_addr,
457
                reset_buffer => w_reset_buffer
458
        );
459
 
460
        w_data_in <= w_write_buffer(conv_integer(w_byte_addr));
461
 
462
        gw2: gpibWriter generic map (ADDR_WIDTH => 4) port map (
463
                clk => clk, reset => reset,
464
                ------------------------------------------------------------------------
465
                ------ GPIB interface --------------------------------------------------
466
                ------------------------------------------------------------------------
467
                data_out => data_2, wnc => wnc_2, spa => spa_2, nba => nba_2,
468
                endOf => endOf_2, tac => tac_2, cwrc => cwrc_2,
469
                ------------------------------------------------------------------------
470
                ------ external interface ----------------------------------------------
471
                ------------------------------------------------------------------------
472
                isTE => '0', secAddr => (others => '0'), dataSecAddr => (others => '0'),
473
                last_byte_addr => w_last_byte_addr_2, end_of_stream => w_end_of_stream_2,
474
                data_available => w_data_available_2, buf_interrupt => w_buf_interrupt_2,
475
                data_in => w_data_in_2, byte_addr => w_byte_addr_2,
476
                reset_buffer => w_reset_buffer_2
477
        );
478
 
479
        spc1: SerialPollCoordinator port map ( clk => clk, reset=> reset,
480
                DAC => not NDAC,
481
                -- receive status byte
482
                rec_stb => rec_stb,
483
                -- attention in
484
                ATN_in => spc_ATN_in,
485
                -- attention out
486
                ATN_out => ATN_1,
487
                output_valid_in => spc_out_valid_in,
488
                output_valid_out => output_valid_1,
489
                -- stb received
490
                stb_received => stb_received
491
        );
492
 
493
        --ATN_1 <= spc_ATN_in;
494
 
495
        -- Clock process definitions
496
        clk_process :process
497
        begin
498
                clk <= '0';
499
                wait for clk_period/2;
500
                clk <= '1';
501
                wait for clk_period/2;
502
        end process;
503
 
504
 
505
        -- Stimulus process
506
        stim_proc: process
507
        begin
508
                -- hold reset state for 10 clock periods.
509
                reset <= '1';
510
                wait for clk_period*10;
511
                reset <= '0';
512
                wait for clk_period*10;
513
 
514
                -- requests system control
515
                rsc_1 <= '1';
516
                -- interface clear
517
                sic_1 <= '1';
518
                wait until IFC_1 = '1';
519
                sic_1 <= '0';
520
                wait until IFC_1 = '0';
521
 
522
                rsv_2 <= '1';
523
                status_byte_2 <= "10010101";
524
 
525
                assert sreq_1 = '0';
526
                assert sreq_2 = '0';
527
 
528
                wait until sreq_1 = '1';
529
 
530
                assert sreq_1 = '1';
531
                assert sreq_2 = '0';
532
 
533
                -- gpib2 to talk
534
                w_write_buffer(0) <= "01000010";
535
                -- gpib1 to listen
536
                w_write_buffer(1) <= "00100001";
537
                -- serial poll enable
538
                w_write_buffer(2) <= "00011000";
539
                w_last_byte_addr <= "0010";
540
                w_data_available <= '1';
541
 
542
                wait until w_buf_interrupt = '1';
543
 
544
 
545
                rec_stb <= '1';
546
 
547
                wait until stb_received = '1';
548
 
549
                rec_stb <= '0';
550
 
551
                wait for clk_period*1;
552
 
553
                rd1_byte_addr <= conv_std_logic_vector(0, 4);
554
 
555
                wait for clk_period*1;
556
 
557
                assert rd1_data_out = "11010101";
558
 
559
                assert rd1_last_byte_addr = "0000";
560
 
561
                assert rd1_data_available = '1';
562
 
563
                report "$$$ END OF TEST - serial poll $$$";
564
 
565
                wait;
566
        end process;
567
 
568
END;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.