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 53

Go to most recent revision | 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
--| Copyright © 2009, Facundo Aguilera.
18
--|
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
 
29
 
30
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
31
library ieee;
32
use ieee.std_logic_1164.all;
33
use ieee.math_real.all;
34
 
35
 
36
 
37
entity ctrl_tb_simple_clock is
38
  port (
39
    CLK_PERIOD: in time;-- := 20 ns;
40
    CLK_DUTY:  in  real; -- := 0.5;
41
    active:  in     boolean;
42
    clk_o:   out    std_logic
43
  );
44
end entity ctrl_tb_simple_clock ;
45
 
46
architecture beh of ctrl_tb_simple_clock is
47
begin
48
  P_main: process
49
  begin
50
    wait until active;
51
    while (active = true) loop
52
      clk_o <= '0';
53
      wait for CLK_PERIOD * (100.0 - clk_Duty)/100.0;
54
      clk_o <= '1';
55
      wait for CLK_PERIOD * clk_Duty/100.0;
56
    end loop;
57
    clk_o <= '0';
58
    wait;
59
  end process;
60
end architecture beh;
61
 
62
 
63
 
64
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
65
library ieee, std;
66
use ieee.std_logic_1164.all;
67
use ieee.std_logic_unsigned.all;
68
use IEEE.NUMERIC_STD.ALL;
69
use ieee.math_real.all;
70
 
71
 
72
-- Additional libraries used by Model Under Test.
73
use work.ctrl_pkg.all;
74
use work.daq_pkg.all;
75
use work.memory_pkg.all;
76
use work.eppwbn_pkg.all;
77
 
78
entity stimulus is
79
  port(
80
 -- ADC
81
    adc_data_I:     inout    std_logic_vector (9 downto 0) := 0;
82
    adc_sel_O:      in   std_logic;
83
    adc_clk_O:      in   std_logic;
84
    adc_sleep_O:    in   std_logic;
85
    adc_chip_sel_O: in   std_logic;
86
 
87
    -- EPP
88
    nStrobe_I:      inout std_logic;                       --  HostClk/nWrite 
89
    Data_IO:        inout std_logic_vector (7 downto 0);--   AD8..1 (Data1..Data8)
90
    nAck_O:         in std_logic;                      --  PtrClk/PeriphClk/Intr
91
    busy_O:         in std_logic;                      --  PtrBusy/PeriphAck/nWait
92
    PError_O:       in std_logic;                      --  AckData/nAckReverse
93
    Sel_O:          in std_logic;                      --  XFlag (Select)
94
    nAutoFd_I:      inout std_logic;                       --  HostBusy/HostAck/nDStrb
95
    PeriphLogicH_O: in std_logic;                      --  (Periph Logic High)
96
    nInit_I:        inout std_logic;                       --  nReverseRequest
97
    nFault_O:       in std_logic;                      --  nDataAvail/nPeriphRequest
98
    nSelectIn_I:    inout std_logic;                       --  1284 Active/nAStrb
99
 
100
    -- Peripherals
101
    reset_I:    inout std_logic;
102
    pll_clk_I:  inout std_logic  -- clock signal go to pll, and is divided in two clocks
103
  );
104
 
105
end stimulus;
106
 
107
architecture STIMULATOR of stimulus is
108
 
109
  -- Control Signal Declarations
110
  signal tb_InitFlag : boolean := false;
111
  signal tb_ParameterInitFlag : boolean := false;
112
  signal i: std_logic;
113
 
114
  -- Parm Declarations
115
  signal clk_Duty :   real := 0.0;
116
  signal clk_Period : time := 0 ns;
117
 
118
begin
119
  --------------------------------------------------------------------------------------------------
120
  -- Parm Assignment Block
121
  P_AssignParms : process
122
    variable clk_Duty_real :    real;
123
    variable clk_Period_real :  real;
124
  begin
125
    -- Basic parameters
126
    clk_Period_real := 20.0; --<--<--<--<--<--<--<--<--<--<--<--<--<--<--<--<--
127
    clk_Period <= clk_Period_real * 1 ns;
128
    clk_Duty_real := 50.0;
129
    clk_Duty <= clk_Duty_real;
130
 
131
    tb_ParameterInitFlag <= true;
132
 
133
    wait;
134
  end process;
135
 
136
 
137
  --------------------------------------------------------------------------------------------------
138
  -- Clocks
139
  -- Clock Instantiation
140
  tb_clk: entity work.tb_simple_clock
141
  port map (
142
    clk_Period => clk_Period,
143
    clk_Duty => clk_Duty,
144
    active => tb_InitFlag,
145
    clk_o => pll_clk_I
146
  );
147
 
148
 
149
  --------------------------------------------------------------------------------------------------
150
  -- Clocked Sequences
151
  P_virtual_adc: process (adc_clk_O)
152
    variable data1: std_logic_vector(9 downto 0) := 1; -- odd
153
    variable data2: std_logic_vector(9 downto 0) := 0; -- pair
154
  begin
155
    if adc_clk_O'event and adc_clk_O = '1' then
156
      data1 <= data1 + 2;
157
      data2 <= data2 + 2;
158
    end if;
159
 
160
 
161
    case adc_sel_O is
162
      when '0' =>
163
         adc_data_I <= data1;
164
      when others =>
165
         adc_data_I <= data2;
166
    end case;
167
  end process;
168
 
169
 
170
  --------------------------------------------------------------------------------------------------
171
  -- Sequence: Unclocked
172
  P_Unclocked : process
173
 
174
  begin
175
    wait until tb_ParameterInitFlag;
176
    tb_InitFlag <= true;
177
 
178
    load_I <= '0';
179
    RST_I <= '1';
180
    STB_I_port <= '1';
181
    CYC_I_port <= '1';
182
    WE_I_port <= '0';
183
    initial_address_I <= B"01_0000_0000_0000";
184
    biggest_address_I <= B"11_1100_0000_0000";
185
    pause_address_I   <= B"00_0000_1000_0000";
186
    enable_I <= '1';
187
      wait for 1.5 * clk_Period;
188
 
189
    RST_I <= '0';
190
      wait for 1.0 * clk_Period;
191
 
192
    load_I <= '1';
193
      wait for 1.0 * clk_Period;
194
 
195
 
196
 
197
 
198
    load_I <= '0';
199
    wait until ADR_O_mem = B"00_0000_1000_0000";
200
      wait for 8.0 * clk_Period;
201
 
202
    pause_address_I   <= B"01_0000_0000_0000";
203
      wait for 20.0 * clk_Period;
204
 
205
    enable_I <= '0';
206
      wait for 8.0 * clk_Period;
207
 
208
    enable_I <= '1';
209
 
210
 
211
    wait until finish_O = '1';
212
      wait for 2.0 * clk_Period;
213
 
214
    tb_InitFlag <= false;
215
    wait;
216
 
217
 
218
  end process;
219
 
220
 
221
 
222
  --------------------------------------------------------------------------------------------------
223
  -- Conditional signals
224
 
225
  P_mem: process(STB_O_mem, DAT_I_mem, CYC_O_mem, CLK_I, RST_I,i)
226
 
227
  begin
228
    if STB_O_mem = '1' and CYC_O_mem = '1' and i = '1' then
229
      ACK_I_mem <= '1';
230
    else
231
      ACK_I_mem <= '0';
232
    end if;
233
 
234
    if CLK_I'event and CLK_I = '1' then
235
      if RST_I = '1' then
236
        DAT_I_mem <= (others => '0');
237
      elsif STB_O_mem = '1' and CYC_O_mem = '1' and i = '1' then
238
        DAT_I_mem <= DAT_I_mem + 1;
239
      end if;
240
    end if;
241
 
242
    if CLK_I'event and CLK_I = '1' then
243
      if RST_I = '1' then
244
        i <= '0';
245
      elsif STB_O_mem = '1' and CYC_O_mem = '1' then
246
        i <= not(i);
247
      end if;
248
    end if;
249
 
250
  end process;
251
 
252
 
253
 
254
end architecture STIMULATOR;
255
 
256
 
257
 
258
 
259
 
260
 
261
 
262
 
263
 
264
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
265
 library ieee, std;
266
 use ieee.std_logic_1164.all;
267
 
268
 
269
 
270
-- Additional libraries used by Model Under Test.
271
-- ...
272
 
273
entity testbench is
274
  generic (
275
    MEM_ADD_WIDTH:  integer := 14
276
  );
277
end testbench;
278
 
279
architecture tbGeneratedCode of testbench is
280
    -- ADC
281
    signal adc_data_I:      std_logic_vector (9 downto 0);
282
    signal adc_sel_O:       std_logic;
283
    signal adc_clk_O:       std_logic;
284
    signal adc_sleep_O:     std_logic;
285
    signal adc_chip_sel_O:  std_logic;
286
    -- EPP
287
    signal nStrobe_I:       std_logic;
288
    signal Data_IO:         std_logic_vector (7 downto 0);
289
    signal nAck_O:          std_logic;
290
    signal busy_O:          std_logic;
291
    signal PError_O:        std_logic;
292
    signal Sel_O:           std_logic;
293
    signal nAutoFd_I:       std_logic;
294
    signal PeriphLogicH_O:  std_logic;
295
    signal nInit_I:         std_logic;
296
    signal nFault_O:        std_logic;
297
    signal nSelectIn_I:     std_logic;
298
    -- Peripherals
299
    signal reset_I:     std_logic;
300
    signal pll_clk_I:   std_logic;
301
begin
302
  --------------------------------------------------------------------------------------------------
303
  -- Instantiation of Stimulus.
304
  U_stimulus_0 : entity work.stimulus
305
    generic map (
306
    MEM_ADD_WIDTH=> MEM_ADD_WIDTH
307
    )
308
    port map (
309
      -- ADC
310
      adc_data_I => adc_data_I,
311
      adc_sel_O => adc_sel_O,
312
      adc_clk_O => adc_clk_O,
313
      adc_sleep_O => adc_sleep_O,
314
      adc_chip_sel_O => adc_chip_sel_O,
315
      -- EPP
316
      nStrobe_I => nStrobe_I,
317
      Data_IO => Data_IO,
318
      nAck_O => nAck_O,
319
      busy_O => busy_O,
320
      PError_O => PError_O,
321
      Sel_O => Sel_O,
322
      nAutoFd_I => nAutoFd_I,
323
      PeriphLogicH_O =>PeriphLogicH_O ,
324
      nInit_I => nInit_I,
325
      nFault_O => nFault_O,
326
      nSelectIn_I => nSelectIn_I,
327
      -- Peripherals
328
      reset_I => reset_I,
329
      pll_clk_I => pll_clk_I
330
    );
331
 
332
  --------------------------------------------------------------------------------------------------
333
  -- Instantiation of Model Under Test.
334
  U_outman_0 : entity work.modular_oscilloscope --<--<--<--<--<--<--<--<--<--<--<--<--<--<--<--<--
335
    generic map (
336
      MEM_ADD_WIDTH=> MEM_ADD_WIDTH
337
    )
338
    port map (
339
      -- ADC
340
      adc_data_I => adc_data_I,
341
      adc_sel_O => adc_sel_O,
342
      adc_clk_O => adc_clk_O,
343
      adc_sleep_O => adc_sleep_O,
344
      adc_chip_sel_O => adc_chip_sel_O,
345
      -- EPP
346
      nStrobe_I => nStrobe_I,
347
      Data_IO => Data_IO,
348
      nAck_O => nAck_O,
349
      busy_O => busy_O,
350
      PError_O => PError_O,
351
      Sel_O => Sel_O,
352
      nAutoFd_I => nAutoFd_I,
353
      PeriphLogicH_O =>PeriphLogicH_O ,
354
      nInit_I => nInit_I,
355
      nFault_O => nFault_O,
356
      nSelectIn_I => nSelectIn_I,
357
      -- Peripherals
358
      reset_I => reset_I,
359
      pll_clk_I => pll_clk_I
360
    );
361
 
362
end tbGeneratedCode;
363
----------------------------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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