Line 1... |
Line 1... |
//
|
//
|
// Filename: fft_tb.cpp
|
// Filename: fft_tb.cpp
|
//
|
//
|
// Project: A Doubletime Pipelined FFT
|
// Project: A Doubletime Pipelined FFT
|
//
|
//
|
// Purpose: A test-bench for the mail program, fftmain.v, of the double
|
// Purpose: A test-bench for the main program, fftmain.v, of the double
|
// clocked FFT. This file may be run autonomously (when
|
// clocked FFT. This file may be run autonomously (when
|
// fully functional). If so, the last line output will either
|
// fully functional). If so, the last line output will either
|
// read "SUCCESS" on success, or some other failure message
|
// read "SUCCESS" on success, or some other failure message
|
// otherwise.
|
// otherwise.
|
//
|
//
|
Line 135... |
Line 135... |
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("%16lx = ", tv);
|
printf("%12lx = ", tv);
|
*dp = twos_complement(tv >> OWIDTH, OWIDTH);
|
*dp = twos_complement(tv >> OWIDTH, OWIDTH);
|
printf("%12.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("%12.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]);
|
}
|
}
|
|
|
|
|
Line 270... |
Line 270... |
}
|
}
|
|
|
double rdata(int addr) {
|
double rdata(int addr) {
|
long ivl = m_data[addr & (FFTLEN-1)];
|
long ivl = m_data[addr & (FFTLEN-1)];
|
|
|
ivl = ivl >> 17;
|
ivl = twos_complement(ivl >> OWIDTH, OWIDTH);
|
ivl &= ((1<<OWIDTH)-1);
|
|
if (1 & (ivl>>(OWIDTH-1)))
|
|
ivl |= (-1l << OWIDTH);
|
|
return (double)ivl;
|
return (double)ivl;
|
}
|
}
|
|
|
double idata(int addr) {
|
double idata(int addr) {
|
long ivl = m_data[addr & (FFTLEN-1)];
|
long ivl = m_data[addr & (FFTLEN-1)];
|
|
|
ivl = ivl;
|
ivl = twos_complement(ivl, OWIDTH);
|
ivl &= ((1<<OWIDTH)-1);
|
|
if (1 & (ivl>>(OWIDTH-1)))
|
|
ivl |= (-1l << OWIDTH);
|
|
return (double)ivl;
|
return (double)ivl;
|
}
|
}
|
|
|
void dump(FILE *fp) {
|
void dump(FILE *fp) {
|
m_dumpfp = fp;
|
m_dumpfp = fp;
|