aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/bug029/fft.vhdl
blob: 704de1c7e2fa0e247fc5f4c69c451be80cbbcabe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package fft_package is
  TYPE complex IS ARRAY(0 TO 1) OF INTEGER;
  CONSTANT w0 : complex := (1, 0);  --Pre-computed constants
  CONSTANT w1 : complex := (0, -1); --Pre-computed constants

  function butterfly(X1, X2 , W : complex )return complex;
END fft_package;

package body fft_package is

    function butterfly ( X1, X2 , W : complex )return complex is
      VARIABLE Y1, Y2  : complex;

    BEGIN
        -- G1 = X1 + W*X2
        G1:Y1(0) := X1(0) + ((W(0)*X2(0)) - W(1)*X2(1)); -- G1 real
        Y1(1) := X1(1) + ((W(0)*X2(1)) + W(1)*X2(0)); -- G1 imaginary

        -- G2 = X1 - W*X2
        Y2(0) := X1(0) - ((W(0)*X2(0)) - W(1)*X2(1)); -- G2 real
        Y2(1) := X1(1) - ((W(0)*X2(1)) + W(1)*X2(0)); -- G2 imaginary
         return Y1;
         return Y2;
    END butterfly;
end fft_package;