User guide

System Generator for DSP User Guide www.xilinx.com 55
UG640 (v 12.2) July 23, 2010
Compiling MATLAB into an FPGA
M-functions using Xilinx data types and functions can be tested in the MATLAB command
window. For example, if you type: [z1, z2, z3, z4] = xlSimpleArith(2, 3) in
the MATLAB command window, you'll get the following lines:
UFix(9, 3): 3.500000
Fix(12, 4): -8.687500
Fix(12, 8): 7.996094
Bool: true
Notice that the two integer arguments (2 and 3) are converted to fixed-point numbers
automatically. If you have a floating-point number as an argument, an xfix call is
required.
Complex Multiplier with Latency
This example shows how to create a complex number multiplier. The following shows the
xlcpxmult.m file which specifies the xlcpxmult function.
function [xr, xi] = xlcpxmult(ar, ai, br, bi)
xr = ar * br - ai * bi;
xi = ar * bi + ai * br;
The following diagram shows the sub-system:
Two delay blocks are added after the MCode block. By selecting the option Implement
using behavioral HDL on the Delay blocks, the downstream logic synthesis tool is able to
perform the appropriate optimizations to achieve higher performance.