Inneren Schleifenheader und Scaling als TIE Instruktionen implementiert
This commit is contained in:
parent
0c0c708e70
commit
f8cfb71c62
29
fft.c
29
fft.c
@ -61,6 +61,7 @@ int fix_fft(fixed fr[], fixed fi[], int m, int inverse)
|
||||
scale = 0;
|
||||
|
||||
int mm = m;
|
||||
xtbool t;
|
||||
|
||||
/* decimation in time - re-order data */
|
||||
for(m=1; m<=nn; ++m) {
|
||||
@ -87,19 +88,14 @@ int fix_fft(fixed fr[], fixed fi[], int m, int inverse)
|
||||
shift = 0;
|
||||
for(i=0; i<n; ++i)
|
||||
{
|
||||
j = fr[i];
|
||||
if(j < 0) j = -j;
|
||||
|
||||
m = fi[i];
|
||||
if(m < 0) m = -m;
|
||||
|
||||
if(j > 16383 || m > 16383)
|
||||
{
|
||||
shift = 1;
|
||||
break;
|
||||
}
|
||||
xtbool sshift;
|
||||
FFT_scale(fr[i], fi[i], sshift, scale);
|
||||
if(sshift)
|
||||
{
|
||||
shift = (int) sshift;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(shift) ++scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -122,9 +118,14 @@ int fix_fft(fixed fr[], fixed fi[], int m, int inverse)
|
||||
FFT_reg reg;
|
||||
fixed *reg_s = ((fixed*) ®);
|
||||
|
||||
for(i=m; i<n; i+=istep)
|
||||
WUR_FFT_loop(m);
|
||||
while(1)
|
||||
{
|
||||
j = i + l;
|
||||
i = RUR_FFT_loop();
|
||||
|
||||
FFT_loop_check(n, istep, t, j);
|
||||
if(!t)
|
||||
break;
|
||||
|
||||
reg_s[3] = fr[i];
|
||||
reg_s[2] = fr[j];
|
||||
|
24
fft_inst.tie
24
fft_inst.tie
@ -132,6 +132,30 @@ table SIN_wave 16 1024 {
|
||||
|
||||
regfile FFT_reg 64 2 fftv
|
||||
|
||||
state FFT_loop 32 add_read_write
|
||||
|
||||
operation FFT_scale {in AR fr, in AR fi, out BR shift, inout AR scale} {}
|
||||
{
|
||||
wire [4:0] jc1 = TIEcmp(fr[15:0], 16'd16383, 1'b1);
|
||||
wire [4:0] mc1 = TIEcmp(fi[15:0], 16'd16383, 1'b1);
|
||||
wire [4:0] jc2 = TIEcmp(fr[15:0], 16'd49153, 1'b1);
|
||||
wire [4:0] mc2 = TIEcmp(fi[15:0], 16'd49153, 1'b1);
|
||||
|
||||
wire x = jc1[0] | mc1[0] | jc2[4] | mc2[4];
|
||||
assign shift = x;
|
||||
|
||||
wire [15:0] scaleInc = TIEadd(scale, 16'b0, 1'b1);
|
||||
assign scale = TIEmux(x, scale, scaleInc);
|
||||
}
|
||||
|
||||
operation FFT_loop_check {in AR n, in AR istep, out BR t, out AR j} {inout FFT_loop}
|
||||
{
|
||||
wire [4:0] cmpres = TIEcmp(FFT_loop, n, 1'b0);
|
||||
assign t = cmpres[4];
|
||||
assign FFT_loop = TIEadd(FFT_loop, istep, 1'b0);
|
||||
assign j = TIEadd(FFT_loop, {1'b0, istep[15:1]}, 1'b0);
|
||||
}
|
||||
|
||||
operation FFT_bit_reverse {in AR b, out AR o, in AR m} {}
|
||||
{
|
||||
assign o = {
|
||||
|
Loading…
Reference in New Issue
Block a user