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

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [vhdl/] [test/] [gpib_TE_LE_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
 
33
use work.gpibComponents.all;
34
use work.helperComponents.all;
35
 
36
 
37
ENTITY gpib_TE_LE_Test IS
38
END gpib_TE_LE_Test;
39
 
40
ARCHITECTURE behavior OF gpib_TE_LE_Test IS
41
 
42
        -- Component Declaration for the Unit Under Test (UUT)
43
 
44
        component gpibCableEmulator is port (
45
                -- interface signals
46
                DIO_1 : in std_logic_vector (7 downto 0);
47
                output_valid_1 : in std_logic;
48
                DIO_2 : in std_logic_vector (7 downto 0);
49
                output_valid_2 : in std_logic;
50
                DIO : out std_logic_vector (7 downto 0);
51
                -- attention
52
                ATN_1 : in std_logic;
53
                ATN_2 : in std_logic;
54
                ATN : out std_logic;
55
                -- data valid
56
                DAV_1 : in std_logic;
57
                DAV_2 : in std_logic;
58
                DAV : out std_logic;
59
                -- not ready for data
60
                NRFD_1 : in std_logic;
61
                NRFD_2 : in std_logic;
62
                NRFD : out std_logic;
63
                -- no data accepted
64
                NDAC_1 : in std_logic;
65
                NDAC_2 : in std_logic;
66
                NDAC : out std_logic;
67
                -- end or identify
68
                EOI_1 : in std_logic;
69
                EOI_2 : in std_logic;
70
                EOI : out std_logic;
71
                -- service request
72
                SRQ_1 : in std_logic;
73
                SRQ_2 : in std_logic;
74
                SRQ : out std_logic;
75
                -- interface clear
76
                IFC_1 : in std_logic;
77
                IFC_2 : in std_logic;
78
                IFC : out std_logic;
79
                -- remote enable
80
                REN_1 : in std_logic;
81
                REN_2 : in std_logic;
82
                REN : out std_logic
83
        );
84
        end component;
85
 
86
        -- inputs common
87
        signal clk : std_logic := '0';
88
        signal reset : std_logic := '0';
89
        signal T1 : std_logic_vector(7 downto 0) := "00000100";
90
 
91
        -- inputs 1
92
        signal data_1 : std_logic_vector(7 downto 0) := (others => '0');
93
        signal status_byte_1 : std_logic_vector(7 downto 0) := (others => '0');
94
        signal rdy_1 : std_logic := '0';
95
        signal nba_1 : std_logic := '0';
96
        signal ltn_1 : std_logic := '0';
97
        signal lun_1 : std_logic := '0';
98
        signal lon_1 : std_logic := '0';
99
        signal ton_1 : std_logic := '0';
100
        signal endOf_1 : std_logic := '0';
101
        signal gts_1 : std_logic := '0';
102
        signal rpp_1 : std_logic := '0';
103
        signal tcs_1 : std_logic := '0';
104
        signal tca_1 : std_logic := '0';
105
        signal sic_1 : std_logic := '0';
106
        signal rsc_1 : std_logic := '0';
107
        signal sre_1 : std_logic := '0';
108
        signal rtl_1 : std_logic := '0';
109
        signal rsv_1 : std_logic := '0';
110
        signal ist_1 : std_logic := '0';
111
        signal lpe_1 : std_logic := '0';
112
 
113
        -- inputs 2
114
        signal data_2 : std_logic_vector(7 downto 0) := (others => '0');
115
        signal status_byte_2 : std_logic_vector(7 downto 0) := (others => '0');
116
        signal rdy_2 : std_logic := '0';
117
        signal nba_2 : std_logic := '0';
118
        signal ltn_2 : std_logic := '0';
119
        signal lun_2 : std_logic := '0';
120
        signal lon_2 : std_logic := '0';
121
        signal ton_2 : std_logic := '0';
122
        signal endOf_2 : std_logic := '0';
123
        signal gts_2 : std_logic := '0';
124
        signal rpp_2 : std_logic := '0';
125
        signal tcs_2 : std_logic := '0';
126
        signal tca_2 : std_logic := '0';
127
        signal sic_2 : std_logic := '0';
128
        signal rsc_2 : std_logic := '0';
129
        signal sre_2 : std_logic := '0';
130
        signal rtl_2 : std_logic := '0';
131
        signal rsv_2 : std_logic := '0';
132
        signal ist_2 : std_logic := '0';
133
        signal lpe_2 : std_logic := '0';
134
 
135
        -- outputs 1
136
        signal dvd_1 : std_logic;
137
        signal wnc_1 : std_logic;
138
        signal tac_1 : std_logic;
139
        signal lac_1 : std_logic;
140
        signal cwrc_1 : std_logic;
141
        signal cwrd_1 : std_logic;
142
        signal clr_1 : std_logic;
143
        signal trg_1 : std_logic;
144
        signal atl_1 : std_logic;
145
        signal att_1 : std_logic;
146
        signal mla_1 : std_logic;
147
        signal lsb_1 : std_logic;
148
        signal spa_1 : std_logic;
149
        signal ppr_1 : std_logic;
150
        signal sreq_1 : std_logic;
151
        signal isLocal_1 : std_logic;
152
        signal currentSecAddr_1 : std_logic_vector (4 downto 0);
153
 
154
        -- outputs 2
155
        signal dvd_2 : std_logic;
156
        signal wnc_2 : std_logic;
157
        signal tac_2 : std_logic;
158
        signal lac_2 : std_logic;
159
        signal cwrc_2 : std_logic;
160
        signal cwrd_2 : std_logic;
161
        signal clr_2 : std_logic;
162
        signal trg_2 : std_logic;
163
        signal atl_2 : std_logic;
164
        signal att_2 : std_logic;
165
        signal mla_2 : std_logic;
166
        signal lsb_2 : std_logic;
167
        signal spa_2 : std_logic;
168
        signal ppr_2 : std_logic;
169
        signal sreq_2 : std_logic;
170
        signal isLocal_2 : std_logic;
171
        signal currentSecAddr_2 : std_logic_vector (4 downto 0);
172
 
173
        -- common
174
        signal DO : std_logic_vector (7 downto 0);
175
        signal DI_1 : std_logic_vector (7 downto 0);
176
        signal output_valid_1 : std_logic;
177
        signal DI_2 : std_logic_vector (7 downto 0);
178
        signal output_valid_2 : std_logic;
179
        signal ATN_1, ATN_2, ATN : std_logic;
180
        signal DAV_1, DAV_2, DAV : std_logic;
181
        signal NRFD_1, NRFD_2, NRFD : std_logic;
182
        signal NDAC_1, NDAC_2, NDAC : std_logic;
183
        signal EOI_1, EOI_2, EOI : std_logic;
184
        signal SRQ_1, SRQ_2, SRQ : std_logic;
185
        signal IFC_1, IFC_2, IFC : std_logic;
186
        signal REN_1, REN_2, REN : std_logic;
187
 
188
        -- gpib reader
189
        signal buf_interrupt : std_logic;
190
        signal data_available : std_logic;
191
        signal last_byte_addr : std_logic_vector (3 downto 0);
192
        signal end_of_stream : std_logic;
193
        signal byte_addr : std_logic_vector (3 downto 0);
194
        signal data_out : std_logic_vector (7 downto 0);
195
        signal reset_buffer : std_logic := '0';
196
        signal dataSecAddr : std_logic_vector (4 downto 0);
197
 
198
        -- gpib writer
199
        signal w_last_byte_addr : std_logic_vector (3 downto 0)
200
                := (others => '0');
201
        signal w_end_of_stream : std_logic := '0';
202
        signal w_data_available : std_logic := '0';
203
        signal w_buf_interrupt : std_logic;
204
        signal w_data_in : std_logic_vector (7 downto 0);
205
        signal w_byte_addr : std_logic_vector (3 downto 0);
206
        signal w_reset_buffer : std_logic := '0';
207
        signal w_dataSecAddr : std_logic_vector (4 downto 0);
208
        type WR_BUF_TYPE is
209
                array (0 to 15) of std_logic_vector (7 downto 0);
210
        signal w_write_buffer : WR_BUF_TYPE;
211
 
212
        -- Clock period definitions
213
        constant clk_period : time := 2ps;
214
 
215
BEGIN
216
 
217
        -- Instantiate the Unit Under Test (UUT)
218
        gpib1: gpibInterface PORT MAP (
219
                clk => clk,
220
                reset => reset,
221
                isLE => '1',
222
                isTE => '1',
223
                lpeUsed => '0',
224
                fixedPpLine => "000",
225
                eosUsed => '0',
226
                eosMark => "00000000",
227
                myListAddr => "00001",
228
                myTalkAddr => "00001",
229
                secAddrMask => "00000000000000000000000000000110",
230
                data => data_1,
231
                status_byte => status_byte_1,
232
                T1 => T1,
233
                rdy => rdy_1,
234
                nba => nba_1,
235
                ltn => ltn_1,
236
                lun => lun_1,
237
                lon => lon_1,
238
                ton => ton_1,
239
                endOf => endOf_1,
240
                gts => gts_1,
241
                rpp => rpp_1,
242
                tcs => tcs_1,
243
                tca => tca_1,
244
                sic => sic_1,
245
                rsc => rsc_1,
246
                sre => sre_1,
247
                rtl => rtl_1,
248
                rsv => rsv_1,
249
                ist => ist_1,
250
                lpe => lpe_1,
251
                dvd => dvd_1,
252
                wnc => wnc_1,
253
                tac => tac_1,
254
                lac => lac_1,
255
                cwrc => cwrc_1,
256
                cwrd => cwrd_1,
257
                clr => clr_1,
258
                trg => trg_1,
259
                atl => atl_1,
260
                att => att_1,
261
                mla => mla_1,
262
                lsb => lsb_1,
263
                spa => spa_1,
264
                ppr => ppr_1,
265
                sreq => sreq_1,
266
                isLocal => isLocal_1,
267
                currentSecAddr => currentSecAddr_1,
268
                DI => DO,
269
                DO => DI_1,
270
                output_valid => output_valid_1,
271
                ATN_in => ATN,
272
                ATN_out => ATN_1,
273
                DAV_in => DAV,
274
                DAV_out => DAV_1,
275
                NRFD_in => NRFD,
276
                NRFD_out => NRFD_1,
277
                NDAC_in => NDAC,
278
                NDAC_out => NDAC_1,
279
                EOI_in => EOI,
280
                EOI_out => EOI_1,
281
                SRQ_in => SRQ,
282
                SRQ_out => SRQ_1,
283
                IFC_in => IFC,
284
                IFC_out => IFC_1,
285
                REN_in => REN,
286
                REN_out => REN_1
287
                );
288
 
289
        -- Instantiate the Unit Under Test (UUT)
290
        gpib2: gpibInterface PORT MAP (
291
                clk => clk,
292
                reset => reset,
293
                isLE => '1',
294
                isTE => '1',
295
                lpeUsed => '0',
296
                fixedPpLine => "000",
297
                eosUsed => '0',
298
                eosMark => "00000000",
299
                myListAddr => "00010",
300
                myTalkAddr => "00010",
301
                secAddrMask => "00000000000000000000000000000110",
302
                data => data_2,
303
                status_byte => status_byte_2,
304
                T1 => T1,
305
                rdy => rdy_2,
306
                nba => nba_2,
307
                ltn => ltn_2,
308
                lun => lun_2,
309
                lon => lon_2,
310
                ton => ton_2,
311
                endOf => endOf_2,
312
                gts => gts_2,
313
                rpp => rpp_2,
314
                tcs => tcs_2,
315
                tca => tca_2,
316
                sic => sic_2,
317
                rsc => rsc_2,
318
                sre => sre_2,
319
                rtl => rtl_2,
320
                rsv => rsv_2,
321
                ist => ist_2,
322
                lpe => lpe_2,
323
                dvd => dvd_2,
324
                wnc => wnc_2,
325
                tac => tac_2,
326
                lac => lac_2,
327
                cwrc => cwrc_2,
328
                cwrd => cwrd_2,
329
                clr => clr_2,
330
                trg => trg_2,
331
                atl => atl_2,
332
                att => att_2,
333
                mla => mla_2,
334
                lsb => lsb_2,
335
                spa => spa_2,
336
                ppr => ppr_2,
337
                sreq => sreq_2,
338
                isLocal => isLocal_2,
339
                currentSecAddr => currentSecAddr_2,
340
                DI => DO,
341
                DO => DI_2,
342
                output_valid => output_valid_2,
343
                ATN_in => ATN,
344
                ATN_out => ATN_2,
345
                DAV_in => DAV,
346
                DAV_out => DAV_2,
347
                NRFD_in => NRFD,
348
                NRFD_out => NRFD_2,
349
                NDAC_in => NDAC,
350
                NDAC_out => NDAC_2,
351
                EOI_in => EOI,
352
                EOI_out => EOI_2,
353
                SRQ_in => SRQ,
354
                SRQ_out => SRQ_2,
355
                IFC_in => IFC,
356
                IFC_out => IFC_2,
357
                REN_in => REN,
358
                REN_out => REN_2
359
                );
360
 
361
        ce: gpibCableEmulator port map (
362
                -- interface signals
363
                DIO_1 => DI_1,
364
                output_valid_1 => output_valid_1,
365
                DIO_2 => DI_2,
366
                output_valid_2 => output_valid_2,
367
                DIO => DO,
368
                -- attention
369
                ATN_1 => ATN_1, ATN_2 => ATN_2, ATN => ATN,
370
                DAV_1 => DAV_1, DAV_2 => DAV_2, DAV => DAV,
371
                NRFD_1 => NRFD_1, NRFD_2 => NRFD_2, NRFD => NRFD,
372
                NDAC_1 => NDAC_1, NDAC_2 => NDAC_2, NDAC => NDAC,
373
                EOI_1 => EOI_1, EOI_2 => EOI_2, EOI => EOI,
374
                SRQ_1 => SRQ_1, SRQ_2 => SRQ_2, SRQ => SRQ,
375
                IFC_1 => IFC_1, IFC_2 => IFC_2, IFC => IFC,
376
                REN_1 => REN_1, REN_2 => REN_2, REN => REN
377
        );
378
 
379
        gr: gpibReader generic map (ADDR_WIDTH => 4) port map (
380
                clk => clk, reset => reset,
381
                ------------------------------------------------------------------------
382
                ------ GPIB interface --------------------------------------------------
383
                ------------------------------------------------------------------------
384
                data_in => DO, dvd => dvd_2, lac => lac_2, lsb => lsb_2, rdy => rdy_2,
385
                ------------------------------------------------------------------------
386
                ------ external interface ----------------------------------------------
387
                ------------------------------------------------------------------------
388
                isLE => '1', secAddr => currentSecAddr_1, dataSecAddr => dataSecAddr,
389
                buf_interrupt => buf_interrupt, data_available => data_available,
390
                last_byte_addr => last_byte_addr, end_of_stream => end_of_stream,
391
                byte_addr => byte_addr, data_out => data_out,
392
                reset_buffer => reset_buffer
393
        );
394
 
395
        w_data_in <= w_write_buffer(conv_integer(w_byte_addr));
396
 
397
        gw: gpibWriter generic map (ADDR_WIDTH => 4) port map (
398
                        clk => clk, reset => reset,
399
                        ------------------------------------------------------------------------
400
                        ------ GPIB interface --------------------------------------------------
401
                        ------------------------------------------------------------------------
402
                        data_out => data_1, wnc => wnc_1, spa => spa_1, nba => nba_1,
403
                        endOf => endOf_1, tac => tac_1, cwrc => cwrc_1,
404
                        ------------------------------------------------------------------------
405
                        ------ external interface ----------------------------------------------
406
                        ------------------------------------------------------------------------
407
                        isTE => '1', secAddr => currentSecAddr_1, dataSecAddr => w_dataSecAddr,
408
                        last_byte_addr => w_last_byte_addr, end_of_stream => w_end_of_stream,
409
                        data_available => w_data_available, buf_interrupt => w_buf_interrupt,
410
                        data_in => w_data_in, byte_addr => w_byte_addr,
411
                        reset_buffer => w_reset_buffer
412
                );
413
 
414
        -- Clock process definitions
415
        clk_process :process
416
        begin
417
                clk <= '0';
418
                wait for clk_period/2;
419
                clk <= '1';
420
                wait for clk_period/2;
421
        end process;
422
 
423
 
424
        -- Stimulus process
425
        stim_proc: process
426
        begin
427
                -- hold reset state for 10 clock periods.
428
                reset <= '1';
429
                wait for clk_period*10;
430
                reset <= '0';
431
                wait for clk_period*10;
432
 
433
                -- requests system control
434
                rsc_1 <= '1';
435
 
436
                -- interface clear
437
                sic_1 <= '1';
438
                wait until IFC_1 = '1';
439
                sic_1 <= '0';
440
                wait until IFC_1 = '0';
441
 
442
                -- gpib2 to listen
443
                w_write_buffer(0) <= "00100010";
444
                w_write_buffer(1) <= "01100010";
445
                -- gpib1 to talk
446
                w_write_buffer(2) <= "01000001";
447
                w_write_buffer(3) <= "01100010";
448
                w_last_byte_addr <= "0011";
449
                w_data_available <= '1';
450
 
451
                wait until w_buf_interrupt='1';
452
 
453
                gts_1 <= '1';
454
                wait until ATN='0';
455
 
456
                w_reset_buffer <= '1';
457
                wait for clk_period*2;
458
                w_reset_buffer <= '0';
459
 
460
                w_dataSecAddr <= "00010";
461
 
462
                wait for clk_period*1;
463
 
464
                w_write_buffer(0) <= "10101010";
465
                w_write_buffer(1) <= "01010101";
466
                w_write_buffer(2) <= "11111111";
467
                w_last_byte_addr <= "0010";
468
                w_end_of_stream <= '1';
469
                w_data_available <= '1';
470
 
471
                wait until buf_interrupt='1';
472
 
473
                byte_addr <= "0000";
474
                wait for clk_period*1;
475
                assert data_out = "10101010";
476
 
477
                byte_addr <= "0001";
478
                wait for clk_period*1;
479
                assert data_out = "01010101";
480
 
481
                byte_addr <= "0010";
482
                wait for clk_period*1;
483
                assert data_out = "11111111";
484
 
485
                report "$$$ END OF TEST - TE / LE $$$";
486
 
487
                wait;
488
        end process;
489
 
490
END;

powered by: WebSVN 2.1.0

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