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

Subversion Repositories modular_oscilloscope

[/] [modular_oscilloscope/] [trunk/] [hdl/] [ctrl/] [tbench/] [trigger_manager_tbench_text.vhd] - Blame information for rev 55

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 36 budinero
-------------------------------------------------------------------------------------------------100
2
--| Modular Oscilloscope
3
--| UNSL - Argentine
4
--|
5
--| File: trigger_manager_tbench_text.vhd
6
--| Version: 0.01
7
--| Tested in: Actel A3PE1500
8
--|-------------------------------------------------------------------------------------------------
9
--| Description:
10
--|   This file is only for test purposes. 
11
--|   It may not work for other than Actel Libero software.
12
--|-------------------------------------------------------------------------------------------------
13
--| File history:
14
--|   0.01  | apr-2009 | First release
15
----------------------------------------------------------------------------------------------------
16
--| Copyright © 2009, Facundo Aguilera.
17
--|
18
--| This VHDL design file is an open design; you can redistribute it and/or
19
--| modify it and/or implement it after contacting the author.
20
----------------------------------------------------------------------------------------------------
21
 
22
 
23
-- NOTE:  It may not work for other than Actel Libero software.
24
--        You can download Libero for free from Actel website (it is not a free software).
25
 
26
 
27
 
28
library ieee, std;
29
use ieee.std_logic_1164.all;
30
use ieee.std_logic_unsigned.all;
31
library syncad_vhdl_lib;
32
use syncad_vhdl_lib.TBDefinitions.all;
33
use IEEE.NUMERIC_STD.ALL;
34
 
35
 
36
 
37
-- Additional libraries used by Model Under Test.
38
use ieee.math_real.all;
39
 
40
 
41
 
42
----------------------------------------------------------------------------------------------------
43
entity stimulus is
44
  generic (
45
    MEM_ADD_WIDTH:  integer := 14;
46
    DATA_WIDTH:     integer := 10;
47
    CHANNELS_WIDTH: integer := 4
48
  );
49
  port (
50
    data_I:           inout  std_logic_vector (DATA_WIDTH - 1 downto 0);
51
    channel_I:        inout  std_logic_vector (CHANNELS_WIDTH -1 downto 0);
52
    trig_channel_I:   inout  std_logic_vector (CHANNELS_WIDTH -1 downto 0);
53
    address_I:        inout  std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
54
    final_address_I:  inout  std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
55
    offset_I:         inout std_logic_vector (MEM_ADD_WIDTH  downto 0);
56
    level_I:          inout  std_logic_vector (DATA_WIDTH - 1 downto 0);
57
    falling_I:        inout  std_logic;
58
    clk_I:            inout  std_logic;
59
    reset_I:          inout  std_logic;
60
    enable_I:         inout  std_logic
61
 
62
  );
63
 
64
end stimulus;
65
 
66
architecture STIMULATOR of stimulus is
67
 
68
  -- Control Signal Declarations
69
  signal tb_status : TStatus;
70
  signal tb_ParameterInitFlag : boolean := false;
71
 
72
  -- Parm Declarations
73
  signal T : real := 10.0;
74
  signal clk_MinHL :  time := 0 ns;
75
  signal clk_MaxHL :  time := 0 ns;
76
  signal clk_MinLH :  time := 0 ns;
77
  signal clk_MaxLH :  time := 0 ns;
78
  signal clk_JFall :  time := 0 ns;
79
  signal clk_JRise :  time := 0 ns;
80
  signal clk_Duty :   real := 0.0;
81
  signal clk_Period : time := 0 ns;
82
  signal clk_Offset : time := 0 ns;
83
 
84
 
85
 
86
begin
87
  --------------------------------------------------------------------------------------------------
88
  -- Parm Assignment Block
89
  AssignParms : process
90
    variable clk_MinHL_real :   real;
91
    variable clk_MaxHL_real :   real;
92
    variable clk_MinLH_real :   real;
93
    variable clk_MaxLH_real :   real;
94
    variable clk_JFall_real :   real;
95
    variable clk_JRise_real :   real;
96
    variable clk_Duty_real :    real;
97
    variable clk_Period_real :  real;
98
    variable clk_Offset_real :  real;
99
  begin
100
    -- Basic parameters
101
    clk_Period_real := T; --<--<--<--<--<--<--<--<--<--<--<--<--<--<--<--<--
102
    clk_Period <= clk_Period_real * 1 ns;
103
    clk_Duty_real := 50.0;
104
    clk_Duty <= clk_Duty_real;
105
 
106
    -- Aditionale parameters
107
    clk_MinHL_real := 0.0;
108
    clk_MinHL <= clk_MinHL_real * 1 ns;
109
    clk_MaxHL_real := 0.0;
110
    clk_MaxHL <= clk_MaxHL_real * 1 ns;
111
    clk_MinLH_real := 0.0;
112
    clk_MinLH <= clk_MinLH_real * 1 ns;
113
    clk_MaxLH_real := 0.0;
114
    clk_MaxLH <= clk_MaxLH_real * 1 ns;
115
    clk_JFall_real := 0.0;
116
    clk_JFall <= clk_JFall_real * 1 ns;
117
    clk_JRise_real := 0.0;
118
    clk_JRise <= clk_JRise_real * 1 ns;
119
    clk_Offset_real := 0.0;
120
    clk_Offset <= clk_Offset_real * 1 ns;
121
    tb_ParameterInitFlag <= true;
122
 
123
    wait;
124
  end process;
125
 
126
 
127
  --------------------------------------------------------------------------------------------------
128
  -- Clocks
129
  -- Clock Instantiation
130
  tb_clk : entity syncad_vhdl_lib.tb_clock_minmax
131
    generic map (name => "tb_clk",
132
                initialize => true,
133
                state1 => '1',
134
                state2 => '0')
135
    port map (tb_status,
136
              clk_I, --<--<--<--<--<--<--<--<--<--<--<--<--<--<--<--<--
137
              clk_MinLH,
138
              clk_MaxLH,
139
              clk_MinHL,
140
              clk_MaxHL,
141
              clk_Offset,
142
              clk_Period,
143
              clk_Duty,
144
              clk_JRise,
145
              clk_JFall);
146
 
147
  -- Clocked Sequences
148
  Var: process
149
  begin
150
    data_I <= (others => '0');
151
    channel_I <= (others => '0');
152
 
153
    while tb_status /= TB_DONE loop
154
      wait for T * 1 ns;
155
      data_I <= std_logic_vector(unsigned(data_I)+1);
156
      channel_I <= std_logic_vector(unsigned(channel_I)+1);
157
    end loop;
158
    wait;
159
 
160
  end process;
161
 
162
 
163
  --------------------------------------------------------------------------------------------------
164
  -- Sequence: Unclocked
165
  Unclocked : process
166
    variable i: natural range 0 to integer(2.0**real(address_I'length));
167
    variable j: natural range 0 to 500;
168
    --variable max: integer range<>;
169
  begin
170
    wait until tb_ParameterInitFlag;
171
    tb_status <= TB_ONCE;
172
    ------------------------------------------------------------------------------------------------
173
    -- Initial
174
 
175
 
176
    trig_channel_I  <=            "0010";
177
    address_I       <= (others => '0');
178
    final_address_I <=  "11110000000000";
179
    offset_I        <= "001110001111011";
180
    level_I         <=      "1101000101";
181
    falling_I       <= '0';
182
    reset_I         <= '1';
183
    enable_I        <= '1';
184
      wait for 3.5 * T * 1 ns;
185
 
186
    reset_I <= '0';
187
      wait for T * 1 ns;
188
 
189
    for j in 0 to 1 loop
190
      for i in 0 to to_integer(unsigned(final_address_I)) loop
191
 
192
        address_I <= std_logic_vector(to_unsigned(i, address_I'length ));
193
          wait for T * 1 ns;
194
      end loop;
195
    end loop;
196
 
197
    ------------------------------------------------------------------------------------------------
198
    -- test falling
199
    reset_I         <= '1';
200
    falling_I       <= '1';
201
      wait for T * 1 ns;
202
 
203
    reset_I         <= '0';
204
 
205
    for j in 0 to 1 loop
206
      for i in 0 to to_integer(unsigned(final_address_I)) loop
207
        address_I <= std_logic_vector(to_unsigned(i, address_I'length ));
208
          wait for T * 1 ns;
209
      end loop;
210
    end loop;
211
 
212
    ------------------------------------------------------------------------------------------------
213
    -- test big offset
214
    reset_I         <= '1';
215
    falling_I       <= '0';
216
   -- address_I       <=  "10011111111111";
217
    offset_I        <= "011101010011000";
218
      wait for T * 1 ns;
219
 
220
    reset_I         <= '0';
221
 
222
    --for j in 0 to 1 loop
223
      for i in 0 to to_integer(unsigned(final_address_I)) loop
224
        address_I <= std_logic_vector(to_unsigned(i, address_I'length ));
225
          wait for T * 1 ns;
226
      end loop;
227
    --end loop;
228
 
229
   ------------------------------------------------------------------------------------------------
230
    -- test negative offset
231
    reset_I         <= '1';
232
    falling_I       <= '0';
233
    -- address_I       <=  "10011111111111";
234
    offset_I        <= "111101001010110";
235
      wait for T * 1 ns;
236
 
237
    reset_I         <= '0';
238
 
239
    --for j in 0 to 1 loop
240
      for i in 0 to to_integer(unsigned(final_address_I)) loop
241
        address_I <= std_logic_vector(to_unsigned(i, address_I'length ));
242
          wait for T * 1 ns;
243
      end loop;
244
    --end loop;
245
 
246
    ------------------------------------------------------------------------------------------------
247
    -- test zero offset
248
 
249
    reset_I         <= '1';
250
    falling_I       <= '0';
251
    -- address_I       <=  "10011111111111";
252
    offset_I        <= "000000000000000";
253
      wait for T * 1 ns;
254
 
255
    reset_I         <= '0';
256
 
257
    --for j in 0 to 1 loop
258
      for i in 0 to to_integer(unsigned(final_address_I)) loop
259
        address_I <= std_logic_vector(to_unsigned(i, address_I'length ));
260
          wait for T * 1 ns;
261
      end loop;
262
    --end loop;
263
 
264
    ------------------------------------------------------------------------------------------------
265
    -- test big offset
266
 
267
    reset_I         <= '1';
268
    falling_I       <= '0';
269
    -- address_I       <=  "10011111111111";
270
    offset_I        <= "100010000000000";
271
      wait for T * 1 ns;
272
 
273
    reset_I         <= '0';
274
 
275
    --for j in 0 to 1 loop
276
      for i in 0 to to_integer(unsigned(final_address_I)) loop
277
        address_I <= std_logic_vector(to_unsigned(i, address_I'length ));
278
          wait for T * 1 ns;
279
      end loop;
280
    --end loop;
281
 
282
    ------------------------------------------------------------------------------------------------
283
    -- test big final_address_I
284
 
285
    final_address_I <=  "11111111111111";
286
    reset_I         <= '1';
287
    falling_I       <= '0';
288
    -- address_I         <=  "10011111111111";
289
    offset_I        <= "011111010000000";
290
      wait for T * 1 ns;
291
 
292
    reset_I         <= '0';
293
 
294
    --for j in 0 to 1 loop
295
      for i in 0 to to_integer(unsigned(final_address_I)) loop
296
        address_I <= std_logic_vector(to_unsigned(i, address_I'length ));
297
          wait for T * 1 ns;
298
      end loop;
299
    --end loop;
300
 
301
    tb_status <= TB_DONE;  -- End of simulation
302
    wait;
303
 
304
 
305
  end process;
306
end STIMULATOR;
307
----------------------------------------------------------------------------------------------------
308
 
309
 
310
 
311
 
312
-- Test Bench wrapper for stimulus and Model Under Test
313
 library ieee, std;
314
 use ieee.std_logic_1164.all;
315
 library syncad_vhdl_lib;
316
 use syncad_vhdl_lib.TBDefinitions.all;
317
 
318
-- Additional libraries used by Model Under Test.
319
-- ...
320
 
321
 
322
 
323
----------------------------------------------------------------------------------------------------
324
entity testbench is
325
  generic (
326
    MEM_ADD_WIDTH:  integer := 14;
327
    DATA_WIDTH:     integer := 10;
328
    CHANNELS_WIDTH: integer := 4
329
  );
330
end testbench;
331
 
332
architecture tbGeneratedCode of testbench is
333
    signal data_I:             std_logic_vector (DATA_WIDTH - 1 downto 0);
334
    signal channel_I:          std_logic_vector (CHANNELS_WIDTH -1 downto 0);
335
    signal trig_channel_I:     std_logic_vector (CHANNELS_WIDTH -1 downto 0);
336
    signal address_I:          std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
337
    signal final_address_I:    std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
338
    signal offset_I:          std_logic_vector (MEM_ADD_WIDTH  downto 0);
339
    signal level_I:            std_logic_vector (DATA_WIDTH - 1 downto 0);
340
    signal falling_I:        std_logic;
341
    signal clk_I:            std_logic;
342
    signal reset_I:          std_logic;
343
    signal enable_I:         std_logic;
344
    signal trigger_O:         std_logic;
345
    signal address_O:         std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
346
 
347
begin
348
  --------------------------------------------------------------------------------------------------
349
  -- Instantiation of Stimulus.
350
  stimulus_0 : entity work.stimulus
351
    generic map (
352
 
353
    MEM_ADD_WIDTH=> MEM_ADD_WIDTH,
354
    DATA_WIDTH => DATA_WIDTH,
355
    CHANNELS_WIDTH => CHANNELS_WIDTH
356
    )
357
    port map (
358
    data_I => data_I,
359
    channel_I => channel_I,
360
    trig_channel_I => trig_channel_I,
361
    address_I => address_I,
362
    final_address_I => final_address_I,
363
    offset_I => offset_I,
364
    level_I => level_I,
365
    falling_I => falling_I,
366
    clk_I => clk_I,
367
    reset_I => reset_I,
368
    enable_I => enable_I
369
    );
370
 
371
  --------------------------------------------------------------------------------------------------
372
  -- Instantiation of Model Under Test.
373
  trig_0 : entity work.trigger_manager --<--<--<--<--<--<--<--<--<--<--<--<--<--<--<--<--
374
    generic map (
375
 
376
    MEM_ADD_WIDTH=> MEM_ADD_WIDTH,
377
    DATA_WIDTH => DATA_WIDTH,
378
    CHANNELS_WIDTH => CHANNELS_WIDTH
379
    )
380
    port map (
381
    data_I => data_I,
382
    channel_I => channel_I,
383
    trig_channel_I => trig_channel_I,
384
    address_I => address_I,
385
    final_address_I => final_address_I,
386
    offset_I => offset_I,
387
    level_I => level_I,
388
    falling_I => falling_I,
389
    clk_I => clk_I,
390
    reset_I => reset_I,
391
    enable_I => enable_I,
392
        trigger_O => trigger_O,
393
 
394
    address_O => address_O
395
    );
396
end tbGeneratedCode;
397
----------------------------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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