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

Subversion Repositories dblclockfft

[/] [dblclockfft/] [trunk/] [bench/] [cpp/] [fft_tb.cpp] - Diff between revs 14 and 16

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 14 Rev 16
Line 107... Line 107...
                double  vout[FFTLEN*2];
                double  vout[FFTLEN*2];
                double  isq=0.0, osq = 0.0;
                double  isq=0.0, osq = 0.0;
                long    *lp;
                long    *lp;
 
 
                // Fill up our test array from the log array
                // Fill up our test array from the log array
                printf("%3d : CHECK: %8d %5x\n", m_ntest, m_iaddr, m_iaddr);
                // printf("%3d : CHECK: %8d %5x\n", m_ntest, m_iaddr, m_iaddr);
                dp = m_fft_buf; lp = &m_log[(m_iaddr-FFTLEN*3)&((4*FFTLEN-1)&(-FFTLEN))];
                dp = m_fft_buf; lp = &m_log[(m_iaddr-FFTLEN*3)&((4*FFTLEN-1)&(-FFTLEN))];
                for(int i=0; i<FFTLEN; i++) {
                for(int i=0; i<FFTLEN; i++) {
                        long    tv = *lp++;
                        long    tv = *lp++;
 
 
                        dp[0] = twos_complement(tv >> IWIDTH, IWIDTH);
                        dp[0] = twos_complement(tv >> IWIDTH, IWIDTH);
                        dp[1] = twos_complement(tv, IWIDTH);
                        dp[1] = twos_complement(tv, IWIDTH);
 
 
                        printf("IN[%4d = %4x] = %9.1f %9.1f\n",
                        // printf("IN[%4d = %4x] = %9.1f %9.1f\n",
                                i+((m_iaddr-FFTLEN*3)&((4*FFTLEN-1)&(-FFTLEN))),
                                // i+((m_iaddr-FFTLEN*3)&((4*FFTLEN-1)&(-FFTLEN))),
                                i+((m_iaddr-FFTLEN*3)&((4*FFTLEN-1)&(-FFTLEN))),
                                // i+((m_iaddr-FFTLEN*3)&((4*FFTLEN-1)&(-FFTLEN))),
                                dp[0], dp[1]);
                                // dp[0], dp[1]);
                        dp += 2;
                        dp += 2;
                }
                }
 
 
                // Let's measure ... are we the zero vector?  If not, how close?
                // Let's measure ... are we the zero vector?  If not, how close?
                dp = m_fft_buf;
                dp = m_fft_buf;
Line 134... Line 134...
                // Let's load up the output we received into vout
                // Let's load up the output we received into vout
                dp = vout;
                dp = vout;
                for(int i=0; i<FFTLEN; i++) {
                for(int i=0; i<FFTLEN; i++) {
                        long    tv = m_data[i];
                        long    tv = m_data[i];
 
 
                        printf("OUT[%4d = %4x] = ", i, i);
                        // printf("OUT[%4d = %4x] = ", i, i);
                        printf("%12lx = ", tv);
                        // printf("%12lx = ", tv);
                        *dp = twos_complement(tv >> OWIDTH, OWIDTH);
                        *dp = twos_complement(tv >> OWIDTH, OWIDTH);
                        printf("%10.1f + ", *dp);
                        // printf("%10.1f + ", *dp);
                        osq += (*dp) * (*dp); dp++;
                        osq += (*dp) * (*dp); dp++;
                        *dp = twos_complement(tv, OWIDTH);
                        *dp = twos_complement(tv, OWIDTH);
                        printf("%10.1f j", *dp);
                        // printf("%10.1f j", *dp);
                        osq += (*dp) * (*dp); dp++;
                        osq += (*dp) * (*dp); dp++;
                        printf(" <-> %12.1f %12.1f\n", m_fft_buf[2*i], m_fft_buf[2*i+1]);
                        // printf(" <-> %12.1f %12.1f\n", m_fft_buf[2*i], m_fft_buf[2*i+1]);
                }
                }
 
 
 
 
                // Let's figure out if there's a scale factor difference ...
                // Let's figure out if there's a scale factor difference ...
                double  scale = 0.0, wt = 0.0;
                double  scale = 0.0, wt = 0.0;
Line 167... Line 167...
 
 
                printf("%3d : SCALE = %12.6f, WT = %18.1f, ISQ = %15.1f, ",
                printf("%3d : SCALE = %12.6f, WT = %18.1f, ISQ = %15.1f, ",
                        m_ntest, scale, wt, isq);
                        m_ntest, scale, wt, isq);
                printf("OSQ = %18.1f, ", osq);
                printf("OSQ = %18.1f, ", osq);
                printf("XISQ = %18.1f\n", xisq);
                printf("XISQ = %18.1f\n", xisq);
 
                if (xisq > 1.2 * FFTLEN/2) {
 
                        printf("TEST FAIL!!  Result is out of bounds from ");
 
                        printf("expected result with FFTW3.\n");
 
                        exit(-2);
 
                }
                m_ntest++;
                m_ntest++;
        }
        }
 
 
        bool    test(int lft, int rht) {
        bool    test(int lft, int rht) {
                m_fft->i_ce    = 1;
                m_fft->i_ce    = 1;
Line 186... Line 191...
                if (m_fft->o_sync) {
                if (m_fft->o_sync) {
                        m_oaddr &= (-1<<LGWIDTH);
                        m_oaddr &= (-1<<LGWIDTH);
                        m_syncd = true;
                        m_syncd = true;
                } else m_oaddr += 2;
                } else m_oaddr += 2;
 
 
                printf("%8x,%5d: %08x,%08x -> %011lx,%011lx"
                /*
                        // "\t%011lx,%011lx"
                printf("%8x,%5d: %08x,%08x -> %011lx,%011lx"
                        // "\t%011lx,%011lx"
                        // "\t%011lx,%011lx"
                        // "\t%06x,%06x"
                        // "\t%011lx,%011lx"
                        // "\t%06x,%06x"
                        // "\t%06x,%06x"
                        "\t%011lx,%06x,%06x"
                        // "\t%06x,%06x"
                        "\t%011lx,%06x,%06x"
                        "\t%011lx,%06x,%06x"
                        " %s%s%s%s%s%s%s%s%s%s %s%s\n",
                        "\t%011lx,%06x,%06x"
 
                        " %s%s%s%s%s%s%s%s%s%s %s%s\n",
                        m_iaddr, m_oaddr,
                        m_iaddr, m_oaddr,
                        lft, rht, m_fft->o_left, m_fft->o_right,
                        lft, rht, m_fft->o_left, m_fft->o_right,
                        // m_fft->v__DOT__stage_e2048__DOT__ib_a,
                        // m_fft->v__DOT__stage_e2048__DOT__ib_a,
                        // m_fft->v__DOT__stage_e2048__DOT__ib_b,
                        // m_fft->v__DOT__stage_e2048__DOT__ib_b,
                        // m_fft->v__DOT__stage_e512__DOT__ib_a,
                        // m_fft->v__DOT__stage_e512__DOT__ib_a,
                        // m_fft->v__DOT__stage_e512__DOT__ib_b,
                        // m_fft->v__DOT__stage_e512__DOT__ib_b,
                        // m_fft->v__DOT__stage_e256__DOT__ib_a,
                        // m_fft->v__DOT__stage_e256__DOT__ib_a,
                        // m_fft->v__DOT__stage_e256__DOT__ib_b,
                        // m_fft->v__DOT__stage_e256__DOT__ib_b,
                        // m_fft->v__DOT__stage_e128__DOT__ib_a,
                        // m_fft->v__DOT__stage_e128__DOT__ib_a,
                        // m_fft->v__DOT__stage_e128__DOT__ib_b,
                        // m_fft->v__DOT__stage_e128__DOT__ib_b,
                        // m_fft->v__DOT__stage_e64__DOT__ib_a,
                        // m_fft->v__DOT__stage_e64__DOT__ib_a,
                        // m_fft->v__DOT__stage_e64__DOT__ib_b,
                        // m_fft->v__DOT__stage_e64__DOT__ib_b,
                        // m_fft->v__DOT__stage_e32__DOT__ib_a,
                        // m_fft->v__DOT__stage_e32__DOT__ib_a,
                        // m_fft->v__DOT__stage_e32__DOT__ib_b,
                        // m_fft->v__DOT__stage_e32__DOT__ib_b,
                        // m_fft->v__DOT__stage_e16__DOT__ib_a,
                        // m_fft->v__DOT__stage_e16__DOT__ib_a,
                        // m_fft->v__DOT__stage_e16__DOT__ib_b,
                        // m_fft->v__DOT__stage_e16__DOT__ib_b,
                        // m_fft->v__DOT__stage_e8__DOT__ib_a,
                        // m_fft->v__DOT__stage_e8__DOT__ib_a,
                        // m_fft->v__DOT__stage_e8__DOT__ib_b,
                        // m_fft->v__DOT__stage_e8__DOT__ib_b,
                        // m_fft->v__DOT__stage_o8__DOT__ib_a,
                        // m_fft->v__DOT__stage_o8__DOT__ib_a,
                        // m_fft->v__DOT__stage_o8__DOT__ib_b,
                        // m_fft->v__DOT__stage_o8__DOT__ib_b,
                        // m_fft->v__DOT__stage_e4__DOT__sum_r,
                        // m_fft->v__DOT__stage_e4__DOT__sum_r,
                        // m_fft->v__DOT__stage_e4__DOT__sum_i,
                        // m_fft->v__DOT__stage_e4__DOT__sum_i,
                        // m_fft->v__DOT__stage_o4__DOT__sum_r,
                        // m_fft->v__DOT__stage_o4__DOT__sum_r,
                        // m_fft->v__DOT__stage_o4__DOT__sum_i,
                        // m_fft->v__DOT__stage_o4__DOT__sum_i,
                        m_fft->v__DOT__stage_e4__DOT__ob_a,
                        m_fft->v__DOT__stage_e4__DOT__ob_a,
                        m_fft->v__DOT__stage_e4__DOT__ob_b_r,
                        m_fft->v__DOT__stage_e4__DOT__ob_b_r,
                        m_fft->v__DOT__stage_e4__DOT__ob_b_i,
                        m_fft->v__DOT__stage_e4__DOT__ob_b_i,
                        m_fft->v__DOT__stage_o4__DOT__ob_a,
                        m_fft->v__DOT__stage_o4__DOT__ob_a,
                        m_fft->v__DOT__stage_o4__DOT__ob_b_r,
                        m_fft->v__DOT__stage_o4__DOT__ob_b_r,
                        m_fft->v__DOT__stage_o4__DOT__ob_b_i,
                        m_fft->v__DOT__stage_o4__DOT__ob_b_i,
//                      m_fft->v__DOT__stage_2__DOT__out_0r,
//                      m_fft->v__DOT__stage_2__DOT__out_0r,
//                      m_fft->v__DOT__stage_2__DOT__out_0i,
//                      m_fft->v__DOT__stage_2__DOT__out_0i,
//                      m_fft->v__DOT__stage_2__DOT__out_1r,
//                      m_fft->v__DOT__stage_2__DOT__out_1r,
//                      m_fft->v__DOT__stage_2__DOT__out_1i,
//                      m_fft->v__DOT__stage_2__DOT__out_1i,
                        (m_fft->v__DOT__w_s2048)?"S":"-",
                        (m_fft->v__DOT__w_s2048)?"S":"-",
                        (m_fft->v__DOT__w_s1024)?"S":"-",
                        (m_fft->v__DOT__w_s1024)?"S":"-",
                        (m_fft->v__DOT__w_s512)?"S":"-",
                        (m_fft->v__DOT__w_s512)?"S":"-",
                        (m_fft->v__DOT__w_s256)?"S":"-",
                        (m_fft->v__DOT__w_s256)?"S":"-",
                        (m_fft->v__DOT__w_s128)?"S":"-",
                        (m_fft->v__DOT__w_s128)?"S":"-",
                        (m_fft->v__DOT__w_s64)?"S":"-",
                        (m_fft->v__DOT__w_s64)?"S":"-",
                        (m_fft->v__DOT__w_s32)?"S":"-",
                        (m_fft->v__DOT__w_s32)?"S":"-",
                        (m_fft->v__DOT__w_s16)?"S":"-",
                        (m_fft->v__DOT__w_s16)?"S":"-",
                        (m_fft->v__DOT__w_s8)?"S":"-",
                        (m_fft->v__DOT__w_s8)?"S":"-",
                        (m_fft->v__DOT__w_s4)?"S":"-",
                        (m_fft->v__DOT__w_s4)?"S":"-",
                //      (m_fft->v__DOT__w_s2)?"S":"-", // doesn't exist
                //      (m_fft->v__DOT__w_s2)?"S":"-", // doesn't exist
                        (m_fft->o_sync)?"\t(SYNC!)":"",
                        (m_fft->o_sync)?"\t(SYNC!)":"",
                        (m_fft->o_left | m_fft->o_right)?"  (NZ)":"");
                        (m_fft->o_left | m_fft->o_right)?"  (NZ)":"");
 
                */
 
 
                m_data[(m_oaddr  )&(FFTLEN-1)] = m_fft->o_left;
                m_data[(m_oaddr  )&(FFTLEN-1)] = m_fft->o_left;
                m_data[(m_oaddr+1)&(FFTLEN-1)] = m_fft->o_right;
                m_data[(m_oaddr+1)&(FFTLEN-1)] = m_fft->o_right;
 
 
                if ((m_syncd)&&((m_oaddr&(FFTLEN-1)) == FFTLEN-2)) {
                if ((m_syncd)&&((m_oaddr&(FFTLEN-1)) == FFTLEN-2)) {
Line 510... Line 517...
                fft->test(0.0,0.0,0.0,0.0);
                fft->test(0.0,0.0,0.0,0.0);
 
 
 
 
 
 
        fclose(fpout);
        fclose(fpout);
 
 
 
        printf("SUCCESS!!\n");
 
        exit(0);
}
}
 
 
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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