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

Subversion Repositories versatile_fft

[/] [versatile_fft/] [trunk/] [multiple_units/] [src/] [fft_engine_tb.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 wzab
-------------------------------------------------------------------------------
2
-- Title      : Testbench for design "fft_top"
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : fft_top_tb.vhd
6
-- Author     : Wojciech Zabolotny
7
-- Company    : 
8
-- License    : BSD
9
-- Created    : 2014-01-21
10
-- Last update: 2015-03-24
11
-- Platform   : 
12
-- Standard   : VHDL'87
13
-------------------------------------------------------------------------------
14
-- Description: 
15
-------------------------------------------------------------------------------
16
-- Copyright (c) 2014 
17
-------------------------------------------------------------------------------
18
-- Revisions  :
19
-- Date        Version  Author  Description
20
-- 2014-01-21  1.0      wzab    Created
21
-------------------------------------------------------------------------------
22
 
23
library ieee;
24
use ieee.std_logic_1164.all;
25
use ieee.numeric_std.all;
26
use ieee.math_real.all;
27
use ieee.math_complex.all;
28
library std;
29
use std.textio.all;
30
library work;
31
use work.fft_len.all;
32
use work.icpx.all;
33
use work.fft_support_pkg.all;
34
 
35
-------------------------------------------------------------------------------
36
 
37
entity fft_engine_tb is
38
 
39
end fft_engine_tb;
40
 
41
-------------------------------------------------------------------------------
42
 
43
architecture beh1 of fft_engine_tb is
44
 
45
  type T_OUT_DATA is array (0 to FFT_LEN-1) of icpx_number;
46
 
47
  signal dptr                 : integer range 0 to 15;
48
  signal din, sout0, sout1    : icpx_number;
49
  signal saddr, saddr_rev     : unsigned(LOG2_FFT_LEN-2 downto 0);
50
  signal end_of_data, end_sim : boolean := false;
51
 
52
  component fft_engine is
53
    generic (
54
      LOG2_FFT_LEN : integer);
55
    port (
56
      rst_n     : in  std_logic;
57
      clk       : in  std_logic;
58
      din       : in  icpx_number;
59
      valid     : out std_logic;
60
      saddr     : out unsigned(LOG2_FFT_LEN-2 downto 0);
61
      saddr_rev : out unsigned(LOG2_FFT_LEN-2 downto 0);
62
      sout0     : out icpx_number;
63
      sout1     : out icpx_number
64
      );
65
  end component fft_engine;
66
 
67
  -- component ports
68
  signal rst_n : std_logic := '0';
69
 
70
  -- clock
71
  signal Clk : std_logic := '1';
72
 
73
begin  -- beh1
74
 
75
  -- component instantiation
76
  fft_engine_1 : entity work.fft_engine
77
    generic map (
78
      LOG2_FFT_LEN => LOG2_FFT_LEN)
79
    port map (
80
      rst_n     => rst_n,
81
      clk       => clk,
82
      din       => din,
83
      saddr     => saddr,
84
      saddr_rev => saddr_rev,
85
      sout0     => sout0,
86
      sout1     => sout1);
87
  -- clock generation
88
 
89
  Clk <= not Clk after 10 ns when end_sim = false else '0';
90
 
91
  -- waveform generation
92
  WaveGen_Proc : process
93
    file data_in         : text open read_mode is "data_in.txt";
94
    variable input_line  : line;
95
    file data_out        : text open write_mode is "data_out.txt";
96
    variable output_line : line;
97
    variable tre, tim    : real;
98
    constant sep         : string := " ";
99
    variable vout        : T_OUT_DATA;
100
  begin
101
    -- insert signal assignments here
102
    wait until Clk = '1';
103
    wait for 15 ns;
104
    wait until clk = '0';
105
    wait until clk = '1';
106
    rst_n <= '1';
107
    dptr  <= 0;
108
    l1 : while not end_sim loop
109
      if not endfile(data_in) then
110
        readline(data_in, input_line);
111
        read(input_line, tre);
112
        read(input_line, tim);
113
      else
114
        end_of_data <= true;
115
      end if;
116
      din <= cplx2icpx(complex'(tre, tim));
117
      if dptr < 15 then
118
        dptr <= dptr + 1;
119
      else
120
        dptr <= 0;
121
      end if;
122
      -- Copy the data produced by the core to the output buffer
123
      vout(to_integer(saddr_rev))       := sout0;
124
      vout(to_integer('1' & saddr_rev)) := sout1;
125
      -- If the full set of data is calculated, write the output buffer
126
      if saddr = FFT_LEN/2-1 then
127
        write(output_line, string'("FFT RESULT BEGIN"));
128
        writeline(data_out, output_line);
129
        for i in 0 to FFT_LEN-1 loop
130
          write(output_line, integer'image(to_integer(vout(i).re)));
131
          write(output_line, sep);
132
          write(output_line, integer'image(to_integer(vout(i).im)));
133
          writeline(data_out, output_line);
134
        end loop;  -- i
135
        write(output_line, string'("FFT RESULT END"));
136
        writeline(data_out, output_line);
137
        exit l1 when end_of_data;
138
      end if;
139
      wait until clk = '0';
140
      wait until clk = '1';
141
    end loop l1;
142
    end_sim <= true;
143
 
144
  end process WaveGen_Proc;
145
 
146
 
147
 
148
end beh1;
149
 
150
 

powered by: WebSVN 2.1.0

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