absolutwert im shift_check berechnen

This commit is contained in:
Jörg Thalheim 2015-03-07 10:24:58 +01:00
parent 5b5ee5fdf0
commit 24124a832a
2 changed files with 12 additions and 7 deletions

3
fft.c
View File

@ -90,10 +90,7 @@ int fix_fft(fixed fr[], fixed fi[], int m, int inverse)
for(i=0; i<n; ++i) for(i=0; i<n; ++i)
{ {
j = fr[i]; j = fr[i];
if(j < 0) j = -j;
m = fi[i]; m = fi[i];
if(m < 0) m = -m;
if(FFT_shift_check(j,m)) if(FFT_shift_check(j,m))
{ {

View File

@ -134,12 +134,20 @@ regfile FFT_reg 64 2 fftv
state FFT_loop 32 add_read_write state FFT_loop 32 add_read_write
operation FFT_shift_check {in AR fr, in AR fi, out BR cmp} {}
{
wire [4:0] jc1 = TIEcmp(fr[15:0], 16'd16383, 1'b0);
wire [4:0] jc2 = TIEcmp(fi[15:0], 16'd16383, 1'b0);
assign cmp = jc1[0] | jc2[0]; operation FFT_shift_check {in AR fr, in AR fi, out BR needs_shift} {}
{
// fr > 0
wire [4:0] jc1 = TIEcmp(fr[15:0], 16'd16383, 1'b1);
// fi > 0
wire [4:0] jc2 = TIEcmp(fi[15:0], 16'd16383, 1'b1);
// fr < 0
wire [4:0] jc3 = TIEcmp(fr[15:0], 16'd49153, 1'b1);
// fi < 0
wire [4:0] jc4 = TIEcmp(fi[15:0], 16'd49153, 1'b1);
assign needs_shift = jc1[0] | jc2[0] | jc3[4] | jc4[4];
} }
operation FFT_loop_check {in AR n, in AR istep, out BR t, out AR j} {inout FFT_loop} operation FFT_loop_check {in AR n, in AR istep, out BR t, out AR j} {inout FFT_loop}