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 13

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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