We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for
Did you mean:
Observer
970 Views
Registered: ‎09-13-2017

## fft Bit reverse order

Hi,

My results from xilinx fft core 9.1 does not match with datasheet in bit reverse configuration.

Data sheet PG109 page 40 explains bit reversed order for piplined architecture of core. It says

```In the Radix-2 Burst I/O, Radix-2 Lite Burst I/O, and Pipelined Streaming I/O architectures,
the Bit Reverse order is simple to calculate by taking the index of the data point, written in
binary, and reversing the order of the digits. Hence, 0000, 0001, 0010, 0011, 0100,...(0, 1, 2,
3, 4,...) becomes 0000, 1000, 0100, 1100, 0010,...(0, 8, 4, 12, 2,...).```

I simulated fft core with xilinx dds as input of the core. It shows correct output. All other indices seem to be reveresed order expect the index at which we get maximum magnitude of (X_re, X_img).

For example, My system clock is 100MHz anf fft size (N) is 16384. My dds outputs 2.56 MHz that becomes input of fft. So i should a hike in magnitude of output of fft at index

index = frequency_in/bin_size  = 2560000/(100M/16384) = 419.43

My simulation shows 420(110100100) index in natural order and same 420(110100100) in reveresed order.

Why is it same, shouldn't it be (001001011)? I checked this at other frequencies too but this snario doesn't change.

I have attached simulation snap, project tcl and block diagram snap.

1 Solution

Accepted Solutions
Moderator
495 Views
Registered: ‎08-16-2018

## Re: fft Bit reverse order

I'm expecting b0010_0101_1000_00 ( 2400), but getting 420 (b00_0001_1010_0100) I have created the project again using you tcl script and changes the fft to reverse order instead natural.

Index will be 420 for both the case, but location of 420 will be at 420 and 2400 for natural and bit-reverse order respectively.

Suppose, peak is at location 4 in natural order case i.e.  [0, 1, 2, 3, 4 (peak here), 5, 6, 7]

Then, in reverse order the peak will be at location 2, but with index 4  i.e. [0, 4 (peak here), 2, 6, 1, 5, 3, 7].

In matlab, if we plot the signal where t_valid = 1 ( and without providing the x-axis), then it's shows the bin number. But in Vivado, we don't have this option (but we can see that index are not in sequence).

/ 7\7     Meher Krishna Patel, PhD
\ \        Senior Product Application Engineer, Xilinx
/ /
\_\/\7   It is not so much that you are within the cosmos as that the cosmos is within you...
10 Replies
Xilinx Employee
807 Views
Registered: ‎09-18-2018

## Re: fft Bit reverse order

Hi @atharbaig ,

As per the calculation, the frequncy of the signal is represented in 420th sample.

From the question, it appears as though the bit-reversal is confused with index reversal.

The peak will appear at sample with index value of "420(110100100)" as per your calculation.

The bit reversal mode only the output sample sequence is changed i.e instead of sample no.s 1,2,3... coming out of core, sample numbers 0,8,4,12 .. so on.

To know the exact sample sequences, simply reverse the binary values of normal sequence. Please refer the XK_Index port for more information in understanding this.

Observer
727 Views
Registered: ‎09-13-2017

## Re: fft Bit reverse order

@vkanchan wrote:

The bit reversal mode only the output sample sequence is changed i.e instead of sample no.s 1,2,3... coming out of core, sample numbers 0,8,4,12 .. so on.

But isn't the sample number and index are the same? like sample 1 has index 1?

Moderator
717 Views
Registered: ‎08-16-2018

## Re: fft Bit reverse order

Sample number and index are same for the "Natural order output". In the case of "reversed output", the index number will be in reverse order e.g. for sample b'001, index value will be b'100.

I checked the simulation outputs, it is same for both reverse and natural order  as shown below. We are debugging it further and inform you about the issue,

/ 7\7     Meher Krishna Patel, PhD
\ \        Senior Product Application Engineer, Xilinx
/ /
\_\/\7   It is not so much that you are within the cosmos as that the cosmos is within you...
Observer
683 Views
Registered: ‎09-13-2017

## Re: fft Bit reverse order

@meherp wrote

checked the simulation outputs, it is same for both reverse and natural order  as shown below.

Yes this is exactly what i got. Looking forward.

Thank you

Moderator
613 Views
Registered: ‎08-16-2018

## Re: fft Bit reverse order

Sample number and index are same for the "Natural order output". In the case of "reversed output", the index number will be in reverse order e.g. index at sample 0 will be b'000 for both the case, but index at sample 1 will be b'001 and b'100 respectively. Therefore peak will appear at index 420 for both the cases but the location will be different.

For natural order case, the peak location will be 420 (b00_0001_1010_0100)only; but for reverse order the location "b00000110100100 (420)" will apprear according to reversed bit format i.e. b0010_0101_1000_00 ( 2400). Note that index size is 0:(NFFT-1) (i.e. 0:13 in this case).

I verified it for the settings which is used in this forum question. Below are the results,

Also, the peaks are at the correct index for both the cases.

Result for natural order

Result for bit-reverse order

In the above result, the System-Generator's index sequece for bit-reverse case is matching with Vivado's results.

Issue is with natural order. We are getting the correct sequence in the System Generator. But, in the Vivado design, result is incorrect (which is same as the bit-reverse order).

System-generator designs are attached for both the cases (see SysGen_FFT.zip). Project is created using Vivado 2018.3 and Matlab R2018a

/ 7\7     Meher Krishna Patel, PhD
\ \        Senior Product Application Engineer, Xilinx
/ /
\_\/\7   It is not so much that you are within the cosmos as that the cosmos is within you...
Moderator
592 Views
Registered: ‎08-16-2018

## Re: fft Bit reverse order

Since, SysGen was showning the correct results, therefore I rerun the script again and it is showing the correct results.

Previous, I run the project for bit-reversed case first, and then modify the IP for 'natural order' case. May be something went wrong there. This time, I created the project and set the IP to 'natural order' first and run the simulation. It is working fine.

Below are the steps which are used to generate the correct result. Please check if it's working at your end as well or not.

1. TCL SCRIPT (start vivado in tcl mode i.e. 'vivado -mode tcl' and paste the code in attached fft_sim.tcl file; then open the project using 'start_gui' command)

2. Select 'natural order' for FFT IP

3. Add the below test bench

````timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 09/03/2019 04:07:13 PM
// Design Name:
// Module Name: tb_fft
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
//
//////////////////////////////////////////////////////////////////////////////////

module tb_fft(

);

//    module design_1_wrapper
//   (aclk_100M,
//    m_axis_data_tuser_0,
//    m_axis_data_tvalid_0,
//    sum);
reg aclk_100M;
wire [15:0]m_axis_data_tuser_0;
wire m_axis_data_tvalid_0;
wire [15:0]sum;

design_1_wrapper uut(.aclk_100M(aclk_100M),
.m_axis_data_tuser_0(m_axis_data_tuser_0),
.m_axis_data_tvalid_0(m_axis_data_tvalid_0),
.sum(sum));

parameter period=10;

always begin
aclk_100M=0;
#(period/2) aclk_100M=1;
#(period/2);

end

endmodule
```

4. Run simulation to get the below result,

/ 7\7     Meher Krishna Patel, PhD
\ \        Senior Product Application Engineer, Xilinx
/ /
\_\/\7   It is not so much that you are within the cosmos as that the cosmos is within you...
Observer
505 Views
Registered: ‎09-13-2017

## Re: fft Bit reverse order

@meherp wrote:

Since, SysGen was showning the correct results, therefore I rerun the script again and it is showing the correct results.

Previous, I run the project for bit-reversed case first, and then modify the IP for 'natural order' case. May be something went wrong there. This time, I created the project and set the IP to 'natural order' first and run the simulation. It is working fine.

Actually my case is opposite. I'm getting expected results in natural order but bit reverse order i'm not getting the reversed indices like you explained in sysGen section above.

"For natural order case, the peak location will be 420 (b00_0001_1010_0100)only; but for reverse order the location "b00000110100100 (420)" will apprear according to reversed bit format i.e. b0010_0101_1000_00 ( 2400). Note that index size is 0:(NFFT-1) (i.e. 0:13 in this case). "

I'm expecting b0010_0101_1000_00 ( 2400), but getting 420 (b00_0001_1010_0100) I have created the project again using you tcl script and changes the fft to reverse order instead natural.

Moderator
496 Views
Registered: ‎08-16-2018

## Re: fft Bit reverse order

I'm expecting b0010_0101_1000_00 ( 2400), but getting 420 (b00_0001_1010_0100) I have created the project again using you tcl script and changes the fft to reverse order instead natural.

Index will be 420 for both the case, but location of 420 will be at 420 and 2400 for natural and bit-reverse order respectively.

Suppose, peak is at location 4 in natural order case i.e.  [0, 1, 2, 3, 4 (peak here), 5, 6, 7]

Then, in reverse order the peak will be at location 2, but with index 4  i.e. [0, 4 (peak here), 2, 6, 1, 5, 3, 7].

In matlab, if we plot the signal where t_valid = 1 ( and without providing the x-axis), then it's shows the bin number. But in Vivado, we don't have this option (but we can see that index are not in sequence).

/ 7\7     Meher Krishna Patel, PhD
\ \        Senior Product Application Engineer, Xilinx
/ /
\_\/\7   It is not so much that you are within the cosmos as that the cosmos is within you...
Observer
487 Views
Registered: ‎09-13-2017

## Re: fft Bit reverse order

Thank you very much.

Ok. It means if i want to find the frequency using bin number, My calculations will remain the same for both natural and bit reversed order. Like in this case my bin number is 420 which corresponds to my input frequency. If i detect a peak at certain bin (420)(b00_0001_1010_0100), I will not have to reverse the bits of index to get my required index. Just the position of this index will be changes. I'll either get this index earlier or later than the natural order, in index output sequence. Is my understanding correct?

Moderator
468 Views
Registered: ‎08-16-2018