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

Subversion Repositories modular_oscilloscope

[/] [modular_oscilloscope/] [trunk/] [hdl/] [tbench/] [modullar_oscilloscope_tbench_text.vhd] - Blame information for rev 57

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 53 budinero
-------------------------------------------------------------------------------------------------100
2
--| Modular Oscilloscope
3
--| UNSL - Argentine
4
--|
5
--| File: modullar_oscilloscope_tbench_text.vhd
6
--| Version: 0.1
7
--| Tested in: Actel A3PE1500
8
--|   Board: RVI Prototype Board + LP Data Conversion Daughter Board
9
--|-------------------------------------------------------------------------------------------------
10
--| Description:
11
--|   This file is only for test purposes. 
12
--|
13
--|-------------------------------------------------------------------------------------------------
14
--| File history:
15
--|   0.1   | aug-2009 | First release
16
----------------------------------------------------------------------------------------------------
17 54 budinero
--| Copyright © 2009, Facundo Aguilera (budinero at gmail.com.
18 53 budinero
--|
19
--| This VHDL design file is an open design; you can redistribute it and/or
20
--| modify it and/or implement it after contacting the author.
21
----------------------------------------------------------------------------------------------------
22
 
23
--==================================================================================================
24
-- TO DO
25
-- · Full full test
26
--==================================================================================================
27
 
28 54 budinero
-- NOTES
29
-- · Board clock freq = 25 MHz
30
-- · PLL clocks: clk_epp freq = 10 MHz, clk_epp freq = 40 MHz
31 53 budinero
 
32
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
33 54 budinero
-->> Virtual clock
34 53 budinero
library ieee;
35
use ieee.std_logic_1164.all;
36
use ieee.math_real.all;
37
 
38
 
39
 
40 54 budinero
entity tb_simple_clock is
41 53 budinero
  port (
42
    CLK_PERIOD: in time;-- := 20 ns;
43
    CLK_DUTY:  in  real; -- := 0.5;
44
    active:  in     boolean;
45
    clk_o:   out    std_logic
46
  );
47 54 budinero
end entity tb_simple_clock ;
48 53 budinero
 
49 54 budinero
architecture beh of tb_simple_clock is
50 53 budinero
begin
51
  P_main: process
52
  begin
53
    wait until active;
54
    while (active = true) loop
55
      clk_o <= '0';
56
      wait for CLK_PERIOD * (100.0 - clk_Duty)/100.0;
57
      clk_o <= '1';
58
      wait for CLK_PERIOD * clk_Duty/100.0;
59
    end loop;
60
    clk_o <= '0';
61
    wait;
62
  end process;
63
end architecture beh;
64
 
65 54 budinero
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
66
-->> Virtual ADC
67
library ieee;
68
use ieee.std_logic_1164.all;
69
use ieee.std_logic_unsigned.all;
70 53 budinero
 
71 54 budinero
entity virtual_adc is
72
  port (
73
    clk_I:        in  std_logic;
74
    sel_I:        in  std_logic;
75
    chip_sel_I:   in  std_logic;
76
    sleep_I:      in  std_logic;
77
    data_O:       out std_logic_vector(9 downto 0)
78
  );
79
end entity virtual_adc ;
80
 
81
architecture beh of virtual_adc is
82
    signal data1: std_logic_vector(9 downto 0) := "0000000001"; -- odd
83
    signal data2: std_logic_vector(9 downto 0) := (others => '0'); -- pair  
84
begin
85 53 budinero
 
86 54 budinero
  P_virtual_adc: process (clk_I, sel_I, chip_sel_I, sleep_I)
87
 
88
  begin
89
    if clk_I'event and clk_I = '1' then
90
      data1 <= data1 + 2;
91
      data2 <= data2 + 2;
92
    end if;
93
 
94 57 budinero
    if sleep_I = '1' or chip_sel_I = '1' then
95 54 budinero
      data_O <= (others => '0');
96
    else
97
      case sel_I is
98
        when '0' =>
99
          data_O <= data1;
100
        when others =>
101
          data_O <= data2;
102
      end case;
103
    end if;
104
 
105
  end process;
106
 
107
end architecture beh;
108
 
109 53 budinero
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
110 54 budinero
-->> Stimulus
111 53 budinero
library ieee, std;
112
use ieee.std_logic_1164.all;
113
use ieee.std_logic_unsigned.all;
114 54 budinero
--use IEEE.NUMERIC_STD.ALL;
115 53 budinero
use ieee.math_real.all;
116
 
117
 
118
-- Additional libraries used by Model Under Test.
119
use work.ctrl_pkg.all;
120
use work.daq_pkg.all;
121
use work.memory_pkg.all;
122
use work.eppwbn_pkg.all;
123
 
124
entity stimulus is
125
  port(
126
 -- ADC
127 54 budinero
    adc_data_I:     inout    std_logic_vector (9 downto 0) := (others => '0');
128 53 budinero
    adc_sel_O:      in   std_logic;
129
    adc_clk_O:      in   std_logic;
130
    adc_sleep_O:    in   std_logic;
131
    adc_chip_sel_O: in   std_logic;
132
 
133
    -- EPP
134
    nStrobe_I:      inout std_logic;                       --  HostClk/nWrite 
135
    Data_IO:        inout std_logic_vector (7 downto 0);--   AD8..1 (Data1..Data8)
136
    nAck_O:         in std_logic;                      --  PtrClk/PeriphClk/Intr
137 54 budinero
    Busy_O:         in std_logic;                      --  PtrBusy/PeriphAck/nWait
138 53 budinero
    PError_O:       in std_logic;                      --  AckData/nAckReverse
139
    Sel_O:          in std_logic;                      --  XFlag (Select)
140
    nAutoFd_I:      inout std_logic;                       --  HostBusy/HostAck/nDStrb
141
    PeriphLogicH_O: in std_logic;                      --  (Periph Logic High)
142
    nInit_I:        inout std_logic;                       --  nReverseRequest
143
    nFault_O:       in std_logic;                      --  nDataAvail/nPeriphRequest
144
    nSelectIn_I:    inout std_logic;                       --  1284 Active/nAStrb
145
 
146
    -- Peripherals
147
    reset_I:    inout std_logic;
148 54 budinero
    pll_clk_I:  inout std_logic;  -- clock signal go to pll, and is divided in two clocks
149
 
150
    test_number: out integer range 0 to 20
151 53 budinero
  );
152
 
153
end stimulus;
154
 
155
architecture STIMULATOR of stimulus is
156 54 budinero
  -- PLL clocks
157
  constant CLK_DAQ_PERIOD: time := 25  ns;
158
  constant CLK_EPP_PERIOD: time := 100 ns;
159
 
160 53 budinero
  -- Control Signal Declarations
161
  signal tb_InitFlag : boolean := false;
162
  signal tb_ParameterInitFlag : boolean := false;
163 56 budinero
 
164 54 budinero
  signal runflag: std_logic;
165 53 budinero
 
166
  -- Parm Declarations
167
  signal clk_Duty :   real := 0.0;
168
  signal clk_Period : time := 0 ns;
169
 
170
begin
171
  --------------------------------------------------------------------------------------------------
172
  -- Parm Assignment Block
173
  P_AssignParms : process
174
    variable clk_Duty_real :    real;
175
    variable clk_Period_real :  real;
176
  begin
177
    -- Basic parameters
178 54 budinero
    clk_Period_real := 40.0; --<--<--<--<--<--<--<--<--<--<--<--<--<--<--<--<--
179 53 budinero
    clk_Period <= clk_Period_real * 1 ns;
180
    clk_Duty_real := 50.0;
181
    clk_Duty <= clk_Duty_real;
182
 
183
    tb_ParameterInitFlag <= true;
184
 
185
    wait;
186
  end process;
187
 
188
 
189
  --------------------------------------------------------------------------------------------------
190 54 budinero
  -- Instantiation
191 53 budinero
  -- Clock Instantiation
192 54 budinero
  U_TB_CLK: entity work.tb_simple_clock
193 53 budinero
  port map (
194
    clk_Period => clk_Period,
195
    clk_Duty => clk_Duty,
196
    active => tb_InitFlag,
197
    clk_o => pll_clk_I
198
  );
199
 
200 54 budinero
  -- ADC Instantiation
201
  U_TB_ADC: entity work.virtual_adc
202
  port map(
203
    clk_I => adc_clk_O,
204
    sel_I => adc_sel_O,
205
    chip_sel_I => adc_chip_sel_O,
206
    sleep_I => adc_sleep_O,
207
    data_O => adc_data_I
208
  );
209
 
210 53 budinero
 
211
  --------------------------------------------------------------------------------------------------
212 54 budinero
  -- Main process
213
  P_Unclocked : process
214 56 budinero
    variable i: integer range 0 to 1200;
215
 
216 54 budinero
    ------------------------------------------------------------------------------------------------
217
    -- Procedure for write in epp port
218
    procedure WriteData(
219
      constant in_address: in  std_logic_vector(7 downto 0);
220
      constant in_data:    in  std_logic_vector(15 downto 0);
221
      signal Data_IO:      out std_logic_vector(7 downto 0);
222
      signal nStrobe_I:    out std_logic;
223
      signal nSelectIn_I:  out std_logic;
224
      signal nAutoFd_I:    out std_logic;
225
      signal Busy_O:       in  std_logic
226
    ) is
227
    begin
228
      nStrobe_I <= '0'; -- '0' -> is write
229 53 budinero
 
230 54 budinero
      Data_IO <= in_address;          -- Address
231
      nSelectIn_I <= '0';             -- addStb      
232
      wait until Busy_O = '1';
233
      --wait for 30 ns;
234
      nSelectIn_I <= '1';
235
      wait until Busy_O = '0';
236 57 budinero
      Data_IO <= (others => '0');
237
      wait for 30 ns;
238 54 budinero
 
239
      Data_IO <= in_data(7 downto 0); -- Data1
240
      nAutoFd_I <= '0';                -- datStb
241
      wait until Busy_O = '1';
242
      nAutoFd_I <= '1';
243
      wait until Busy_O = '0';
244 57 budinero
      Data_IO <= (others => '0');
245
      wait for 30 ns;
246 54 budinero
 
247
      Data_IO <= in_data(15 downto 8); -- Data0  
248
      nAutoFd_I <= '0';               -- datStb
249
      wait until Busy_O = '1';
250
      nAutoFd_I <= '1';
251
      wait until Busy_O = '0';
252
 
253
    end procedure WriteData;
254
    ------------------------------------------------------------------------------------------------
255
    -- Procedure for read from epp port
256
    procedure ReadData(
257
      signal out_runflag:  out std_logic;
258
      constant in_address: in  std_logic_vector(7 downto 0);
259
      signal Data_IO:      inout std_logic_vector(7 downto 0);
260
      signal nStrobe_I:    out std_logic;
261
      signal nSelectIn_I:  out std_logic;
262
      signal nAutoFd_I:    out std_logic;
263
      signal Busy_O:       in  std_logic
264
    ) is
265
    begin
266
 
267
      nStrobe_I <= '0'; -- '0' -> is write
268
      Data_IO <= in_address;          -- Address
269
      nSelectIn_I <= '0';             -- addStb
270
      wait until Busy_O = '1';
271 57 budinero
      wait for 30 ns; -- default
272
     -- wait for 150 ns;
273
      nSelectIn_I <= '1';
274 54 budinero
      wait until Busy_O = '0';
275 57 budinero
      wait for 30 ns;
276 54 budinero
 
277
      nStrobe_I <= '1'; -- '1' -> is read
278
      Data_IO <= (others => 'Z');     -- Data1
279
      nAutoFd_I <= '0';               -- datStb
280 57 budinero
    --  wait for 150 ns;
281 54 budinero
      wait until (Busy_O = '1');
282 57 budinero
      wait for 150 ns;
283 54 budinero
      nAutoFd_I <= '1';
284 57 budinero
   --   wait for 40 ns;
285 54 budinero
      wait until (Busy_O = '0');
286 57 budinero
      wait for 30 ns;
287 54 budinero
 
288
      Data_IO <= (others => 'Z');     -- Data0
289
      nAutoFd_I <= '0';               -- datStb
290 57 budinero
   --   wait for 150 ns;
291 54 budinero
      wait until (Busy_O = '1');
292 57 budinero
      wait for 150 ns;
293 54 budinero
      out_runflag <= Data_IO(6);
294
      nAutoFd_I <= '1';
295
      wait until (Busy_O = '0');
296 57 budinero
      wait for 30 ns;
297 54 budinero
 
298
    end procedure ReadData;
299 53 budinero
 
300 57 budinero
 
301
     ------------------------------------------------------------------------------------------------
302
    -- Procedure for read from epp port
303
    procedure ReadData2(
304
      signal out_runflag:  out std_logic;
305
      --constant in_address: in  std_logic_vector(7 downto 0);
306
      signal Data_IO:      inout std_logic_vector(7 downto 0);
307
      signal nStrobe_I:    out std_logic;
308
      signal nSelectIn_I:  out std_logic;
309
      signal nAutoFd_I:    out std_logic;
310
      signal Busy_O:       in  std_logic
311
    ) is
312
    begin
313
 
314
 
315
      nStrobe_I <= '1'; -- '1' -> is read
316
      Data_IO <= (others => 'Z');     -- Data1
317
      nAutoFd_I <= '0';               -- datStb
318
     -- wait for 150 ns;
319
      wait until (Busy_O = '1');
320
     -- wait for 150 ns;
321
      nAutoFd_I <= '1';
322
      --wait for 40 ns;
323
      wait until (Busy_O = '0');
324
    --  wait for 40 ns;
325
 
326
      Data_IO <= (others => 'Z');     -- Data0
327
      nAutoFd_I <= '0';               -- datStb
328
    --  wait for 150 ns;
329
      wait until (Busy_O = '1');
330
    --  wait for 150 ns;
331
      out_runflag <= Data_IO(6);
332
      nAutoFd_I <= '1';
333
      --wait for 40 ns;
334
      wait until (Busy_O = '0');
335
    --  wait for 40 ns;
336
 
337
    end procedure ReadData2;
338
 
339 53 budinero
  begin
340 54 budinero
    ------------------------------------------------------------------------------------------------
341
    -- Init
342
    test_number <= 0;
343 53 budinero
    wait until tb_ParameterInitFlag;
344
    tb_InitFlag <= true;
345
 
346 54 budinero
    nSelectIn_I <= '0';
347
    nStrobe_I   <= '0';
348
    Data_IO     <= (others => '0');
349
    nAutoFd_I   <= '1';
350
    nInit_I     <= '1';
351 57 budinero
    reset_I     <= '0';
352 54 budinero
    wait for 700 ns; -- PLL delay
353 53 budinero
 
354 57 budinero
    reset_I     <= '1';
355 53 budinero
 
356 54 budinero
    -- EPP Mode Negotiation
357
    -- Standar timing and handshake
358
    nStrobe_I <= '1';
359
    wait for 500 ns;
360 53 budinero
 
361 54 budinero
    Data_IO <= X"40";
362
    wait for 500 ns;
363 53 budinero
 
364 54 budinero
    nSelectIn_I <= '1';
365
    nAutoFd_I <= '0';
366
    wait until (PError_O = '1' and nAck_O = '0' and nFault_O = '1' and Sel_O = '1');
367 53 budinero
 
368 54 budinero
    nStrobe_I <= '0';
369
    wait for 500 ns;
370 53 budinero
 
371 54 budinero
    nAutoFd_I <= '1';
372
    nStrobe_I <= '1';
373 55 budinero
    wait until (nAck_O = '1' and Sel_O = '1');
374 53 budinero
 
375 54 budinero
    ------------------------------------------------------------------------------------------------
376
    -- Test 1
377
    -- Writing in all control register
378 53 budinero
 
379 54 budinero
    -- 00   RunConf_R   RW     [       |       |       |       |       |TScal04|TScal03|TScal02|
380
    --                          TScal01|TScal00|TScalEn|   TrCh|  TrEdg|   TrOn|   Cont|  Start]    
381
    --      
382
    -- 01   Channels_R  RW     [       |       |       |       |       |       |       |       |
383
    --                                 |       |       |       |       |       |  RCh01|  RCh00] 
384
    --      
385
    -- 02   BuffSize_R  RW     [       |       |BuffS13|BuffS12|BuffS11|BuffS10|BuffS09|BuffS08|
386
    --                          BuffS07|BuffS06|BuffS05|BuffS04|BuffS03|BuffS02|BuffS01|BuffS00]
387
    --      
388
    -- 03   TrigLvl_R   RW     [       |       |       |       |       |       |TrLvl09|TrLvl08|
389
    --                          TrLvl07|TrLvl06|TrLvl05|TrLvl04|TrLvl03|TrLvl02|TrLvl01|TrLvl00]
390
    --           
391
    -- 04   TrigOff_R   RW     [       |TrOff14|TrOff13|TrOff12|TrOff11|TrOff10|TrOff09|TrOff08|
392
    --                          TrOff07|TrOff06|TrOff00|TrOff00|TrOff00|TrOff00|TrOff00|TrOff00]  
393
    --
394
    -- 05   ADCConf     RW     [       |       |       |       |   ADCS|ADSleep| ADPSEn| ADPS08|
395
    --                           ADPS07| ADPS06| ADPS05| ADPS04| ADPS03| ADPS02| ADPS01| ADPS00]  
396
    --
397
    -- 08   Data_O      R      [ErrFlag|RunFlag|       |       |       |  DCh00|  Dat09|  Dat08|
398
    --                            Dat07|  Dat06|  Dat05|  Dat04|  Dat03|  Dat02|  Dat01|  Dat00] 
399
    -- 
400
    -- 09   Error_O     R      [       |       |       |       |       |       |       |       |
401
    --                                 |       |       |       |       | ErrN02| ErrN01| ErrN00] 
402 55 budinero
--     test_number <= 1;
403
--     
404
--     WriteData(X"00", X"FFFE", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
405
--     WriteData(X"01", X"FFFF", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
406
--     WriteData(X"02", X"FFFF", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
407
--     WriteData(X"03", X"FFFF", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
408
--     WriteData(X"04", X"FFFF", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
409
--     
410
--     ReadData(runflag, X"00", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
411
--     ReadData(runflag, X"01", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
412
--     ReadData(runflag, X"02", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
413
--     ReadData(runflag, X"03", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
414
--     ReadData(runflag, X"04", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
415
--     
416
--     wait for 50 ns;
417
--     ------------------------------------------------------------------------------------------------
418
--     -- Test 2 - DAQ Config
419
--     -- Writing in daq config register
420
--     test_number <= 2;
421
--     
422
--     WriteData(X"05", X"07FF", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
423
--     ReadData(runflag, X"05", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
424
--     
425
--     WriteData(X"05", X"0A00", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
426
--     ReadData(runflag, X"05", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
427
--     
428
--     wait for 50 ns;
429
--     ------------------------------------------------------------------------------------------------
430
--     -- Test 3 - Test basic
431
--     -- daq freq = ctrl freq/2 (default), w/o trigger, w/o skipper, channels 1 and 2, 
432
--     -- buffer size = 50h, continuous
433
--     test_number <= 3;
434
--     
435
--     WriteData(X"01", X"0003", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- Channels_R
436
--     WriteData(X"02", X"0050", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- BuffSize_R
437
--     WriteData(X"03", X"0000", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigLvl_R
438
--     WriteData(X"04", X"0000", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigOff_R
439
--     WriteData(X"00", X"0001", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- RunConf_R
440
--     
441
--     
442
--     ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
443
--     while (runflag = '1') loop
444
--       ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);    
445
--     end loop;
446
--     
447
--     wait for 50 ns;
448
--     ------------------------------------------------------------------------------------------------
449
--     -- Test 4 - Skipper
450
--     -- daq freq = ctrl freq/2 (default), w/o trigger, skipper = 3, channels 1 and 2, 
451
--     -- buffer size = 80h, no continuous
452
--     test_number <= 4;
453
--     
454
--     WriteData(X"01", X"0003", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- Channels_R
455
--     WriteData(X"02", X"0080", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- BuffSize_R
456
--     WriteData(X"03", X"0000", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigLvl_R
457
--     WriteData(X"04", X"0000", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigOff_R
458
--     WriteData(X"00", B"00000_00011_1_0_0_0_0_1", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- RunConf_R
459
--                        
460
--     
461
--     
462
--     ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
463
--     while (runflag = '1') loop
464
--       ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);    
465
--     end loop;
466
--     
467
--     -- Some samples
468
--     --     011011001  0  217
469
--     --     011110110  1  246
470
--     --     011111001  0  249  32
471
--     --     100010110  1  278  32
472
--     --     100011001  0  281  32
473
--     --     100110110  1  310  32
474
--     --     100111001  0  313  32
475
--     --     101010110  1  342  32
476
--     
477
--     
478 56 budinero
--     
479
--     wait for 50 ns;
480
--     
481
--     ------------------------------------------------------------------------------------------------
482
--     -- Test 5 - Trigger - one shot
483
--     -- daq freq = ctrl freq/2 (default), trigger channel 1, level 30 %, not continuous, skipper = 5, 
484
--     -- channels 1 and 2, buffer size = 100h, rissing edge, trigg offset = 0
485
--     test_number <= 5;
486
--     
487
--     WriteData(X"01", X"0003", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- Channels_R
488
--     WriteData(X"02", X"0100", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- BuffSize_R
489
--     WriteData(X"03", X"0133", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigLvl_R
490
--     WriteData(X"04", X"0000", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigOff_R
491
--     WriteData(X"00", B"00000_00101_1_1_0_1_0_1", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- RunConf_R
492
--     
493
--     
494
--     ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
495
--     while (runflag = '1') loop
496
--       ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);    
497
--     end loop;
498 53 budinero
 
499
 
500 54 budinero
    ------------------------------------------------------------------------------------------------
501 56 budinero
    -- Test 6 - Trigger 
502
    -- daq freq = ctrl freq/2 (default), trigger channel 1, level 70 %, continuous, skipper = 3, 
503
    -- channels 1, buffer size = 150h, falling edge, full negative trigger offset
504 57 budinero
    -- test_number <= 6;
505 54 budinero
 
506 57 budinero
    -- WriteData(X"01", X"0002", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- Channels_R
507
    -- WriteData(X"02", X"0150", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- BuffSize_R
508
    -- WriteData(X"03", X"02CD", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigLvl_R
509
    -- WriteData(X"04", X"FF6A", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigOff_R -150
510
    -- WriteData(X"00", B"00000_00011_1_1_1_1_1_1", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- RunConf_R
511 54 budinero
 
512
 
513 57 budinero
    -- ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
514
    -- i := 0;
515
    -- while (i <= 200) loop
516
      -- ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);    
517
      -- i := i + 1;
518
    -- end loop;
519 54 budinero
 
520 57 budinero
 
521
    -- WriteData(X"01", X"0002", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
522
 
523
 
524 54 budinero
    ------------------------------------------------------------------------------------------------
525
    -- Test 7 - One channel
526 56 budinero
    -- daq freq = ctrl freq/2 (default), trigger channel 0, level 30 %, continuous, skipper = 5, 
527
    -- channels 1, buffer size = 30, trigger offset 29, skipper = 10
528
    --11101101010
529
--     test_number <= 7;
530
--     
531
--     WriteData(X"01", X"0001", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- Channels_R
532
--     WriteData(X"02", X"0030", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- BuffSize_R
533
--     WriteData(X"03", X"0010", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigLvl_R
534
--     WriteData(X"04", X"0029", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigOff_R -150
535
--     WriteData(X"00", B"00000_01010_1_0_1_1_1_1", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- RunConf_R
536
--     
537
--     
538
--     ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
539
--     while (i <= 1200) loop
540
--       ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);    
541
--       i = i + 1;
542
--     end loop;
543 54 budinero
 
544
 
545
    ------------------------------------------------------------------------------------------------
546
    -- Test 8  - Test write while working
547
    -- daq freq = ctrl freq/2 (default), trigger channel 1, level 30 %, continuous, skipper = 5, 
548
    -- channels 1, buffer size = 50
549 57 budinero
--     
550
--         test_number <= 8;
551
--     
552
--     WriteData(X"01", X"0002", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- Channels_R
553
--     WriteData(X"02", X"0150", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- BuffSize_R
554
--     WriteData(X"03", X"02CD", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigLvl_R
555
--     WriteData(X"04", X"FF6A", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigOff_R -150
556
--     WriteData(X"00", B"00000_00011_1_1_1_1_1_1", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- RunConf_R
557
--     
558
--     wait for 800 ns;
559
--     WriteData(X"01", X"0002", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
560
--     
561
--     ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
562
--     i := 0;
563
--     while (i <= 200) loop
564
--       ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);    
565
--       i := i + 1;
566
--     end loop;
567 54 budinero
 
568
 
569 57 budinero
    -- ------------------------------------------------------------------------------------------------
570
    -- Test 9 - Test read with full buffer
571
    -- daq freq = ctrl freq/2 (default), w/o trigger, w/o skipper, channels 1 and 2, 
572
    -- buffer size = 50h, continuous
573
--     test_number <= 9;
574
--     
575
--     WriteData(X"01", X"0003", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- Channels_R
576
--     WriteData(X"02", X"0050", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- BuffSize_R
577
--     WriteData(X"03", X"0000", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigLvl_R
578
--     WriteData(X"04", X"0000", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigOff_R
579
--     WriteData(X"00", X"0001", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- RunConf_R
580
--     
581
--     wait for 5000 ns;
582
--     i := 0;
583
--     ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
584
--     while (i <= 25) loop
585
--       ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);    
586
--       i := i + 1;
587
--     end loop;
588
--     
589
--     -- big buffer
590
--     WriteData(X"01", X"0003", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- Channels_R
591
--     WriteData(X"02", X"03E8", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- BuffSize_R
592
--     WriteData(X"03", X"0000", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigLvl_R
593
--     WriteData(X"04", X"0000", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigOff_R
594
--     WriteData(X"00", X"0001", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- RunConf_R
595
--     
596
-- 
597
--     ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
598
--     while (runflag = '1') loop
599
--       ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);    
600
--     end loop;
601
--     
602
 
603
 
604
    ------------------------------------------------------------------------------------------------
605
    -- Test 10 - Test simple continuous
606
    -- daq freq = ctrl freq/2 (default), trigger channel 1, level 70 %, continuous, skipper = 3, 
607
    -- channels 1, buffer size = 150h, falling edge, full negative trigger offset
608
    test_number <= 10;
609 54 budinero
 
610 57 budinero
    WriteData(X"01", X"0002", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- Channels_R
611
    WriteData(X"02", X"0050", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- BuffSize_R
612
    WriteData(X"03", X"02CD", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigLvl_R
613
    WriteData(X"04", X"FF6A", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigOff_R -150
614
    WriteData(X"00", X"FFC1", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- RunConf_R
615
                      --1111111111000011
616
    --wait for 5000 ns;  
617 54 budinero
 
618
 
619 57 budinero
 
620
    test_number <= 11;
621
 
622
    ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
623
    while (runflag = '1') loop
624
      ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
625
    end loop;
626
 
627
--     ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
628
--     i := 0;
629
--     while (i <= 50) loop
630
--       ReadData2(runflag,  Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);    
631
--       i := i + 1;
632
--     end loop;
633
--     
634
--     
635
--    
636
--     test_number <= 12;
637
--     WriteData(X"01", X"0002", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- Channels_R
638
--     WriteData(X"02", X"0050", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- BuffSize_R
639
--     WriteData(X"03", X"01FF", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigLvl_R
640
--     WriteData(X"04", X"0000", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- TrigOff_R -150
641
--     WriteData(X"00", X"FFC3", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O); -- RunConf_R
642
--                       --1111 1111 1100 0011
643
--     ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
644
--     i := 0;
645
--     while (i <= 150) loop
646
--       ReadData(runflag, X"08", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);    
647
--       i := i + 1;
648
--     end loop;
649
 
650
 
651
    WriteData(X"01", X"0002", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
652
 
653
     wait for 1000 ns;
654
--     
655
--     -- reading an address
656
--     
657
     WriteData(X"09", X"0002", Data_IO, nStrobe_I, nSelectIn_I, nAutoFd_I, Busy_O);
658
       nStrobe_I <= '1'; -- '1' -> is read
659
      Data_IO <= (others => 'Z');     -- Data0          -- Address
660
      nSelectIn_I <= '0';             -- addStb
661
      wait until Busy_O = '1';
662
      wait for 30 ns; -- default
663
     -- wait for 150 ns;
664
      nSelectIn_I <= '1';
665
      wait until Busy_O = '0';
666
      wait for 30 ns;
667
 
668
 
669
    wait for 100 ns;
670
 
671 54 budinero
    tb_InitFlag <= false;
672
    wait;
673
 
674
 
675 53 budinero
  end process;
676
 
677
 
678
 
679
end architecture STIMULATOR;
680
 
681
 
682
 
683
 
684
 
685
 
686
 
687
 
688
 
689
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
690
 library ieee, std;
691
 use ieee.std_logic_1164.all;
692
 
693
 
694
-- Additional libraries used by Model Under Test.
695
-- ...
696
entity testbench is
697
end testbench;
698
 
699
architecture tbGeneratedCode of testbench is
700
    -- ADC
701
    signal adc_data_I:      std_logic_vector (9 downto 0);
702
    signal adc_sel_O:       std_logic;
703
    signal adc_clk_O:       std_logic;
704
    signal adc_sleep_O:     std_logic;
705
    signal adc_chip_sel_O:  std_logic;
706
    -- EPP
707
    signal nStrobe_I:       std_logic;
708
    signal Data_IO:         std_logic_vector (7 downto 0);
709
    signal nAck_O:          std_logic;
710
    signal busy_O:          std_logic;
711
    signal PError_O:        std_logic;
712
    signal Sel_O:           std_logic;
713
    signal nAutoFd_I:       std_logic;
714
    signal PeriphLogicH_O:  std_logic;
715
    signal nInit_I:         std_logic;
716
    signal nFault_O:        std_logic;
717
    signal nSelectIn_I:     std_logic;
718
    -- Peripherals
719
    signal reset_I:     std_logic;
720
    signal pll_clk_I:   std_logic;
721 54 budinero
 
722
 
723
    signal test_number: integer range 0 to 20;
724 53 budinero
begin
725
  --------------------------------------------------------------------------------------------------
726
  -- Instantiation of Stimulus.
727
  U_stimulus_0 : entity work.stimulus
728
    port map (
729
      -- ADC
730
      adc_data_I => adc_data_I,
731
      adc_sel_O => adc_sel_O,
732
      adc_clk_O => adc_clk_O,
733
      adc_sleep_O => adc_sleep_O,
734
      adc_chip_sel_O => adc_chip_sel_O,
735
      -- EPP
736
      nStrobe_I => nStrobe_I,
737
      Data_IO => Data_IO,
738
      nAck_O => nAck_O,
739
      busy_O => busy_O,
740
      PError_O => PError_O,
741
      Sel_O => Sel_O,
742
      nAutoFd_I => nAutoFd_I,
743
      PeriphLogicH_O =>PeriphLogicH_O ,
744
      nInit_I => nInit_I,
745
      nFault_O => nFault_O,
746
      nSelectIn_I => nSelectIn_I,
747
      -- Peripherals
748
      reset_I => reset_I,
749 54 budinero
      pll_clk_I => pll_clk_I,
750
 
751
      test_number => test_number
752 53 budinero
    );
753
 
754
  --------------------------------------------------------------------------------------------------
755
  -- Instantiation of Model Under Test.
756 54 budinero
  U_OSC0 : entity work.modular_oscilloscope --<--<--<--<--<--<--<--<--<--<--<--<--<--<--<--<--
757 53 budinero
    port map (
758
      -- ADC
759
      adc_data_I => adc_data_I,
760
      adc_sel_O => adc_sel_O,
761
      adc_clk_O => adc_clk_O,
762
      adc_sleep_O => adc_sleep_O,
763
      adc_chip_sel_O => adc_chip_sel_O,
764
      -- EPP
765
      nStrobe_I => nStrobe_I,
766
      Data_IO => Data_IO,
767
      nAck_O => nAck_O,
768
      busy_O => busy_O,
769
      PError_O => PError_O,
770
      Sel_O => Sel_O,
771
      nAutoFd_I => nAutoFd_I,
772
      PeriphLogicH_O =>PeriphLogicH_O ,
773
      nInit_I => nInit_I,
774
      nFault_O => nFault_O,
775
      nSelectIn_I => nSelectIn_I,
776
      -- Peripherals
777
      reset_I => reset_I,
778
      pll_clk_I => pll_clk_I
779
    );
780
 
781
end tbGeneratedCode;
782
----------------------------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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