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

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [vhdl/] [test/] [RegsGpibFasade_communication_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:   16:22:23 02/04/2012
20
-- Design Name:   
21 13 Andrewski
-- Module Name:   RegsGpibFasade_test.vhd
22 3 Andrewski
-- Project Name:  proto1
23
-- Target Device:  
24
-- Tool versions:  
25
-- Description:   
26
-- 
27
-- VHDL Test Bench Created by ISE for module: RegsGpibFasade
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
 
45
-- Uncomment the following library declaration if using
46
-- arithmetic functions with Signed or Unsigned values
47
--USE ieee.numeric_std.ALL;
48
 
49
use work.wrapperComponents.ALL;
50
 
51
ENTITY RegsGpibFasade_communication_test IS
52
END RegsGpibFasade_communication_test;
53
 
54
ARCHITECTURE behavior OF RegsGpibFasade_communication_test IS
55
 
56
        component gpibCableEmulator is port (
57
                -- interface signals
58
                DIO_1 : in std_logic_vector (7 downto 0);
59
                output_valid_1 : in std_logic;
60
                DIO_2 : in std_logic_vector (7 downto 0);
61
                output_valid_2 : in std_logic;
62
                DIO : out std_logic_vector (7 downto 0);
63
                -- attention
64
                ATN_1 : in std_logic;
65
                ATN_2 : in std_logic;
66
                ATN : out std_logic;
67
                -- data valid
68
                DAV_1 : in std_logic;
69
                DAV_2 : in std_logic;
70
                DAV : out std_logic;
71
                -- not ready for data
72
                NRFD_1 : in std_logic;
73
                NRFD_2 : in std_logic;
74
                NRFD : out std_logic;
75
                -- no data accepted
76
                NDAC_1 : in std_logic;
77
                NDAC_2 : in std_logic;
78
                NDAC : out std_logic;
79
                -- end or identify
80
                EOI_1 : in std_logic;
81
                EOI_2 : in std_logic;
82
                EOI : out std_logic;
83
                -- service request
84
                SRQ_1 : in std_logic;
85
                SRQ_2 : in std_logic;
86
                SRQ : out std_logic;
87
                -- interface clear
88
                IFC_1 : in std_logic;
89
                IFC_2 : in std_logic;
90
                IFC : out std_logic;
91
                -- remote enable
92
                REN_1 : in std_logic;
93
                REN_2 : in std_logic;
94
                REN : out std_logic
95
        );
96
        end component;
97
 
98
   --Inputs
99
   signal reset : std_logic := '0';
100
   signal clk : std_logic := '0';
101
   signal DI : std_logic_vector(7 downto 0) := (others => '0');
102
   signal ATN_in : std_logic := '0';
103
   signal DAV_in : std_logic := '0';
104
   signal NRFD_in : std_logic := '0';
105
   signal NDAC_in : std_logic := '0';
106
   signal EOI_in : std_logic := '0';
107
   signal SRQ_in : std_logic := '0';
108
   signal IFC_in : std_logic := '0';
109
   signal REN_in : std_logic := '0';
110
   signal data_in : std_logic_vector(15 downto 0) := (others => '0');
111
   signal reg_addr : std_logic_vector(14 downto 0) := (others => '0');
112
   signal strobe_read : std_logic := '0';
113
   signal strobe_write : std_logic := '0';
114
 
115
        --Outputs
116
   signal DO : std_logic_vector(7 downto 0);
117
   signal output_valid : std_logic;
118
   signal ATN_out : std_logic;
119
   signal DAV_out : std_logic;
120
   signal NRFD_out : std_logic;
121
   signal NDAC_out : std_logic;
122
   signal EOI_out : std_logic;
123
   signal SRQ_out : std_logic;
124
   signal IFC_out : std_logic;
125
   signal REN_out : std_logic;
126
   signal data_out : std_logic_vector(15 downto 0);
127
   signal interrupt_line : std_logic;
128
   signal debug1 : std_logic;
129
 
130
   --Inputs
131
   signal data_in_1 : std_logic_vector(15 downto 0) := (others => '0');
132
   signal reg_addr_1 : std_logic_vector(14 downto 0) := (others => '0');
133
   signal strobe_read_1 : std_logic := '0';
134
   signal strobe_write_1 : std_logic := '0';
135
 
136
        --Outputs
137
   signal DO_1 : std_logic_vector(7 downto 0);
138
   signal output_valid_1 : std_logic;
139
   signal ATN_out_1 : std_logic;
140
   signal DAV_out_1 : std_logic;
141
   signal NRFD_out_1 : std_logic;
142
   signal NDAC_out_1 : std_logic;
143
   signal EOI_out_1 : std_logic;
144
   signal SRQ_out_1 : std_logic;
145
   signal IFC_out_1 : std_logic;
146
   signal REN_out_1 : std_logic;
147
   signal data_out_1 : std_logic_vector(15 downto 0);
148
   signal interrupt_line_1 : std_logic;
149
 
150
 
151
        -- Clock period definitions
152
        constant clk_period : time := 10 ns;
153
 
154
 
155
BEGIN
156
 
157
        -- Instantiate the Unit Under Test (UUT)
158
        uut: RegsGpibFasade PORT MAP (
159
                reset => reset,
160
                clk => clk,
161
                DI => DI,
162
                DO => DO,
163
                output_valid => output_valid,
164
                ATN_in => ATN_in,
165
                ATN_out => ATN_out,
166
                DAV_in => DAV_in,
167
                DAV_out => DAV_out,
168
                NRFD_in => NRFD_in,
169
                NRFD_out => NRFD_out,
170
                NDAC_in => NDAC_in,
171
                NDAC_out => NDAC_out,
172
                EOI_in => EOI_in,
173
                EOI_out => EOI_out,
174
                SRQ_in => SRQ_in,
175
                SRQ_out => SRQ_out,
176
                IFC_in => IFC_in,
177
                IFC_out => IFC_out,
178
                REN_in => REN_in,
179
                REN_out => REN_out,
180
                data_in => data_in,
181
                data_out => data_out,
182
                reg_addr => reg_addr,
183
                strobe_read => strobe_read,
184
                strobe_write => strobe_write,
185
                interrupt_line => interrupt_line,
186
                debug1 => debug1
187
        );
188
 
189
        -- Instantiate the Unit Under Test (UUT)
190
        uut_1: RegsGpibFasade PORT MAP (
191
                reset => reset,
192
                clk => clk,
193
                DI => DI,
194
                DO => DO_1,
195
                output_valid => output_valid_1,
196
                ATN_in => ATN_in,
197
                ATN_out => ATN_out_1,
198
                DAV_in => DAV_in,
199
                DAV_out => DAV_out_1,
200
                NRFD_in => NRFD_in,
201
                NRFD_out => NRFD_out_1,
202
                NDAC_in => NDAC_in,
203
                NDAC_out => NDAC_out_1,
204
                EOI_in => EOI_in,
205
                EOI_out => EOI_out_1,
206
                SRQ_in => SRQ_in,
207
                SRQ_out => SRQ_out_1,
208
                IFC_in => IFC_in,
209
                IFC_out => IFC_out_1,
210
                REN_in => REN_in,
211
                REN_out => REN_out_1,
212
                data_in => data_in_1,
213
                data_out => data_out_1,
214
                reg_addr => reg_addr_1,
215
                strobe_read => strobe_read_1,
216
                strobe_write => strobe_write_1,
217
                interrupt_line => interrupt_line_1,
218
                debug1 => open
219
        );
220
 
221
        gce: gpibCableEmulator port map (
222
                -- interface signals
223
                DIO_1 => DO,
224
                output_valid_1 => output_valid,
225
                DIO_2 => DO_1,
226
                output_valid_2 => output_valid_1,
227
                DIO => DI,
228
                -- attention
229
                ATN_1 => ATN_out,
230
                ATN_2 => ATN_out_1,
231
                ATN => ATN_in,
232
                -- data valid
233
                DAV_1 => DAV_out,
234
                DAV_2 => DAV_out_1,
235
                DAV => DAV_in,
236
                -- not ready for data
237
                NRFD_1 => NRFD_out,
238
                NRFD_2 => NRFD_out_1,
239
                NRFD => NRFD_in,
240
                -- no data accepted
241
                NDAC_1 => NDAC_out,
242
                NDAC_2 => NDAC_out_1,
243
                NDAC => NDAC_in,
244
                -- end or identify
245
                EOI_1 => EOI_out,
246
                EOI_2 => EOI_out_1,
247
                EOI => EOI_in,
248
                -- service request
249
                SRQ_1 => SRQ_out,
250
                SRQ_2 => SRQ_out_1,
251
                SRQ => SRQ_in,
252
                -- interface clear
253
                IFC_1 => IFC_out,
254
                IFC_2 => IFC_out_1,
255
                IFC => IFC_in,
256
                -- remote enable
257
                REN_1 => REN_out,
258
                REN_2 => REN_out_1,
259
                REN => REN_in
260
        );
261
 
262
   -- Clock process definitions
263
   clk_process :process
264
   begin
265
                clk <= '0';
266
                wait for clk_period/2;
267
                clk <= '1';
268
                wait for clk_period/2;
269
   end process;
270
 
271
 
272
   -- Stimulus process
273
        stim_proc: process begin
274
 
275
                -- hold reset state for 10 clock cycles
276
                reset <= '1';
277
                wait for clk_period*10;
278
                reset <= '0';
279
                wait for clk_period*10;
280
 
281
                -- set address of GPIB1
282
                reg_addr_1 <= "000000000000001";
283
                data_in_1 <= X"0002";
284
                wait for clk_period*2;
285
                strobe_write_1 <= '1';
286
                wait for clk_period*2;
287
                strobe_write_1 <= '0';
288
                wait for clk_period*2;
289
 
290
                -- set rsc
291
                reg_addr <= "000000000000111";
292
                data_in <= X"0040";
293
                wait for clk_period*2;
294
                strobe_write <= '1';
295
                wait for clk_period*2;
296
                strobe_write <= '0';
297
                wait for clk_period*20;
298
 
299
                -- set sic
300
                reg_addr <= "000000000000111";
301
                data_in <= X"00c0";
302
                wait for clk_period*2;
303
                strobe_write <= '1';
304
                wait for clk_period*2;
305
                strobe_write <= '0';
306
                wait for clk_period*20;
307
 
308
                -- reset sic
309
                reg_addr <= "000000000000111";
310
                data_in <= X"0040";
311
                wait for clk_period*2;
312
                strobe_write <= '1';
313
                wait for clk_period*2;
314
                strobe_write <= '0';
315
                wait until IFC_in = '0';
316
 
317
                -- address GPIB1 to listen
318
                reg_addr <= "000000000001101";
319
                data_in <= X"0022";
320
                wait for clk_period*2;
321
                strobe_write <= '1';
322
                wait for clk_period*2;
323
                strobe_write <= '0';
324
                wait for clk_period*5;
325
 
326
                -- address GPIB0 to talk
327
                reg_addr <= "000000000001101";
328
                data_in <= X"0041";
329
                wait for clk_period*2;
330
                strobe_write <= '1';
331
                wait for clk_period*2;
332
                strobe_write <= '0';
333
                wait for clk_period*5;
334
 
335
                -- go to standby
336
                reg_addr <= "000000000000111";
337
                data_in <= X"0240";
338
                wait for clk_period*2;
339
                strobe_write <= '1';
340
                wait for clk_period*2;
341
                strobe_write <= '0';
342
                wait until ATN_in = '0';
343
                reg_addr <= "000000000000111";
344
                data_in <= X"0040";
345
                wait for clk_period*2;
346
                strobe_write <= '1';
347
                wait for clk_period*2;
348
                strobe_write <= '0';
349
                wait for clk_period*5;
350
 
351
                -- set eof
352
                reg_addr <= "000000000001010";
353
                data_in <= X"0006";
354
                wait for clk_period*2;
355
                strobe_write <= '1';
356
                wait for clk_period*2;
357
                strobe_write <= '0';
358
                wait for clk_period*5;
359
 
360
                -- writes data to GPIB1
361
                reg_addr <= "000000000001101";
362
                data_in <= X"0007";
363
                wait for clk_period*2;
364
                strobe_write <= '1';
365
                wait for clk_period*2;
366
                strobe_write <= '0';
367
                wait for clk_period*15;
368
 
369
                -- take control
370
                reg_addr <= "000000000000111";
371
                data_in <= X"0840";
372
                wait for clk_period*2;
373
                strobe_write <= '1';
374
                wait for clk_period*2;
375
                strobe_write <= '0';
376
                wait for clk_period*150;
377
 
378
                -- reset buffer
379
                reg_addr <= "000000000001010";
380
                data_in <= X"000a";
381
                wait for clk_period*2;
382
                strobe_write <= '1';
383
                wait for clk_period*2;
384
                strobe_write <= '0';
385
                wait for clk_period*10;
386
 
387
                -- address GPIB0 to listen
388
                reg_addr <= "000000000001101";
389
                data_in <= X"0021";
390
                wait for clk_period*2;
391
                strobe_write <= '1';
392
                wait for clk_period*2;
393
                strobe_write <= '0';
394
                wait for clk_period*5;
395
 
396
                wait;
397
        end process;
398
 
399
END;

powered by: WebSVN 2.1.0

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