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

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [vhdl/] [test/] [gpibReaderTest.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 gpibReaderTest IS
38
END gpibReaderTest;
39
 
40
ARCHITECTURE behavior OF gpibReaderTest 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 cwrc_1 : std_logic;
140
        signal cwrd_1 : std_logic;
141
        signal clr_1 : std_logic;
142
        signal trg_1 : std_logic;
143
        signal atl_1 : std_logic;
144
        signal att_1 : std_logic;
145
        signal mla_1 : std_logic;
146
        signal lsb_1 : std_logic;
147
        signal spa_1 : std_logic;
148
        signal ppr_1 : std_logic;
149
        signal sreq_1 : std_logic;
150
        signal isLocal_1 : std_logic;
151
        signal currentSecAddr_1 : std_logic_vector (4 downto 0);
152
 
153
        -- outputs 2
154
        signal dvd_2 : std_logic;
155
        signal wnc_2 : std_logic;
156
        signal tac_2 : std_logic;
157
        signal cwrc_2 : std_logic;
158
        signal cwrd_2 : std_logic;
159
        signal clr_2 : std_logic;
160
        signal trg_2 : std_logic;
161
        signal atl_2 : std_logic;
162
        signal att_2 : std_logic;
163
        signal mla_2 : std_logic;
164
        signal lsb_2 : std_logic;
165
        signal spa_2 : std_logic;
166
        signal ppr_2 : std_logic;
167
        signal sreq_2 : std_logic;
168
        signal isLocal_2 : std_logic;
169
        signal currentSecAddr_2 : std_logic_vector (4 downto 0);
170
 
171
        -- common
172
        signal DO : std_logic_vector (7 downto 0);
173
        signal DI_1 : std_logic_vector (7 downto 0);
174
        signal output_valid_1 : std_logic;
175
        signal DI_2 : std_logic_vector (7 downto 0);
176
        signal output_valid_2 : std_logic;
177
        signal ATN_1, ATN_2, ATN : std_logic;
178
        signal DAV_1, DAV_2, DAV : std_logic;
179
        signal NRFD_1, NRFD_2, NRFD : std_logic;
180
        signal NDAC_1, NDAC_2, NDAC : std_logic;
181
        signal EOI_1, EOI_2, EOI : std_logic;
182
        signal SRQ_1, SRQ_2, SRQ : std_logic;
183
        signal IFC_1, IFC_2, IFC : std_logic;
184
        signal REN_1, REN_2, REN : std_logic;
185
 
186
        -- gpib reader
187
        signal buf_interrupt : std_logic;
188
        signal data_available : std_logic;
189
        signal last_byte_addr : std_logic_vector (3 downto 0);
190
        signal end_of_stream : std_logic;
191
        signal byte_addr : std_logic_vector (3 downto 0);
192
        signal data_out : std_logic_vector (7 downto 0);
193
        signal reset_buffer : std_logic := '0';
194
        signal dataSecAddr : std_logic_vector (4 downto 0);
195
 
196
        -- Clock period definitions
197
        constant clk_period : time := 2ps;
198
 
199
BEGIN
200
 
201
        -- Instantiate the Unit Under Test (UUT)
202
        gpib1: gpibInterface PORT MAP (
203
                clk => clk,
204
                reset => reset,
205
                isLE => '0',
206
                isTE => '0',
207
                lpeUsed => '0',
208
                fixedPpLine => "000",
209
                eosUsed => '0',
210
                eosMark => "00000000",
211
                myListAddr => "00001",
212
                myTalkAddr => "00001",
213
                secAddrMask => (others => '0'),
214
                data => data_1,
215
                status_byte => status_byte_1,
216
                T1 => T1,
217
                rdy => rdy_1,
218
                nba => nba_1,
219
                ltn => ltn_1,
220
                lun => lun_1,
221
                lon => lon_1,
222
                ton => ton_1,
223
                endOf => endOf_1,
224
                gts => gts_1,
225
                rpp => rpp_1,
226
                tcs => tcs_1,
227
                tca => tca_1,
228
                sic => sic_1,
229
                rsc => rsc_1,
230
                sre => sre_1,
231
                rtl => rtl_1,
232
                rsv => rsv_1,
233
                ist => ist_1,
234
                lpe => lpe_1,
235
                dvd => dvd_1,
236
                wnc => wnc_1,
237
                tac => tac_1,
238
                cwrc => cwrc_1,
239
                cwrd => cwrd_1,
240
                clr => clr_1,
241
                trg => trg_1,
242
                atl => atl_1,
243
                att => att_1,
244
                mla => mla_1,
245
                lsb => lsb_1,
246
                spa => spa_1,
247
                ppr => ppr_1,
248
                sreq => sreq_1,
249
                isLocal => isLocal_1,
250
                currentSecAddr => currentSecAddr_1,
251
                DI => DO,
252
                DO => DI_1,
253
                output_valid => output_valid_1,
254
                ATN_in => ATN,
255
                ATN_out => ATN_1,
256
                DAV_in => DAV,
257
                DAV_out => DAV_1,
258
                NRFD_in => NRFD,
259
                NRFD_out => NRFD_1,
260
                NDAC_in => NDAC,
261
                NDAC_out => NDAC_1,
262
                EOI_in => EOI,
263
                EOI_out => EOI_1,
264
                SRQ_in => SRQ,
265
                SRQ_out => SRQ_1,
266
                IFC_in => IFC,
267
                IFC_out => IFC_1,
268
                REN_in => REN,
269
                REN_out => REN_1
270
                );
271
 
272
        -- Instantiate the Unit Under Test (UUT)
273
        gpib2: gpibInterface PORT MAP (
274
                clk => clk,
275
                reset => reset,
276
                isLE => '0',
277
                isTE => '0',
278
                lpeUsed => '0',
279
                fixedPpLine => "000",
280
                eosUsed => '0',
281
                eosMark => "00000000",
282
                myListAddr => "00010",
283
                myTalkAddr => "00010",
284
                secAddrMask => (others => '0'),
285
                data => data_2,
286
                status_byte => status_byte_2,
287
                T1 => T1,
288
                rdy => rdy_2,
289
                nba => nba_2,
290
                ltn => ltn_2,
291
                lun => lun_2,
292
                lon => lon_2,
293
                ton => ton_2,
294
                endOf => endOf_2,
295
                gts => gts_2,
296
                rpp => rpp_2,
297
                tcs => tcs_2,
298
                tca => tca_2,
299
                sic => sic_2,
300
                rsc => rsc_2,
301
                sre => sre_2,
302
                rtl => rtl_2,
303
                rsv => rsv_2,
304
                ist => ist_2,
305
                lpe => lpe_2,
306
                dvd => dvd_2,
307
                wnc => wnc_2,
308
                tac => tac_2,
309
                cwrc => cwrc_2,
310
                cwrd => cwrd_2,
311
                clr => clr_2,
312
                trg => trg_2,
313
                atl => atl_2,
314
                att => att_2,
315
                mla => mla_2,
316
                lsb => lsb_2,
317
                spa => spa_2,
318
                ppr => ppr_2,
319
                sreq => sreq_2,
320
                isLocal => isLocal_2,
321
                currentSecAddr => currentSecAddr_2,
322
                DI => DO,
323
                DO => DI_2,
324
                output_valid => output_valid_2,
325
                ATN_in => ATN,
326
                ATN_out => ATN_2,
327
                DAV_in => DAV,
328
                DAV_out => DAV_2,
329
                NRFD_in => NRFD,
330
                NRFD_out => NRFD_2,
331
                NDAC_in => NDAC,
332
                NDAC_out => NDAC_2,
333
                EOI_in => EOI,
334
                EOI_out => EOI_2,
335
                SRQ_in => SRQ,
336
                SRQ_out => SRQ_2,
337
                IFC_in => IFC,
338
                IFC_out => IFC_2,
339
                REN_in => REN,
340
                REN_out => REN_2
341
                );
342
 
343
        ce: gpibCableEmulator port map (
344
                -- interface signals
345
                DIO_1 => DI_1,
346
                output_valid_1 => output_valid_1,
347
                DIO_2 => DI_2,
348
                output_valid_2 => output_valid_2,
349
                DIO => DO,
350
                -- attention
351
                ATN_1 => ATN_1, ATN_2 => ATN_2, ATN => ATN,
352
                DAV_1 => DAV_1, DAV_2 => DAV_2, DAV => DAV,
353
                NRFD_1 => NRFD_1, NRFD_2 => NRFD_2, NRFD => NRFD,
354
                NDAC_1 => NDAC_1, NDAC_2 => NDAC_2, NDAC => NDAC,
355
                EOI_1 => EOI_1, EOI_2 => EOI_2, EOI => EOI,
356
                SRQ_1 => SRQ_1, SRQ_2 => SRQ_2, SRQ => SRQ,
357
                IFC_1 => IFC_1, IFC_2 => IFC_2, IFC => IFC,
358
                REN_1 => REN_1, REN_2 => REN_2, REN => REN
359
        );
360
 
361
        gr: gpibReader generic map(ADDR_WIDTH => 4) port map(
362
                clk => clk, reset => reset,
363
                ------------------------------------------------------------------------
364
                ------ GPIB interface --------------------------------------------------
365
                ------------------------------------------------------------------------
366
                data_in => DO, dvd => dvd_2, atl => atl_2, lsb => lsb_2, rdy => rdy_2,
367
                ------------------------------------------------------------------------
368
                ------ external interface ----------------------------------------------
369
                ------------------------------------------------------------------------
370
                isLE => '0', secAddr => (others => '0'), dataSecAddr => dataSecAddr,
371
                buf_interrupt => buf_interrupt, data_available => data_available,
372
                last_byte_addr => last_byte_addr, end_of_stream => end_of_stream,
373
                byte_addr => byte_addr, data_out => data_out,
374
                reset_buffer => reset_buffer
375
        );
376
 
377
        -- Clock process definitions
378
        clk_process :process
379
        begin
380
                clk <= '0';
381
                wait for clk_period/2;
382
                clk <= '1';
383
                wait for clk_period/2;
384
        end process;
385
 
386
 
387
        -- Stimulus process
388
        stim_proc: process
389
        begin
390
                -- hold reset state for 10 clock periods.
391
                reset <= '1';
392
                wait for clk_period*10;
393
                reset <= '0';
394
                wait for clk_period*10;
395
 
396
                -- requests system control
397
                rsc_1 <= '1';
398
 
399
                -- interface clear
400
                sic_1 <= '1';
401
                wait until IFC_1 = '1';
402
                sic_1 <= '0';
403
                wait until IFC_1 = '0';
404
 
405
                -- address gpib2 to listen
406
                data_1 <= "00100010";
407
                nba_1 <= '1';
408
                wait until DAV='1';
409
                nba_1 <= '0';
410
                wait for clk_period*20;
411
                -- address gpib1 to talk
412
                data_1 <= "01000001";
413
                wait for clk_period*1;
414
                nba_1 <= '1';
415
                wait until DAV='1';
416
                nba_1 <= '0';
417
                wait for clk_period*30;
418
 
419
                gts_1 <= '1';
420
                wait until ATN='0';
421
 
422
 
423
                -- send data to gpib2
424
                data_1 <= "10101010";
425
                nba_1 <= '1';
426
                wait until wnc_1='1';
427
                nba_1 <= '0';
428
                wait for clk_period*3;
429
                -- send end data to gpib2
430
                data_1 <= "10101010";
431
                endOf_1 <= '1';
432
 
433
                nba_1 <= '1';
434
                wait until wnc_1='1';
435
                nba_1 <= '0';
436
                --wait until wnc_1='0';
437
 
438
                wait until buf_interrupt = '1';
439
 
440
 
441
                byte_addr <= "0000";
442
                wait for clk_period*1;
443
                assert data_out = "10101010";
444
 
445
                byte_addr <= "0001";
446
                wait for clk_period*1;
447
                assert data_out = "10101010";
448
 
449
                report "$$$ END OF TEST - reader $$$";
450
 
451
                wait;
452
        end process;
453
 
454
END;

powered by: WebSVN 2.1.0

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