|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- ------------------------------------------------------------------------
- -- fft_magnitude_calc
- --
- -- calculation of FFT magnitude sqrt(real_part²+im_part²)
- -- Inputs:
- -- input_re in: +-1 signed Fixpoint (0.5=0x40000000, -0.5=0xC0000000 (negative numbers in 2K)
- -- input_im in: +-1 signed Fixpoint (0.5=0x40000000, -0.5=0xC0000000 (negative numbers in 2K)
- -- input_valid: high = inputs are valid for data processing
- -- Outputs
- -- output_magnitude: Fixpoint 0.5=0x40000000 (always positive)
- -- output_valid: high = magnitude data is valid
- -----------------------------------------------------------------------
-
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.numeric_std.all;
-
- entity tb_fft_magnitude_calc is
- generic( GUI_MODE : boolean; CHECK_RESULTS : boolean );
- end entity tb_fft_magnitude_calc;
-
-
- architecture rtl of tb_fft_magnitude_calc is
-
-
- signal clk : std_logic := '0'; -- Takt
- signal reset : std_logic := '1'; -- Reset
- signal input_valid: std_logic := '0'; -- Eingangsdaten gültig
- signal input_re : std_logic_vector( 31 downto 0 ) := X"40000000"; -- Realteil in Fixpoint
- signal input_im : std_logic_vector( 31 downto 0 ):= X"40000000"; -- Imaginärteil in Fixpoint
- signal output_valid : std_logic; -- Ausgangsdaten gültig
- signal output_magnitude : std_logic_vector( 31 downto 0 );
-
- begin
-
- clk <= not clk after 10 ns;
-
- reset_release : process is
- begin
- wait for 435 ns;
- reset <= '0';
- wait;
- end process reset_release;
-
- -- Instanziierung des SQRT Moduls für die Berechnung der Quardratwurzel
- -- Weisen Sie die Signale output_sqrt, reset, input_sqrt und clk richtig zu
- fft_magnitude_calc_module : entity work.fft_magnitude_calc
- port map (
- clk => clk,
- reset => reset,
- input_valid => input_valid, -- Eingangsdaten gültig
- input_re => input_re, -- Realteil in Fixpoint
- input_im => input_im, -- Imaginärteil in Fixpoint
- output_valid => output_valid, -- Ausgangsdaten gültig
- output_magnitude => output_magnitude -- Berechnete magnitude
- );
-
- stimulus: process is
- begin
- wait until falling_edge( reset );
- wait until falling_edge( clk );
- input_valid <= '1';
- wait until falling_edge( clk );
- input_valid <= '0';
-
- wait until falling_edge( output_valid );
-
- wait for 200 ns;
-
- wait until falling_edge( clk );
- input_valid <= '1';
- input_re <= X"20000000";
- input_im <= X"20000000";
- wait until falling_edge( clk );
- input_valid <= '0';
-
- wait until falling_edge( output_valid );
-
-
- wait until falling_edge( clk );
- if ( GUI_MODE ) then
- std.env.stop;
- else
- std.env.finish;
- end if;
-
- end process stimulus;
-
- end architecture rtl;
|