Bit Reverse in TIE Instruktion implementiert
This commit is contained in:
parent
d7aa4d18fe
commit
0c0c708e70
24
fft.c
24
fft.c
@ -60,14 +60,11 @@ int fix_fft(fixed fr[], fixed fi[], int m, int inverse)
|
||||
nn = n - 1;
|
||||
scale = 0;
|
||||
|
||||
int mm = m;
|
||||
|
||||
/* decimation in time - re-order data */
|
||||
for(m=1; m<=nn; ++m) {
|
||||
l = n;
|
||||
do{
|
||||
l >>= 1;
|
||||
}while(mr+l > nn);
|
||||
mr = (mr & (l-1)) + l;
|
||||
mr = FFT_bit_reverse(m, mm);
|
||||
|
||||
if(mr <= m) continue;
|
||||
tr = fr[m];
|
||||
@ -119,23 +116,16 @@ int fix_fft(fixed fr[], fixed fi[], int m, int inverse)
|
||||
for(m=0; m<l; ++m)
|
||||
{
|
||||
j = m << k;
|
||||
/* 0 <= j < N_WAVE/2 */
|
||||
wr = Sinewave[j+N_WAVE/4];
|
||||
wi = -Sinewave[j];
|
||||
|
||||
if(inverse) wi = -wi;
|
||||
if(shift)
|
||||
{
|
||||
wr >>= 1;
|
||||
wi >>= 1;
|
||||
}
|
||||
for(i=m; i<n; i+=istep)
|
||||
{
|
||||
j = i + l;
|
||||
FFT_twiddle(wr, wi, j, shift, inverse);
|
||||
|
||||
FFT_reg reg;
|
||||
fixed *reg_s = ((fixed*) ®);
|
||||
|
||||
for(i=m; i<n; i+=istep)
|
||||
{
|
||||
j = i + l;
|
||||
|
||||
reg_s[3] = fr[i];
|
||||
reg_s[2] = fr[j];
|
||||
reg_s[1] = fi[i];
|
||||
|
25
fft_inst.tie
25
fft_inst.tie
@ -132,6 +132,31 @@ table SIN_wave 16 1024 {
|
||||
|
||||
regfile FFT_reg 64 2 fftv
|
||||
|
||||
operation FFT_bit_reverse {in AR b, out AR o, in AR m} {}
|
||||
{
|
||||
assign o = {
|
||||
TIEmux(m[2:0], 1'b0, 1'b0, 1'b0, 1'b0, 1'b0, 1'b0, 1'b0, b[0]),
|
||||
TIEmux(m[2:0], 1'b0, 1'b0, 1'b0, 1'b0, 1'b0, 1'b0, b[0], b[1]),
|
||||
TIEmux(m[2:0], 1'b0, 1'b0, 1'b0, 1'b0, 1'b0, b[0], b[1], b[2]),
|
||||
TIEmux(m[2:0], 1'b0, 1'b0, 1'b0, 1'b0, b[0], b[1], b[2], b[3]),
|
||||
TIEmux(m[2:0], 1'b0, 1'b0, 1'b0, b[0], b[1], b[2], b[3], b[4]),
|
||||
TIEmux(m[2:0], 1'b0, 1'b0, b[0], b[1], b[2], b[3], b[4], b[5]),
|
||||
TIEmux(m[2:0], 1'b0, b[0], b[1], b[2], b[3], b[4], b[5], b[6])
|
||||
};
|
||||
}
|
||||
|
||||
operation FFT_twiddle {out AR wr, out AR wi, in AR j, in BR shift, in BR inverse} {}
|
||||
{
|
||||
// 256 = N_WAVE / 4
|
||||
wire [9:0] idx = TIEadd(j, 256, 1'b0);
|
||||
wire [15:0] sin = SIN_wave[j];
|
||||
wire [15:0] wr1 = SIN_wave[idx];
|
||||
wire [15:0] wi1 = TIEadd(~sin, 16'b0, 1'b1);
|
||||
wire [15:0] wi2 = TIEmux(inverse, wi1, sin);
|
||||
assign wr = TIEmux(shift, wr1, {wr1[15], wr1[15:1]});
|
||||
assign wi = TIEmux(shift, wi2, {wi2[15], wi2[15:1]});
|
||||
}
|
||||
|
||||
operation FFT_calc {inout FFT_reg data, in AR wr, in AR wi, in AR shift} {}
|
||||
{
|
||||
wire [15:0] fri = data[63:48];
|
||||
|
Loading…
Reference in New Issue
Block a user