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

Subversion Repositories astron_statistics

[/] [astron_statistics/] [trunk/] [tb_st_calc.vhd] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 danv
-------------------------------------------------------------------------------
2
--
3
-- Copyright (C) 2010
4
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6
--
7
-- This program is free software: you can redistribute it and/or modify
8
-- it under the terms of the GNU General Public License as published by
9
-- the Free Software Foundation, either version 3 of the License, or
10
-- (at your option) any later version.
11
--
12
-- This program is distributed in the hope that it will be useful,
13
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
-- GNU General Public License for more details.
16
--
17
-- You should have received a copy of the GNU General Public License
18
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
--
20
-------------------------------------------------------------------------------
21
 
22
LIBRARY IEEE, common_pkg_lib;
23
USE IEEE.std_logic_1164.ALL;
24
USE IEEE.numeric_std.ALL;
25
USE common_pkg_lib.common_pkg.ALL;
26
 
27
 
28
ENTITY tb_st_calc IS
29
  GENERIC (
30
    g_in_dat_w     : NATURAL := 16;
31
    g_out_dat_w    : NATURAL := 32
32
  );
33
END tb_st_calc;
34
 
35
 
36
ARCHITECTURE tb OF tb_st_calc IS
37
 
38
  CONSTANT clk_period             : TIME := 10 ns;
39
 
40
  CONSTANT c_nof_sync             : NATURAL := 3;
41
  CONSTANT c_nof_stat             : NATURAL := 100;
42
  CONSTANT c_out_adr_w            : NATURAL := ceil_log2(c_nof_stat);
43
  CONSTANT c_gap_size             : NATURAL := 2**c_out_adr_w - c_nof_stat;
44
 
45
  CONSTANT c_nof_accum_per_sync   : NATURAL := 5;  -- integration time
46
 
47
  SIGNAL tb_end          : STD_LOGIC := '0';
48
  SIGNAL clk             : STD_LOGIC := '0';
49
  SIGNAL rst             : STD_LOGIC;
50
 
51
  SIGNAL in_sync         : STD_LOGIC;
52
  SIGNAL in_val          : STD_LOGIC;
53
  SIGNAL in_dat          : STD_LOGIC_VECTOR(g_in_dat_w-1 DOWNTO 0);
54
 
55
  SIGNAL in_a_re         : STD_LOGIC_VECTOR(g_in_dat_w-1 DOWNTO 0);
56
  SIGNAL in_a_im         : STD_LOGIC_VECTOR(g_in_dat_w-1 DOWNTO 0);
57
  SIGNAL in_b_re         : STD_LOGIC_VECTOR(g_in_dat_w-1 DOWNTO 0);
58
  SIGNAL in_b_im         : STD_LOGIC_VECTOR(g_in_dat_w-1 DOWNTO 0);
59
 
60
  SIGNAL out_adr         : STD_LOGIC_VECTOR(c_out_adr_w-1 DOWNTO 0);
61
  SIGNAL out_re          : STD_LOGIC_VECTOR(g_out_dat_w-1 DOWNTO 0);
62
  SIGNAL out_im          : STD_LOGIC_VECTOR(g_out_dat_w-1 DOWNTO 0);
63
  SIGNAL out_val         : STD_LOGIC;
64
 
65
BEGIN
66
 
67
  clk  <= NOT clk OR tb_end AFTER clk_period/2;
68
 
69
  in_a_re <= in_dat;
70
  in_a_im <= in_dat;
71
  in_b_re <= in_dat;
72
  in_b_im <= in_dat;
73
 
74
  in_dat <= (OTHERS=>'0') WHEN rst='1' ELSE INCR_UVEC(in_dat, 1) WHEN rising_edge(clk) AND in_val='1';
75
 
76
  -- run 1 us
77
  p_stimuli : PROCESS
78
  BEGIN
79
    rst <= '1';
80
    in_sync <= '0';
81
    in_val <= '0';
82
    WAIT UNTIL rising_edge(clk);
83
    FOR I IN 0 TO 9 LOOP WAIT UNTIL rising_edge(clk); END LOOP;
84
    rst <= '0';
85
    FOR I IN 0 TO 9 LOOP WAIT UNTIL rising_edge(clk); END LOOP;
86
 
87
    FOR I IN 0 TO c_nof_sync-1 LOOP
88
      in_sync <= '1';
89
      WAIT UNTIL rising_edge(clk);
90
      in_sync <= '0';
91
 
92
      FOR J IN 0 TO c_nof_accum_per_sync-1 LOOP
93
        in_val <= '1';
94
        FOR I IN 0 TO c_nof_stat-1 LOOP WAIT UNTIL rising_edge(clk); END LOOP;
95
        in_val <= '0';
96
        FOR I IN 0 TO c_gap_size-1 LOOP WAIT UNTIL rising_edge(clk); END LOOP;
97
      END LOOP;
98
    END LOOP;
99
    FOR I IN 0 TO 9 LOOP WAIT UNTIL rising_edge(clk); END LOOP;
100
    tb_end <= '1';
101
    WAIT;
102
  END PROCESS;
103
 
104
  u_dut : ENTITY work.st_calc
105
  GENERIC MAP (
106
    g_nof_mux       => 1,
107
    g_nof_stat      => c_nof_stat,
108
    g_in_dat_w      => g_in_dat_w,
109
    g_out_dat_w     => g_out_dat_w,
110
    g_out_adr_w     => c_out_adr_w,
111
    g_complex       => FALSE
112
  )
113
  PORT MAP (
114
    rst        => rst,
115
    clk        => clk,
116
    clken      => '1',
117
    in_ar      => in_a_re,
118
    in_ai      => in_a_im,
119
    in_br      => in_b_re,
120
    in_bi      => in_b_im,
121
    in_val     => in_val,
122
    in_sync    => in_sync,
123
    out_adr    => out_adr,
124
    out_re     => out_re,
125
    out_im     => out_im,
126
    out_val    => out_val,
127
    out_val_m  => OPEN
128
  );
129
 
130
END tb;

powered by: WebSVN 2.1.0

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