Saturday, November 28, 2009

IFFT in System Generator

The FFT block in Xilinx Blockset can be used to calculate both DFT and IDFT because the two equations are almost identical:

By default, the FFT block is configured to calculate DFT. The setup and timing of control/data signals for IDFT are the same as DFT except for two things:
  1. The FFT block needs to be set up for IDFT by setting fwd_inv_we signal to 1 and fwd_inv signal to 0 before the start of the transform 
  2. The FFT output needs to be manually scaled to account for the factor 1/N in Equation 2 above. The scaling can be done either by using the scaling schedule input or shifting the FFT output if the FFT block is set to "unscaled".
The picture below shows the timing of control/data signals at the beginning of a data frame.
Now let's use a simple 8-point IDFT example to show how everything is put together. Below is the IDFT calculation of a test vector xn_re in Matlab:
>>xn_re=[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8];
ans =
Columns 1 through 5
0.4500  -0.0500-0.1207i  -0.0500-0.0500i  -0.0500-0.0207i 0.0500          

Columns 6 through 8
-0.0500+0.0207i  -0.0500+0.0500i  -0.0500+0.1207i

The idft_test simulink/sysgen model for the 8-point can be downloaded here. The model includes a block called WaveScope, which is a "hidden" gem in System Generator for debugging SysGen designs, especially for hardware engineers who are used to viewing waveforms in HDL simulators.

The picture below shows the waveform at the beginning of the simulation in Wavescope. fwd_inv_we=1 and fwd_inv=0 for 1 cycle to set up the block for IDFT. Also the scale_sch is set to "010101" at the beginning to scale the FFT result down by 8 (the 1/N factor in Equation 2).

The picture below shows the waveform in Wavescope at the end of simulation, which shows that the xk_re and xk_im outputs when dv=1 match the Matlab results above when taking the quantization errors into account.

Tuesday, November 24, 2009

Really impressed with 7-Zip

Update Aug 20, 2011:  Just found out that 7-Zip can also extract CD/DVD image files (.iso). Nice! Below are all the file formats it supports:
  • Packing / unpacking: 7z, XZ, BZIP2, GZIP, TAR, ZIP and WIM
  • Unpacking only: ARJ, CAB, CHM, CPIO, CramFS, DEB, DMG, FAT, HFS, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, RAR, RPM, SquashFS, UDF, VHD, WIM, XAR and Z.
I have been using Winzip to compress files for as long as I can remember. One of my colleagues mentioned another compression tool called 7-Zip to me a couple of weeks ago and I am really impressed with the high compression ratio achieved by 7-Zip. Besides it's free and supports all compression file formats (.zip, .rar, .gz, .7z) that I know of. Below is a chart that compares the compressed file sizes between Winzip 10 and 7-Zip 4.65 on several files that I use for my daily work:

FileUncompressed .zip.7z%smaller
Virtex-6 UG365
5.4MB 4MB 26%
ADEPT 0.38.6 12.6MB5.3MB4.4MB17%
SP601 Base Reference Design rdf0003 56.3MB17.5MB10MB43%