DSP
DSP
If you confirm that the file is coming from a trusted source, you can send the following SHA-256
hash value to your admin for the original file.
283b7839ab8bd4fbb3e4f2a32de54125b20d8c1bb4efa8ecef2bb5b50df7dd9e
R
DSP PRODUCTS: ADVANCED DESIGN GUIDE EDITION 1.0
Xilinx • i
DSP: DESIGNING FOR OPTIMAL RESULTS
© 2005 Xilinx, Inc. All rights reserved. XILINX, the Xilinx Logo, and other designated brands included herein are trademarks
of Xilinx, Inc. PowerPC is a trademark of IBM, Inc. All other trademarks are the property of their respective owners.
NOTICE OF DISCLAIMER: The information stated in this book is not to be used for design purposes. Xilinx is
providing this design, code, or information "as is." By providing the design, code, or information as one possible
implementation of this feature, application, or standard, Xilinx makes no representation that this implementation is free
from any claims of infringement. You are responsible for obtaining any rights you may require for your implementation.
Xilinx expressly disclaims any warranty whatsoever with respect to the adequacy of the implementation, including but
not limited to any warranties or representations that this implementation is free from claims of infringement and any
implied warranties of merchantability or fitness for a particular purpose.
All terms mentioned in this book are known to be trademarks or service marks and are the property of their respective owners.
Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.
All rights reserved. No part of this book may be reproduced, in any form or by any means, without written permission from the
publisher.
Edition 1.0
March 2005
ii • Xilinx
Acknowledgements
Chapter 2 through Appendix A have been sourced from the Xilinx Advanced Product Division’s
(APD) "XtremeDSP Design Considerations User Guide". For up-to-date information, download the
online version located here:
http://www.xilinx.com/bvdocs/userguides/ug073.pdf
For more information, contact:
Gregg C. Hawkes
Senior Staff Applications Manager, Xilinx, Inc.
Xilinx • iii
DSP: DESIGNING FOR OPTIMAL RESULTS
iv • Xilinx
TABLE OF CONTENTS
Xilinx • v
DSP: DESIGNING FOR OPTIMAL RESULTS
Xilinx • vii
DSP: DESIGNING FOR OPTIMAL RESULTS
viii • Xilinx
Chapter 1
Our insatiable hunger for electronic gadgets that provide high-quality audio, video, data or all three,
is spiraling up the processing power that is needed to process these signals. Digital signal processing
(DSP) systems, within both infrastructure and customer premise equipment must provide increasing
levels of performance and flexibility to handle the new requirements yet provide greater scalability for
achieving higher economies of scale.
4G
Performance
SDR
(Algorithm and Processor Forecast)
Gap 3G Imaging
Radar
ity
lex
mp
Performance
Co SD/HD Video
DSP/GPP*
thm
ori
Alg
Traditional
Processor
Architectures
Field Programmable Gate Arrays (FPGAs) are very well suited to fill the performance gap for a
variety of reasons:
• They offer extremely high-performance signal processing capability through parallelism.
• They provide very low risk due to the flexible architecture.
• They allow design migration to handle changing standards.
• Developers can use them to create a customized and differentiated solution.
• They are quickly coming down in price. In fact, it is possible to find FPGAs for less then $2
per device.
• They provide very low power per function.
2 • Xilinx
DIGITAL SIGNAL PROCESSING DESIGN CHALLENGES
Easy to Use
Xilinx and its partners provide the easiest-to-use design solutions for FPGA-based DSP solutions with
features such as:
• System Generator for DSP reduces design time.
• A rich DSP IP library implements fast, highly optimized algorithms.
• Award-winning technical support and DSP services enable you to bring products to market
much faster.
Whether you are working with spread-spectrum, multi-carrier, or narrowband communication
systems, Virtex-4 FPGAs are the ideal choice for ease of use.
A Must-Read
This book is a must-read for DSP designers who want to tap the power of the Virtex-4 XtremeDSP
Slice. It provides a detailed description of the multiple features of the slice as well as providing
multiple examples that show you how to harness the power and flexibility of this powerful IP block.
Tap into the XtremeDSP Slice and reap the rewards of highest performance, lowest power at the lowest
cost.
Xilinx • 3
DSP: DESIGNING FOR OPTIMAL RESULTS
4 • Xilinx
Chapter 2
This chapter provides technical details for the XtremeDSP™ Digital Signal Processing (DSP)
element, the DSP48 slice.
The DSP48 slice is a new element in the Xilinx development model referred to as “Application
Specific Modular Blocks” (ASMBL). The purpose of this model is to deliver off-the-shelf
programmable devices with the best mix of logic, memory, I/O, processors, clock management, and
digital signal processing. ASMBL is an efficient FPGA development model for delivering off-the-
shelf, flexible solutions ideally suited to different application domains.
Each XtremeDSP tile contains two DSP48 slices to form the basis of a versatile coarse-grain DSP
architecture. Many DSP designs follow a multiply with addition. In Virtex™-4 devices these elements
are supported in dedicated circuits.
The DSP48 slices support many independent functions, including multiplier, multiplier-
accumulator (MAC), multiplier followed by an adder, three-input adder, barrel shifter, wide bus
multiplexers, magnitude comparator, or wide counter. The architecture also supports connecting
multiple DSP48 slices to form wide math functions, DSP filters, and complex arithmetic without the
use of general FPGA fabric.
The DSP48 slices available in all Virtex-4 family members support new DSP algorithms and
higher levels of DSP integration than previously available in FPGAs. Minimal use of general FPGA
fabric leads to low power, very high performance, and efficient silicon utilization.
Introduction
The DSP48 slices facilitate higher levels of DSP integration than previously possible in FPGAs. Many
DSP algorithms are supported with minimal use of the general-purpose FPGA fabric, resulting in low
power, high performance, and efficient device utilization.
At first look, the DSP48 slice is an 18 x 18 bit two’s complement multiplier followed by a 48-bit
sign-extended adder/subtracter/accumulator, a function that is widely used in digital signal processing
(DSP).
A second look reveals many subtle features that enhance the usefulness, versatility, and speed of
this arithmetic building block.
Programmable pipelining of input operands, intermediate products, and accumulator outputs
enhances throughput. The 48-bit internal bus allows for practically unlimited aggregation of DSP
slices.
Xilinx • 5
DSP: DESIGNING FOR OPTIMAL RESULTS
One of the most important features is the ability to cascade a result from one XtremeDSP Slice to
the next without the use of general fabric routing. This path provides high-performance and low-
power post addition for many DSP filter functions of any tap length.
For multi-precision arithmetic this path supports a right-wire-shift. Thus a partial product from
one XtremeDSP Slice can be right-justified and added to the next partial product computed in an
adjacent such slice. Using this technique, the XtremeDSP Slices can be configured to support any size
operands.
Another key feature for filter composition is the ability to cascade an input stream from slice to
slice.
The C input port, allows the formation of many 3-input mathematical functions, such as 3-input
addition, 2-input multiplication with a single addition. One subset of this function is the very
valuable support of rounding a multiplication “away from zero”.
Architecture Highlights
The Virtex-4 DSP slices are organized as vertical DSP columns. Within the DSP column, two vertical
DSP slices are combined with extra logic and routing to form a DSP tile. The DSP tile is four CLBs
tall.
Each DSP48 slice has a two-input multiplier followed by multiplexers and a three-input
adder/subtracter. The multiplier accepts two 18-bit, two's complement operands producing a 36-bit,
two's complement result. The result is sign extended to 48 bits and can optionally be fed to the
adder/subtracter. The adder/subtracter accepts three 48-bit, two's complement operands, and produces
a 48-bit two's complement result.
Higher level DSP functions are supported by cascading individual DSP48 slices in a DSP48
column. One input (cascade B input bus) and the DSP48 slice output (cascade P output bus) provide
the cascade capability. For example, a Finite Impulse Response (FIR) filter design can use the
cascading input to arrange a series of input data samples and the cascading output to arrange a series
of partial output results. For details on this technique, refer to the section titled “Adder Cascade vs.
Adder Tree,” page 31.
Architecture highlights of the DSP48 slices are:
• 18-bit by 18-bit, two's-complement multiplier with a full-precision 36-bit result, sign
extended to 48 bits
• Three-input, flexible 48-bit adder/subtracter with optional registered accumulation feedback
• Dynamic user-controlled operating modes to adapt DSP48 slice functions from clock cycle to
clock cycle
• Cascading 18-bit B bus, supporting input sample propagation
• Cascading 48-bit P bus, supporting output propagation of partial results
• Multi-precision multiplier and arithmetic support with 17-bit operand right shift to align
wide multiplier partial products (parallel or sequential multiplication)
• Symmetric intelligent rounding support for greater computational accuracy
• Performance enhancing pipeline options for control and data signals are selectable by
configuration bits
• Input port “C” typically used for multiply-add operation, large three-operand addition, or
flexible rounding mode
• Separate reset and clock enable for control and data registers
6 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
• I/O registers, ensuring maximum clock performance and highest possible sample rates with
no area cost
• OPMODE multiplexers
A number of software tools support the DSP48 slice. The Xilinx ISE software supports DSP48
slice instantiations. The Architecture Wizard is a GUI for creating instantiation VHDL and/or Verilog
code. It also helps generate code for designs using a single DSP48 slice (i.e., Multiplier, Adder,
Multiply-Accumulate or MAC, and Dynamic Control modes). Using the Architecture Wizard, CORE
Generator™ tool, or System Generator, a designer can quickly generate math or other functions using
Virtex-4 DSP48 slices.
Xilinx • 7
DSP: DESIGNING FOR OPTIMAL RESULTS
A[17:0] BCOUT[17:0]
18 18
B[17:0] PCOUT[47:0]
18 48
C[47:0] P[47:0]
48 48
OPMODE[6:0]
7
SUBTRACT
CARRYIN
CARRYINSEL[1:0]
2
CEA
CEB
CEC
CEM
CEP
CECTRL
CECINSUB
CECARRYIN
RSTA
RSTB
RSTC
RSTM
RSTP
RSTCTRL
RSTCARRYIN
CLK
BCIN[17:0]
18
PCIN[47:0]
48
ug073_c1_01_060304
8 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
Xilinx • 9
DSP: DESIGNING FOR OPTIMAL RESULTS
10 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
Attributes in VHDL
DSP48 generic map (
AREG => 1,-- Number of pipeline registers on the A input, 0, 1 or 2
BREG => 1,-- Number of pipeline registers on the B input, 0, 1 or 2
B_INPUT => “DIRECT”, -- B input DIRECT from fabric or CASCADE from
-- another DSP48
CARRYINREG => 1, -- Number of pipeline registers for the CARRYIN
-- input, 0 or 1
CARRYINSELREG => 1, -- Number of pipeline registers for the
-- CARRYINSEL, 0 or 1
CREG => 1, -- Number of pipeline registers on the C input, 0 or 1
LEGACY_MODE => “MULT18X18S”, -- Backward compatibility, NONE,
-- MULT18X18 or MULT18X18S
MREG => 1, -- Number of multiplier pipeline registers, 0 or 1
OPMODEREG => 1,-- Number of pipeline registers on OPMODE input,
-- 0 or 1
PREG => 1, -- Number of pipeline registers on the P output, 0 or 1
SIM_X_INPUT => “GENERATE_X_ONLY”,
-- Simulation parameter for behavior for X on input.
-- Possible values: GENERATE_X, NONE or WARNING
SUBTRACTREG => 1)-- Number of pipeline registers on the SUBTRACT
-- input, 0 or 1
Attributes in Verilog
defparam DSP48_inst.AREG = 1;
// Number of pipeline registers on the A input, 0, 1 or 2
defparam DSP48_inst.BREG = 1;
// Number of pipeline registers on the B input, 0, 1 or 2
defparam DSP48_inst.B_INPUT = “DIRECT”;
// B input DIRECT from fabric or CASCADE from another DSP48
defparam DSP48_inst.CARRYINREG = 1;
// Number of pipeline registers for the CARRYIN input, 0 or 1
defparam DSP48_inst.CARRYINSELREG = 1;
// Number of pipeline registers for the CARRYINSEL, 0 or 1
defparam DSP48_inst.CREG = 1;
// Number of pipeline registers on the C input, 0 or 1
defparam DSP48_inst.LEGACY_MODE = “MULT18X18S”;
// Backward compatibility, NONE, MULT18X18 or MULT18X18S
defparam DSP48_inst.MREG = 1;
// Number of multiplier pipeline registers, 0 or 1
defparam DSP48_inst.OPMODEREG = 1;
// Number of pipeline registers on OPMODE input, 0 or 1
defparam DSP48_inst.PREG = 1;
// Number of pipeline registers on the P output, 0 or 1
defparam DSP48_inst.SIM_X_INPUT = “GENERATE_X_ONLY”;
// Simulation parameter for behavior for X on input.
// Possible values: GENERATE_X, NONE or WARNING
defparam DSP48_inst.SUBTRACTREG = 1;
// Number of pipeline registers on the SUBTRACT input, 0 or 1
Xilinx • 11
DSP: DESIGNING FOR OPTIMAL RESULTS
Multiplier BRAM
Virtex-4 Devices
Interconnect
Interconnect
DSP48 DSP48
BRAM
Slice Slice
ug073_c1_02_060304
12 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
BCOUT PCOUT
18 Note 4
Note 1
36
18
X
48
A 18 48 48
18 36
×
CIN
Note 2
B 72
18
Note 3 36 Y
48
± P
48
SUBTRACT
48 Note 8
C Zero
48
Z
48
Note 7
48 18 Notes 4, 5
48
Note 5 48
BCIN Wire Shift Right by 17 bits PCIN
BCOUT PCOUT
Note 4
18 Note 1
36
18
X
18 48
A 48 48
36
×
18 CIN
Note 2
B 72
18
Note 3 36 Y ± P
48
48
SUBTRACT
48 Note 8
Zero
Z
48
18
Notes 4, 5
48
Note 5 48
BCIN Wire Shift Right by 17 bits PCIN
ug073_c1_03_020405
Xilinx • 13
DSP: DESIGNING FOR OPTIMAL RESULTS
P
A:B X
A
×
B
Y ± P
C
Zero
PCIN Z OPMODE, CARRYINSEL, CIN,
and SUBTRACT Control Behavior
P
UG073_c1_04_070904
Timing Model
Table 2-3 lists the XtremeDSP switching characteristics.
Xilinx • 15
DSP: DESIGNING FOR OPTIMAL RESULTS
16 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
The timing diagram in Figure 2-5 uses OPMODE equal to 0x05 with all pipeline registers
turned on. For other applications, the clock latencies and the parameter names must be adjusted.
CLK
TDSPCCK_CE
CE
TDSPCCK_RST
RST
TDSPDCK_AA
TDSPDCK_BB
TDSPDCK_CC
TDSPCKO_CC TDSPCKO_CC
UG073_c1_27_071204
Xilinx • 17
DSP: DESIGNING FOR OPTIMAL RESULTS
4. At time TDSPCCK_RST before CLK event 5, the RST signal becomes valid High to allow a
synchronous reset at CLK event 5.
5. At time TDSPCKO_PP after CLK event 5, the output P becomes a logic 0.
18 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
The A, B, C, and P port logics are shown in Figure 2-6, Figure 2-7, Figure 2-8, and Figure 2-9,
respectively.
A
18 18
A input to
18 18 Multiplier
D Q D Q
18
EN EN
RST RST
CEA
RSTA UG073_c1_05_061304
B
18
18
BCIN
18 B input to
18 18 Multiplier
D Q D Q
18
EN EN
RST RST
CEB
UG073_c1_06_061304
RSTB
C
48
To Both DSP48 Slices
48
D Q
48
CLK_0 CEC EN
RST
CLK_1
RSTC UG073_c1_07_061304
Xilinx • 19
DSP: DESIGNING FOR OPTIMAL RESULTS
P
48
DSP48 Slice Output
48
D Q
48
CEP EN
RST
RSTP UG073_c1_08_061304
OPMODE
7 To the X, Y, Z Multiplexers and
7 Carry Input Select Logic
D Q
CECTRL EN
RST
RSTCTRL
SUBTRACT
To Adder/Subtracter
D Q
CECINSUB EN
RST
CARRYINSEL
2
To Carry Input Select Logic
2
D Q
EN
RST
ug073_c1_09_070904
20 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
Partial Product 1
A 36
×
B 72
Partial Product 2
36
Optional
MREG ug073_c1_10_070904
X, Y, and Z Multiplexer
The Operating Mode (OPMODE) inputs provide a way for the design to change its functionality from
clock cycle to clock cycle (e.g., when altering the initial or final state of the DSP48 relative to the
middle part of a given calculation). The OPMODE bits can be optionally registered under the control
of the configuration memory cells (as denoted by the grey colored MUX symbol in Figure 2-10).
Table 2-4, Table 2-5, and Table 2-6 list the possible values of OPMODE and the resulting
function at the outputs of the three multiplexers (X, Y, and Z multiplexers). The multiplexer outputs
supply three operands to the following adder/subtracter. Not all possible combinations for the
multiplexer select bits are allowed. Some are marked in the tables as “illegal selection” and give
undefined results. If the multiplier output is selected, then both the X and Y multiplexers are
consumed supplying the multiplier output to the adder/subtracter.
Xilinx • 21
DSP: DESIGNING FOR OPTIMAL RESULTS
There are seven possible non-zero operands for the three-input adder as selected by the three
multiplexers, and the 36-bit operands are sign extended to 48 bits at the multiplexer outputs:
1. Multiplier output, supplied as two 36-bit partial products
2. Multiplier bypass bus consisting of A concatenated with B
3. C bus, 48 bits, shared by two slices
4. Cascaded P bus, 48 bits, from a neighbor DSP48 slice
5. Registered P bus output, 48 bits, for accumulator functions
6. Cascaded P bus, 48 bits, right shifted by 17 bits from a neighbor DSP48 slice
7. Registered P bus output, 48 bits, right shifted by 17 bits, for accumulator functions
Three-Input Adder/Subtracter
The adder/subtracter output is a function of control and data inputs. OPMODE, as shown in the
previous section, selects the inputs to the X, Y, Z multiplexer directed to the associated three
adder/subtracter inputs. It also describes how selecting the multiplier output consumes both X and Y
multiplexers.
As with the input multiplexers, the OPMODE bits specify a portion of this function. Table 2-7
shows OPMODE combinations and the resulting functions. The symbol ± in the table means either
add or subtract and is specified by the state of the SUBTRACT control signal (SUBTRACT = 1 is
defined as “subtraction”). The symbol : in the table means concatenation. The outputs of the X and Y
22 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
multiplexer and CIN are always added together. This result is then added to or subtracted from the
output of the Z multiplexer.
Xilinx • 23
DSP: DESIGNING FOR OPTIMAL RESULTS
Table 2-7: OPMODE Control Bits Adder/Subtracter Function (Continued)
Hex
Binary OPMODE XYZ Multiplexer Outputs and Adder/Subtracter Output
OPMODE
[6:0] Z Y X Z Y X Adder/Subtracter Output
0x53 101 00 11 Shift (PCIN) 0 A:B Shift(PCIN) ± (A:B + CIN)
0x55 101 01 01 Shift (PCIN) Note 1 Shift(PCIN) ± (A × B + CIN)
0x5c 101 11 00 Shift (PCIN) C 0 Shift(PCIN) ± (C + CIN)
0x5e 101 11 10 Shift (PCIN) C P Shift(PCIN) ± (C + P + CIN)
0x5f 101 11 11 Shift (PCIN) C A:B Shift(PCIN) ± (A:B + C + CIN)
0x60 110 00 00 Shift (P) 0 0 Shift(P) ± CIN
0x62 110 00 10 Shift (P) 0 PShift(P) ± (P + CIN)
0x63 110 00 11 Shift (P) 0 A:B Shift(P) ± (A:B + CIN)
0x65 110 01 01 Shift (P) Note 1 Shift(P) ± (A × B + CIN)
0x6c 110 11 00 Shift (P) C 0 Shift(P) ± (C + CIN)
0x6e 110 11 10 Shift (P) C P Shift(P) ± (C + P + CIN)
0x6f 110 11 11 Shift (P) C A:B Shift(P) ± (A:B + C + CIN)
Notes:
1. When the multiplier output is selected, both X and Y multiplexers are used to feed the multiplier partial
products to the adder input.
24 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
CARRYINSEL
2
CARRYIN
Carry input from general fabric
(to cause counter increment, etc.)
00
D Q
CECINSUB EN
OPMODE
RST
Round a previous ~P[47] RSTCARRYIN
P result
01
Round a previous ~PCIN[47] Carry Input (CIN) to
PCIN result Adder/Subtracter
OPMODE
10
Round an external ~A[17]
value input via A:B
Xilinx • 25
DSP: DESIGNING FOR OPTIMAL RESULTS
26 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
number of ones present in the C register. Table 2-9 has examples for rounding off the fractional bits
from a value (binary point placement and rounded bits placement coincide).
BL * AL = 34 bits
Sign Extend 36 bits of '0'
[33:17] [16:0]
Xilinx • 27
DSP: DESIGNING FOR OPTIMAL RESULTS
positive”. The “forced zero sign” bit in the least-significant part is why only 35-bit operands are found
instead of 36-bit operands.
The DSP48 slices, with 18 x 18 multipliers and post adder, can now be used to implement the
sum of the four partial products shown in Figure 2-13. The lessor significant partial products must be
right-shifted by 17 bit positions before being summed with the next most-significant partial
products. This is accomplished with a built in “wire shift” applied to PCIN supplied as one selectable
Z multiplexer input. The entire process of multiplication, shifting, and addition using adder cascade
to form the 70-bit result can remain in the dedicated silicon of the DSP48 slice, resulting in maximum
performance with minimal power consumption. Figure 2-21, page 41 illustrates the implementation
of a 35 x 35 multiplier using the DSP48 slices.
FIR Filters
28 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
h(0)
× h(1)
× h(2)
× h(3)
× h(4) × h(N-1)
×
y(n)
+ + + + +
UG073_c6_01_070904
In Figure 2-14, the sample delay logic is denoted by Z-1, whereas the –1 represents a single clock
delay. The delayed input samples are supplied to one input of the multiplier. The coefficients (denoted
by h0 to h(N-1)) are supplied to the other input of the multiplier through individual ROMs, RAMs,
registers, or constants. Y(n) is merely the summation of a set of input samples, and in time, multiplied
by their respective coefficients.
Xilinx • 29
DSP: DESIGNING FOR OPTIMAL RESULTS
x ( n ) = x ( n ) + jx Q ( n )
I
xl(n)
× M(z) I
v(n)
× xQ(n)
M(z) Q
DDS
Direct Digital Synthesizer UG073_c6_02_070904
30 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
h7(n)
18 × 48
+
18
48
h6(n)
18 × +
X(n-4)
18
Z-2
h5(n)
18 × 48
+
18
48
h4(n)
18 ×
X(n-2)
18
Z-2 + y(n-6)
h3(n)
18 × 48
+
18
h1(n)
18 × +
48
18
48
h0(n)
X(n)
18 ×
ug073_c1_13_070904
18
Xilinx • 31
DSP: DESIGNING FOR OPTIMAL RESULTS
performance and lowering power for DSP math is to remain inside the DSP48 column consisting
entirely of dedicated silicon.
The Virtex-4 solution accomplishes the post-addition process while guaranteeing no wasted
silicon resources. It involves computing the additive result incrementally utilizing a cascaded
approach as illustrated in Figure 2-17. Figure 2-17 is a systolic version of a direct form FIR with a
latency of 10 clocks versus an adder tree latency of six clocks.
32 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
Slice 8
h7(n-7)
18 × 48
+ 48
Y(n–10)
18
No wire shift
Slice 7 48
h6(n-6)
18 × 48
+
18
No wire shift
Slice 6 48
h5(n-5)
18 × 48
+
18
No wire shift
48
Slice 5
h4(n-4)
18 × 48
+
18
No wire shift The post adders are
contained wholly in
Slice 4 48
dedicated silicon for
h3(n-3) highest performance
18 × 48
+ and lowest power
18
No wire shift
Slice 3 48
h2(n-2)
18 × 48
+
18
No wire shift
Slice 2 48
h1(n-1)
18 × +
48
18
No wire shift
48
Slice 1
h0(n)
X(n)
18 × 48
+
18
Zero
Sign extended from 36 bits to 48 bits ug073_c1_14_070904
Xilinx • 33
DSP: DESIGNING FOR OPTIMAL RESULTS
34 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
Xilinx • 35
DSP: DESIGNING FOR OPTIMAL RESULTS
A[34:17]
18 × 48
+ P[52:17]
B[17:0] 48 48
18
36 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
product. The upper partial product is formed by multiplying the signed upper 18 bits of B with the
signed upper 18 bits of A.
A[34:17] x B[34:17]
The 70-bit result is output sequentially in 17-bit, 17-bit, and 36-bit segments as shown in
Figure 2-19.
Figure 2-19 shows the function during all four clock cycles for a single DSP48 slice used as a 35-
bit x 35-bit, signed, two's complement multiplier. Increased performance can be obtained by using
the pipeline registers before and after the multiplier, however, the clock latency is increased.
Clock Cycle 4 A[34:17] x B[34:17] P = right shifted PREG + (A[34:0] x B[34:17])
A[34:17]
18 × + P[69:34]
B[34:17] 48 48
18
0,A[16:0]
18 × + P[33:17]
B[34:17] 48 48
18
48
Clock Cycle 2 A[34:17] x 0,B[16:0] PREG = right shifted PREG + (A[34:17] x 0,B[16:0])
A[34:17]
18 × +
0,B[16:0] 48
18 48
0,A[16:0]
18 × + 48
P[16:0]
0,B[16:0] 48 48
18
Zero
Sign extended from 36 bits to 48 bits ug073_c1_16_071004
Xilinx • 37
DSP: DESIGNING FOR OPTIMAL RESULTS
38 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
Table 2-12 summarizes utilization of more complex digital filters possible using the DSP48. The
small “n” in the Silicon Utilization column indicates the number of DSP48 filter taps. The
construction and operation of complex filters is discussed in Chapter 4, “MAC FIR Filters,” Chapter 5,
“Parallel FIR Filters,” and Chapter 6, “Semi-Parallel FIR Filters.”
Xilinx • 39
DSP: DESIGNING FOR OPTIMAL RESULTS
A[34:17]
18 × + P[52:17]
48 48
18
PREG2 = right shifted PREG1+ (A[34:17] × B[17:0])
right “wire shift” by 17 bits
48
Slice 1
0,A[16:0] × B[17:0]
P[16:0]
48
0,A[16:0]
18 × +
B[17:0] 48 PREG1[16:0] = 0,A[16:0] × B[17:0]
18
Zero
Sign extended from 36 bits to 48 bits UG073_c1_17_071004
40 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
Slice 4
Z-3 A[34:17] × B[34:17]
A[34:17]
18 × + P[69:34]
48 48
18 PREG4 = right shifted PREG3 + (A[34:0] × B[34:17])
Slice 2 48
A[34:17] × 0,B[16:0]
A[34:17] 48
18 × +
48
18 PREG2 = right shifted PREG1 + (A[34:17] × 0,B[16:0])
48 Z-3
Slice 1
0,A[16:0] × 0,B[16:0]
P[16:0]
0,A[16:0] 48
18 × +
0,B[16:0] 48
18 PREG1 = 0,A[16:0] × 0,B[16:0]
Zero
Sign extended from 36 bits to 48 bits
ug073_c1_18_071004
Xilinx • 41
DSP: DESIGNING FOR OPTIMAL RESULTS
A_imag
18 × _ P_real
B_imag 48 48
18
Slice 3 48
A_real
18 × +
B_real 48
18
Slice 2
A_imag
18 × + 48
P_imag
B_real 48
18
Slice 1 48
A_real
18 × +
B_imag 48
18
Zero
Sign extended from 36 bits to 48 bits UG073_c1_19_071004
42 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
Last Cycle:
Slice 1 + Slice 2 = P_imaginary
Slice 3 – Slice 4 = P_real
During the last cycle, the input data must stall while the final terms are added. To avoid having
to stall the data, instead of using the complex multiply implementation shown in Figure 2-23 and
Figure 2-24, use the complex multiply implementation shown in Figure 2-25.
Slice 4
A_imag
18 × + P_real
B_imag 48
18
48
Slice 3
A_real
18 × 48 +
B_real
18
48
Slice 2
A_imag
18 × + P_imag
B_real 48
18
48
Slice 1
A_real
18 × +
B_imag 48
18
Xilinx • 43
DSP: DESIGNING FOR OPTIMAL RESULTS
In Figure 2-24, the N+1 cycle adds the accumulated products, and the input data stalls one cycle.
Slice 4 48
+ P_real
48
Slice 3 48
A_real
18 × +
B_real 48
18
Zero
48
Slice 2 P_imag
48
+
Slice 1 48
A_real
18 × +
B_imag 48
18
Zero
Sign extended from 36 bits to 48 bits ug073_c1_21_070904
44 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
An additional slice used for the accumulation is shown in Figure 2-25. The extra slice prevents
the input data from stalling on the last cycle. The capability of accumulating the P cascade through
the X mux feedback eliminates the pipeline stall.
Slice 6 + P_real
48
Slice 5 48
A_imag
18 × _
B_imag 48
18
Slice 4 48
A_real
18 × +
B_real 48
18
Zero
Sign extended from 36 bits to 48 bits
Slice 3
+ P_imag
48
Slice 2 48
A_imag
18 × +
B_real 48
18
Slice 1 48
A_real
18 × +
B_imag 48
18
Zero
Sign extended from 36 bits to 48 bits ug073_c1_22_070904
Xilinx • 45
DSP: DESIGNING FOR OPTIMAL RESULTS
48
A_real[34:17] × B_real[17:0]
Slice 3
A_real[34:17]
18 × +
48
18
PREG3 = right shifted PREG2 + (A_real[34:17] × B_real[17:0])
Right “wire shift” by 17 bits
48 Z –2
0,A_real[16:0] × B_real[17:0]
Slice 2 P[16:0]
48
0,A_real[16:0]
18 × +
B_real[17:0] 48
18 PREG2 = PREG1 + (0,A_real[16:0] × B_real[17:0])
48
0,A_imag[16:0] × B_imag[17:0]
Slice 1
0,A_imag[16:0]
18 × _
B_imag[17:0] 48
PREG1 = –(0,A_imag[16:0] × B_imag[17:0])
18
Zero
Sign extended from 36 bits to 48 bits ug073_c1_23_071004
46 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
Figure 2-27 shows the imaginary part of a fully pipelined, complex, 35-bit x 18-bit multiplier.
Z –3 A_imag[34:17] × B_real[17:0]
Slice 4
A_imag[34:17]
18 × + 48
P[52:17]
B_real[17:0] 48
18 PREG4 = PREG3 + (A_imag[34:17] × B_real[17:0])
Z –3
48
A_real[34:17] × B_imag[17:0]
Slice 3
A_real[34:17]
18 × +
48
48 Z –2
0,A_real[16:0] × B_imag[17:0]
Slice 2 P[16:0]
48
0,A_real[16:0]
18 × +
B_imag[17:0] 48
18 PREG2 = PREG1+ 0,(A_real[16:0] × B_imag[17:0])
48
0,A_imag[16:0] × B_real[17:0]
Slice 1
0,A_imag[16:0]
18 × +
B_real[17:0] 48
18 PREG1 = (0,A_imag[16:0] × B_real[17:0])
Zero
Sign extended from 36 bits to 48 bits ug073_c1_24_071004
Xilinx • 47
DSP: DESIGNING FOR OPTIMAL RESULTS
17 bits of A
48 – 18 – N + 17 zeros
N MSBs of A
48 – 18 – N zeros N MSBs of A
18 – N LSBs of A
ug073_c1_25_061304
48 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
Slice 2
A[17:0]
18 × + AR[17:0]
48 48
PREG2 = right shifted by 17 PREG1+ n bit left shifted A[17:0]
Right “wire shift” by 17 bits
48
Slice 1
A[0,17:1]
18 × +
2n 48
18 PREG1 = [000..., 000..., A17:1, ...000]
Zero 12 36 – 18 – n + 1 17-bit n
zeros zeros A zeros
ug073_c1_26_071004
Xilinx • 49
DSP: DESIGNING FOR OPTIMAL RESULTS
-- <-----Cut code below this line and paste into the architecture body---->
port map (
BCOUT => BCOUT, -- 18-bit B cascade output
50 • Xilinx
XTREMEDSP DESIGN CONSIDERATIONS
DSP48 DSP48_inst (
.BCOUT(BCOUT), // 18-bit B cascade output
.P(P), // 48-bit product output
.PCOUT(PCOUT), // 38-bit cascade output
.A(A), // 18-bit A data input
.B(B), // 18-bit B data input
.BCIN(BCIN), // 18-bit B cascade input
.C(C), // 48-bit cascade input
.CARRYIN(CARRYIN), // Carry input signal
.CARRYINSEL(CARRYINSEL), // 2-bit carry input select
.CEA(CEA), // A data clock enable input
Xilinx • 51
DSP: DESIGNING FOR OPTIMAL RESULTS
52 • Xilinx
Chapter 3
The DSP48 slice efficiently performs a wide range of basic math functions, including adders,
subtracters, accumulators, MACs, multiply multiplexers, counters, dividers, square-root functions,
and shifters. The optional pipeline stage within the DSP48 tile ensures high performance arithmetic
functions. The DSP48 column structure and associated routing provides fast routing between DSP48
tiles with less routing congestion to the FPGA fabric. This chapter describes how to use the DSP48
slice to perform some basic arithmetic functions.
Overview
The DSP48 slice is shown in Figure 3-1. Refer to Figure 2-3, page 13 for a diagram showing two
slices cascaded together.
Cascade Out to Next Slice
BCOUT PCOUT
18
36
18 X
48
A 18 48 48
18 36 CIN
B
×
72
18
36 Y
48
± P
48
48 SUBTRACT
C ZERO
48
Z
48
48 18
48
48
BCIN Wire Shift Right by 17 Bits PCIN
Xilinx • 53
DSP: DESIGNING FOR OPTIMAL RESULTS
Add/Subtract
The DSP48 slice contains an adder/subtracter unit allowing different combinations of add/subtract
logic to be implemented in a single DSP slice. The output of the DSP48 slice in adder/subtracter mode
is:
Output = Z ± (X + Y +CIN)
The X, Y, and Z terms in this equation refer to the X, Y, and Z multiplexers shown in Figure 3-1.
The inputs to the X, Y, and Z multiplexers are routed to the outputs using OPMODE settings as
shown in Table 3-1. The CIN term is the Carry Input to the Adder/subtracter unit.
Determining whether an addition or a subtraction (±) takes place is controlled by the
SUBTRACT input to the adder/subtracter unit. The SUBTRACT input must be set to 0 to add, and
1 to subtract.
The Verilog code for this 48-bit adder is in the reference design file: ADDSUB48.v, and the
VHDL code is in the reference design file: ADDSUB48.vdh. This code can be used to implement any
data combination for this equation by using the different OPMODEs found in Table 3-1.
Accumulate
A DSP48 slice can implement add and accumulate functions with up to 36-bit inputs. The output
equation of the accumulator is:
Output = Output + A:B + C
Concatenate (:) the A and B inputs to provide a 36-bit input from Multiplexer X using the
setting OPMODE[1:0] = 0’b11. Select the C input to Multiplexer Y using the setting
OPMODE[3:2] = 0’b11. To add (accumulate) the output of the slice, select the feedback path (P)
through the Z multiplexer using the setting OPMODE[6:4] = 0’b010.
Other accumulate functions can be implemented by changing the OPMODE selection for the Z
input multiplexer. To get an output of:
Output = Shift(P) ± (A:B + C)
54 • Xilinx
DSP48 SLICE MATH FUNCTIONS
use the setting OPMODE[6:4] = 0’b110 to select the Shift(P) input to the Z multiplexer. To get
an output of:
Output = 0 ± (A:B +C)
(no accumulation) use the setting OPMODE [6:4] = 0’b0000 to select the ZERO input to the
Z multiplexer.
The Verilog code for the accumulator is in the reference design file ACCUM48.v, and the VHDL
code is in the reference design file ACCUM48.vhd.
Multiplexer
There are three multiplexers in a DSP48 slice: the 3:1 Y multiplexer, the 4:1 X multiplexer, and the
6:1 Z multiplexer. Only one multiplexer is active to use the slice as a pure multiplexer. Make the other
two multiplexers inactive by choosing the OPMODE selecting the ZERO inputs. The two DSP48
tiles in a slice can be combined to make wider input multiplexers.
Barrel Shifter
An 18-bit barrel shifter can be implemented using the two DSP48 tiles in the DSP slice. To barrel
shift the 18-bit number A[17:0] two positions to the left, the output from the barrel shifter is
A[15:0], A[17], and A[16]. This operation is implemented as follows.
The first DSP48 is used to multiply {0,A[17:1]} by 22. The output of this DSP48 tile is now
{0,A[17:1],0,0}. The output from the first tile is fed into the second DSP48 tile over the
PCIN/PCOUT signals, and is passed through the 17-bit right-shifted input. The input to the Z
multiplexer becomes {0,A[17],A[16]}, or {0,A[17:0],0,0} shifted right by 17 bits.
The multiplier inputs to the second DSP48 tile are A = A[17:0] and B = 22. The output of this
multiplier is {A[17:0], 0,0}. This output is added to the 17-bit right-shifted value of {0,A[17],A[16]}
coming from the previous slice. The 18-bit output of the adder is {A[15:0],A[17],A[16]}. This is the
initial A input shifted by two to the left.
The Verilog code is in the reference design file barrelshifter_18bit.v, and the VHDL code
is in the reference design file barrelshifter_18bit.vhd).
Counter
The DSP48 slice can be used as a counter to count up by one on each clock cycle. Setting the
SUBTRACT input to ‘0’, the carry-in input (CIN) to ‘1’, and OPMODE [6:0] = 0’b0100000 gives
an output of P + CIN. After the first clock, the output P is 0 + 1 = 1. Subsequent outputs are P + 1.
Xilinx • 55
DSP: DESIGNING FOR OPTIMAL RESULTS
This method is equivalent to counting up by one. The counter can be used as a down counter by
setting the SUBTRACT input to a ‘1’ at the start.
The counter can also be preloaded using the C input to provide the preload value. Setting the
Carry In input (CIN) to ‘1’ and OPMODE [6:4] = 0’b0110000 gives an output of P = C+1 in the
first cycle. For subsequent clocks, set the OPMODE to select P = P+1 by changing OPMODE [6:4]
from 0’b0110000 to 0’b0100000.
The Verilog code for a loadable counter is in the reference design file CNTR_LOAD.v, and the
VHDL code for a loadable counter is in the reference design file CNTR_LOAD.vhd.
Multiply
A single DSP48 slice can implement an 18x18 signed or unsigned multiplier. Larger multipliers can
be implemented in a single DSP48 slice by sequentially shifting the appropriate number of bits in
each clock cycle. The Verilog implementation of an 18x18 multiplier is in the reference design file
MULT18X18_PARALLEL.v, and the VHDL implementation is in the reference design file
MULT18X18_PARALLEL.vhd.
The Verilog implementation of a 35x35 multiplier and a sequential 35x35 multiplier are in the
reference design files MULT35X35_PIPE.v and MULT35X35_SEQUENTIAL_PIPE.v respectively.
The VHDL implementation of a 35x35 multiplier and a sequential 35x35 multiplier are in the
reference design files MULT35X35_PIPE.vhd and MULT35x35_SEQUENTIAL_PIPE.vhd,
respectively.
Divide
Binary division can be implemented in the DSP48 slice by performing a shift and subtract or a
multiply and subtract. The DSP48 slice includes a shifter, a multiplier, and adder/subtracter unit to
implement binary division. The division by subtraction and division by multiplication algorithms are
shown below. These algorithms assume:
1. N > D
2. N and D are both positive
If either N or D is negative, use the same algorithms by taking the absolute positive values for N
and D and making the appropriate sign change in the result.
The terms N and D in the algorithms refer to the number to be divided (N) and the divisor (D).
The terms Q and R in the algorithms refer to the quotient and remainder, respectively.
Dividing with Subtraction
The shift and subtract algorithm can be explained as follows:
If N is an 8-bit integer and D is not more than 8 bits wide, N/D = Q + R
1. Assign the 8-bit register R the value “00000000”.
2. Shift the R register one bit to the left and fill in the LSB with N[8-n].
3. Calculate R-D.
4. Set R and set Q:
a. If R-D is positive, set Q[8-n] to 1 and R = R-D
b. If R-D is negative, set Q[0] to 0 and R = R
5. Repeat Steps 2 to 4, filling in R[n] each time with N[8-n], where n is the number of the
iteration. Q[8-n] is filled each time in Step 4.
56 • Xilinx
DSP48 SLICE MATH FUNCTIONS
After the eighth iteration, Q[7:0] contains the quotient, and R[7:0] contains the remainder. For
example:
N 8 0000, 1000
--- = --- = ------------------------ = Q(10) + R(10)
D 3 011
Xilinx • 57
DSP: DESIGNING FOR OPTIMAL RESULTS
8 0000, 1000
--- = ------------------------ = Q(10) + R(10)
3 011
58 • Xilinx
DSP48 SLICE MATH FUNCTIONS
Both of the division implementations are possible in one DSP48 slice. The slice usage for 8-bit
division is one DSP48, and the latency is eight clock cycles.
The Verilog code for the Divide by Subtraction implementation is in the reference design file
DIV_SUB.v, and the VHDL code is in the reference design file DIV_SUB.vhd. The Verilog code for
the Divide by Multiplication implementation is in DIV_MULT.v and the VHDL code for the second
implementation is in DIV_MULT.vhd.
Square Root
The square root of an integer number can be calculated by successive multiplication and subtraction.
This is similar to the subtraction method used to divide two numbers. The square root of an N-bit
number will have N/2 (rounded up) bits. If the square root is a fractional number, N/2 clocks are
needed for the integer part of the answer, and every following clock gives one bit of the fraction part.
The logic needed to compute this is shown in Figure 3-2.
1'b1
1'b0
Register Multiplier
A
Register
A
Subtractor
Input
Input = Reg C
UG073_c2_02_061304
X = Y.Z
Y is the integer part of the root, and Z is the fraction part. Register A refers to the registers found
on the A input to the DSP48 slice, and Register C refers to the registers found on the C input to the
DSP48 slice
1. Read the number into Register C. Set Register A to 8’b10000000.
2. Calculate Register C – (Register A * Register A).
3. If step 2 is positive, set Register A[(8-clock)] = 1,
Register A[(8-clock)-1] = 1
Xilinx • 59
DSP: DESIGNING FOR OPTIMAL RESULTS
60 • Xilinx
DSP48 SLICE MATH FUNCTIONS
I = n–1
∑
2 2 2
SoS = A + B or SoS = Ai
i=0
Equation 3-1
I = n–1
∑
2 2 2
SoS = A + B or SoS = Ai
i=0
Equation 3-2
These functions are basic multiply-accumulate operations easily implemented on the DSP48 slice
as described in “Multiply Accumulate (MAC),” page 55. A variation of this function is when the
square root of either of the above equations is needed. In this case, the OPMODE does the MAC
function for n cycles and then switches to do the square root function for the next n cycles. The
Subtract input is dynamic and does an “add” for the MAC cycles and a “subtract” for the square root
cycles.
With the SUBTRACT input equal to 0, the OPMODE for the function is 0110101. A square
root function is implemented by changing the SUBTRACT input to a “1”.
Xilinx • 61
DSP: DESIGNING FOR OPTIMAL RESULTS
Conclusion
The DSP48 slice has a variety of features for fast and easy implementation of many basic math
functions. The dedicated routing region around the DSP48 slice and the feedback paths provided in
each slice result routing improvements. The high-speed multiplier and adder/subtracter unit in the
slice delivers high-speed math functions.
62 • Xilinx
Chapter 4
This chapter describes the implementation of a Multiply-Accumulate (MAC) Finite Impulse Response
(FIR) filter using the DSP48 slice in a Virtex™-4 device. Because the Virtex-4 architecture is flexible,
constructing FIR filters for specific application requirements is practical. Creating optimized filter
structures of a sequential nature saves resources and potential clock cycles.
This chapter demonstrates two sequential filter architectures: the single-multiplier and the dual-
multiplier MAC FIR filter. Reference design files are available for the System Generator in DSP,
VHDL, and Verilog. These reference designs permit filter parameter changes including coefficients
and the number of taps.
Overview
A large array of filtering techniques is available to signal processing engineers. A common filter
implementation uses the single multiplier MAC FIR filter. In the past, this structure used the
Virtex-II embedded multipliers and 18K block RAMs. The Virtex- 4 DSP48 slice contains higher
performance multiplication and arithmetic capabilities specifically designed to enhance the use of
MAC FIR filters in FPGA-based Digital Signal Processing (DSP).
yn = ∑ xn – i hi Equation 4-1
i=0
In this equation, a set of N coefficients is multiplied by N respective data samples, and the inner
products are summed together to form an individual result. The values of the coefficients determine
the characteristics of the filter (e.g., low-pass filter, band-pass filter, high-pass filter). The equation can
be mapped to many different implementations (e.g., sequential, semi-parallel, or parallel) in the
different available architectures.
Xilinx • 63
DSP: DESIGNING FOR OPTIMAL RESULTS
For slow sample rate requirements and a large number of coefficients, the single MAC FIR filter
is well suited and dual-port block RAM is the optimal choice for the memory buffer. This structure is
illustrated in Figure 4-1. If the number of coefficients is small, distributed memory and the SRL16E
can be used as the data and coefficient buffers. For more information on using distributed memory,
refer to “Using Distributed RAM for Data and Coefficient Buffers,” page 70.
Data Samples A
96 x 18 18
P
Data Addr
B
Coefficients
Control WE 96 x 18
Coef Addr load
Optional Output
Register Used
Z-4
UG073_c3_02_081804
The input data buffer is implemented in dual-port block RAM. The read address port is clocked
N times faster than the input samples are written into the data port, where N is the number of filter
taps. The filter coefficients are also stored in the same dual-port block RAM, and are output at port B.
Hence, the RAM is used in a mixed-mode configuration. The data is written and read from port A
(RAM mode), and the coefficients are read only from port B (ROM mode).
The control logic provides the necessary address logic for the dual-port block RAM and creates a
cyclic RAM buffer for port A (data buffer) to create the FIR filter delay line. An optional output
capture register maybe required for streaming operation, if the accumulation result can not be
immediately used in downstream processing.
The multiplier followed by the accumulator sums the products over the same number of cycles as
there are coefficients. With this relationship, the performance of the MAC FIR filter is calculated by
the following equation:
M a x i m u m I n p u t S a m pl e R a t e = C l o c k S p ee d / N u mb e r o f Ta ps Equation 4-2
If the coefficients possess a symmetric shape, a slightly costlier structure is available (see
“Symmetric MAC FIR Filter,” page 72), however, the maximum sampled rate is doubled. The sample
rate of the costlier structure is defined as follows:
S am p l e R at e = C l o c k S p e e d / ( 1 /2 x nu m b e r o f t a p s ) Equation 4-3
64 • Xilinx
MAC FIR FILTERS
Bit Growth
The nature of the FIR filter, with numerous multiplies and adds, outputs a larger number of bits from
the filter than are present on the filter’s input. This effect is the "bit growth" or the "gain" of a filter.
These larger results cannot be maintained throughout a system due to cost implications. Therefore, the
full precision result is typically rounded and quantized (refer to “Rounding,” page 69) back to a
desired level. However, it is important to calculate the full precision output in order to select the
correct bits from the output of the MAC.
A simple explanation for implementation purposes involves considering the maximum value
expected at the output (saturation level). A greater understanding of the specific filter enhances the
accuracy of the output bit width. The following two techniques help determine the full precision
output bit width.
Generic Saturation Level
This technique assumes every value in the filter could be the worst possible for the size of the two’s
complement numbers specified. Using the generic saturation level is a good starting point when the
coefficients are unknown, but the number of bits required to represent them is known. For example,
if the coefficients are reloadable, as in adaptive filters.
O u t pu t W i dt h = c e i l ( l o g 2 ( 2 ( b - 1 ) x 2 (c -1) x N ) + 1 Equation 4-4
where:
ceil: Rounds up to the nearest integer
b: Number of bits in the data samples
c: Number of bits in the coefficients
Coefficient Specific Saturation Level
This technique uses the magnitude-only sum of actual coefficient values and applies the worst-case
data samples to the filter. More accurate calculations could be required if a bit maximum is reached.
With actual coefficients, the output for the worst possible inputs can be determined.
O u t p u t W i d th = c e i l ( l og 2 ( 2 ( b - 1 ) x a b s ( s u m ( c oe f )) x N ) + 1 Equation 4-5
where:
ceil: Rounds up to the nearest integer
abs: Makes the absolute value of a number (not negative)
sum: Sums all the values in an array
B: Number of bits in the data samples
C: Number of bits in the coefficients
If the output width exceeds 48 bits, there are notable effects on the size (in terms of the number
of DSP48 slices used to implement the filter), because the DSP48 slice is limited to a 48-bit result.
The output width can be extended by using more DSP48 slices, however, reconsidering the
specification is more practical.
Control Logic
The control logic is very straightforward when using an SRL16E for the data buffer. For dual-port
block RAM implementations the cyclic RAM buffer is required. This can complicate the control
logic, and there are two different ways this control can be implemented. Both techniques produce the
same results, but one way uses all slice-based logic to produce the results, while the other way embeds
Xilinx • 65
DSP: DESIGNING FOR OPTIMAL RESULTS
the control in the available space in the Block RAM. The basic architecture of the control logic for the
slice based approach is outlined in Figure 4-2.
en addr Data
Address
Data
Counter WE
A = 2N – 2
Load ACC
en addr Coefficient
Address
Coefficient
Counter UG073_c3_03_090204
Figure 4-2: Dual-Port Block RAM MAC FIR Filter Control Logic Using Slices
The control logic consists of two counters. One counter drives the address of the coefficient
section of the dual-port block RAM, while the other controls the address for the data buffer. A
comparator controls an enable to the data buffer counter to disable the count for one cycle every output
sample, and writes a new sample into the data buffer every N cycles. A simplified diagram of the
control logic and the memory is shown in Figure 4-3.
Dual-Port RAM
Counter DIN A
0 – (N–1)
WE DOUT A
Counter DIN B
N – (2N–1) Coefficient
WE ROM DOUT B
coef addr
addr
DIN D1 X X X X X D2 X X X X X D3 X X X
Data Addr 0 1 2 3 94 95 95 0 1 2 93 94 94 95 0 1
Coeff Addr 96 97 98 99 190 191 96 97 98 99 190 191 96 97 98 99
WE WE UG073_c3_04_090204
66 • Xilinx
MAC FIR FILTERS
The cyclic data RAM buffer is required to emulate the delay line shift register of the FIR filter
while using a static RAM. The RAM is addressed sequentially every clock cycle. The counter rolls over
to have the last coefficient (N–1) read out. At this point, the data buffer is stalled by the controlling
clock enable and the newest sample is read into the buffer AFTER the oldest data sample is read out.
This newest data sample is now multiplied by the first coefficient (as the coefficient address counter is
never disabled) and the cycle is repeated. The effect is of data shifting over time as the FIR filter
equation requires. The ability to perform a simultaneous read and write requires the RAM buffer to
have a read port and a write port (called read before write mode).
The inverted WE signal is also used to drive the load input (OPMODE[5]) on the DSP48 slice.
This signal must be delayed with a simple SRL16E to make sure the latency on the signal matches the
latency through the MAC engine. This delay is typically four clocks, but depends upon the number of
pipelining registers used in the DSP48 slice and block RAM. The number of required pipelining
stages is a function of the desired achievable clock frequency.
The number of resources used for the control logic is easily calculated. The counters are always
two bits per slice plus the additional logic required to count limit the counter (unless the counter is a
power of two limit). The count limiter circuit size is determined by the number of bits needed to
represent the count limit value divided by four. Therefore, n/2 + n/4 slices are required for each
counter, but the coefficient counter is larger due to the higher count value. The other control logic
typically yields about N/4 slices due to the comparator required for the enable circuitry and the
inverter to disable the data counter.
The total number of slices for the control logic for an 18 x 18 MAC FIR filter with 96 coefficients
is listed in Table 4-1.
Table 4-1: Control Logic Using Slices Resource Utilization
Elements Slices
Coefficient Counter 5
Data Counter 4
Relational Operator 1
Other Logic 1
Total 11
Xilinx • 67
DSP: DESIGNING FOR OPTIMAL RESULTS
trick. Figure 4-4 illustrates the control logic and memory layout for this embedded control logic
implementation.
coef addr
Counter
N -> (2N–1)
Dual-Port RAM
DIN D1 X X X X X D2 X X X X X D3 X X X
Coeff Addr 0 1 2 3 94 95 0 1 2 3 94 95 0 1 2 3
Data Addr 96 97 98 99 190 191 191 96 97 98 189 190 190 191 96 97
WE WE UG073_c3_05_090204
Figure 4-4 demonstrates how the predictable and repeatable control sequence for the coefficient
side of the memory can be embedded into the remaining space of the memory. The coefficient address
value, accumulator Load signal, CE, and WE for the data buffer are precalculated and concatenated on
to the coefficient values. The memory must be used in 512 x 36 mode, instead of 1024 x 18 mode. The
individual signals are split up correctly on the output of the memory. This costs nothing in logic
utilization apart from routing.
Due to the feedback nature of the address line, it is important to set the initial state of the dual-
port block RAM’s output register to effectively “kick- start” the MAC process. The initial values need
to be different from each other to start the correct addressing, however, the silicon forces them to be
the same. This changes the 1-bit masking of the LSB of the coefficient address such that the first value
is ‘0’ instead of the initialized value of ‘1’. The initial value of the output latch is on the address bus the
next cycle and, by unmasking the LSB, the count is successfully kick-started. Because the coefficients
are placed in the upper half of the memory, only a single LSB must be masked, not the complete
address bus. The masking signal can take the form of a reset signal or a registered permanent value to
get the required single cycle mask. Each address concatenated onto its respective coefficient is the next
required address (ahead by two cycles due to the output latch and register) to keep cycling through the
coefficients.
This technique enables a reduction in the control logic required for the MAC FIR filter, but it can
only be exploited when the number of coefficients is smaller than 256 for greater than 9-bit data (256
68 • Xilinx
MAC FIR FILTERS
data and 256 coefficient elements are required to be stored). Table 4-2 highlights the smaller resource
utilization.
Table 4-2: Control Logic Using Embedded Block RAMs Resource Utilization
Element Slices
Control Counter 5
Total 5
Rounding
As noted earlier, the number of bits on the output of the filter is much larger than the number of bits
on the input, and must be reduced to a manageable width. The output can be truncated by simply
selecting the MSBs required from the filter. However, truncation introduces an undesirable DC data
shift due to the nature of two’s complement numbers. Negative numbers become more negative, and
positive numbers also become more negative. The DC shift can be improved with the use of symmetric
rounding, where positive numbers are rounded up and negative numbers are rounded down.
The rounding capability built into the DSP48 slice maintains performance and minimizes the use
of the FPGA fabric. This is implemented in the DSP48 slice using the C input port and the Carry-In
port. The rounding is achieved in the following manner:
• For positive numbers: Binary Data Value + 0.10000… and then truncate
• For negative numbers: Binary Data Value + 0.01111... and then truncate
The actual implementation always adds 0.0111… to the data value using the C input port, as in
the negative case, and then adds the extra carry in required to adjust for positive numbers. Table 4-3
illustrates some examples of symmetric rounding.
Table 4-3: Symmetric Rounding Examples
Decimal Value Binary Value Add Round Truncate: Finish Rounded Value
2.4375 0010.0111 0010.1111 0010 2
2.5 0010.1000 0011.0000 0011 3
2.5625 0010.1001 0011.0001 0011 3
-2.4375 1101.1001 1110.0000 1110 -2
-2.5 1101.1000 1101.1111 1101 -3
-2.5625 1101.0111 1101.1110 1101 -3
In the instance of the MAC FIR filter, the C input is available for continued use because the Z
multiplexer is used for the feedback from the P output. Therefore, for rounding to be performed,
either an extra cycle or another DSP48 slice is required. Typically, an extra cycle is used to save on
DSP48 slices. On the extra cycle, OPMODE is changed for the X and Y multiplexers, setting the X
multiplexer to zero and the Y multiplexer to use the C input to add the user-specified requirements for
a negative rounding scenario.
Xilinx • 69
DSP: DESIGNING FOR OPTIMAL RESULTS
The Z multiplexer remains unchanged, as the feedback loop is still required, leading to the
opcode being 0101100. The simplified diagram in Figure 4-5 shows how the DSP48 slice functions
during this extra cycle.
18 DSP48 Slice
Data Samples A
96 x 18 18
P
Data Addr
B
Coefficients
Control WE CIN
96 x 18
Coef Addr C
Rounding OPMODE
Dual-Port Block RAM Constant Translation
Z-4
UG073_c3_06_081804
70 • Xilinx
MAC FIR FILTERS
FIR filters. Figure 4-6 illustrates the MAC FIR filter implementation using distributed RAM for the
coefficient bank and an SRL16E for the data buffer.
DSP48 Slice
SRL16E
OPMODE = 0100101
18
A
P 18
WE
Control B
Addr Coefficients
16 x 18
load
Single-Port
Distributed Memory
Z-3
UG073_c3_07_081804
The resource utilization is still small for these small memories. For a 16-tap (or less), n-bit
memory bank, the cost is n/2 slices. Therefore, for this example, the cost is nine slices per memory
bank (18 slices in total).
The added benefit of using SRL16Es is the embedded shifting capabilities leading to a reduction
in control logic. Only a single count value is required to address both the coefficient buffer and the
data buffer. The terminal count signal is used to write the slower input samples into the data buffer
and capture the results and to load the accumulator with the new set of inner products. The size of the
control logic and memory buffer for a 16-tap, 18-bit data and coefficient FIR is detailed in Table 4-4.
Table 4-4: Control Logic Resource Utilization
Element Slices
Data Buffer 9
Coefficient Memory 9
Control Counter 2
Relational Operator 1
Capture/Load Delay 1
Total 22
All aspects of the DSP48 and capture register approach to the MAC FIR filter using distributed
RAM are identical to the block RAM based MAC FIR.
Xilinx • 71
DSP: DESIGNING FOR OPTIMAL RESULTS
Performance
Table 4-5 compares the performance of a Virtex-4 MAC FIR filter with a Virtex-II Pro solution.
Overall, the Virtex-4 DSP48 slice greatly reduces the logic fabric resource requirement, improves the
speed of the design, and reduces filter power consumption.
Table 4-5: 18 x 18 MAC FIR Filter (96 Tap) Comparison
18 x 18 MAC FIR Filter (96 Tap)
Parameter
Virtex-II Pro FPGA Virtex-4 FPGA
Size 99 slices, 1 Embedded Multiplier, 24 slices, 1 DSP48 Slice,
1 block RAM 1 block RAM
Performance 3.125 MSPS 4.69 MSPS
(Clock Speed) 250 MHz 450 MHz
Power 170 mW 57 mW
17
Data Samples A
96 x 18
P 18
Data1 Addr
B
Dual Read
Control WE
Access
Data2 Addr
DSP48 Slice load
Coef Addr Dual-Port Block RAM
OPMODE = 010010
Z-4
Coefficients
48 x 18
72 • Xilinx
MAC FIR FILTERS
There are limitations to using the symmetric MAC FIR filter. Due to the 1-bit growth from the
pre-adder shown in Figure 4-5, the data input to the filter must be less than 18 bits to fit into one
DSP48 slice. If necessary, the pre-adder can be implemented in slices or in another DSP48 slice.
The performance of this fabric-based adder represents the critical path through the filter and
limits the maximum clock speed. There are extra resources required for the filter to support symmetry.
Three memory ports are needed along with the pre-adder. The control portion increases in resource
utilization since the data is read out of one port in a forward direction and in reverse on the second
port. This technique should only be utilized when extra sample rate performance is required.
18 DSP48 Slice
Data Samples A
43 x 18
P 18
Data Addr
B
Coefficients
Control WE 43 x 18
Coef Addr
OPMODE = 010010
OPMODE Dual-Port Block RAM
Translation
18
DSP48 Slice
Data Samples A
43 x 18
B
Coefficients
43 x 18
Xilinx • 73
DSP: DESIGNING FOR OPTIMAL RESULTS
DSP48 Slice
18
Data Samples A
43 x 18 18
P
Data Addr
B
Coefficients Cin
Control WE 43 x 18
Coef Addr
OPMODE = 0011110
OPMODE Dual-Port Block RAM
Translation Rounding
Constant
18 DSP48 Slice
Data Samples A
43 x 18
B
Coefficients
43 x 18
OPMODE = 0100101
Dual-Port Block RAM
UG073_c3_10_081804
Conclusion
MAC FIR filters are commonly used in DSP applications. With the introduction of the Virtex-4
DSP48 slice, this function can be achieved in a smaller area, while at the same time producing higher
performance with less power resources. Designers have tremendous flexibility in determining the
desired implementation as well as the ability to change the implementation parameters.
Each specification and design scenario brings a different set of restrictions for the design. Several
more techniques are discussed in the next chapters. The ability to "tune" a filter in an existing system
or to have multiple filter settings is a distinct advantage. The HDL and System Generator for DSP
reference designs are easily modified to achieve specific requirements, such as different coefficients,
smaller data and coefficient bit widths, and coefficient values.
74 • Xilinx
Chapter 5
This chapter describes the implementation of high-performance, parallel, full-precision FIR filters
using the DSP48 slice in a Virtex-4 device. Because the Virtex-4 architecture is flexible, it is practical
to construct custom FIR filters to meet the requirements of a specific application. Creating optimized,
parallel filters saves either resources and potential clock cycles.
This chapter demonstrates two parallel filter architectures: the Transposed and Systolic Parallel
FIR filters. The reference design files in VHDL and Verilog permit filter parameter changes including
coefficients and the number of taps.
Overview
There are many filtering techniques available to signal processing engineers. A common filter
implementation for high-performance applications is the fully parallel FIR filter. Implementing this
structure in the Virtex-II architecture uses the embedded multipliers and slice based arithmetic logic.
The Virtex- 4 DSP48 slice introduces higher performance multiplication and arithmetic capabilities
specifically designed to enhance the use of parallel FIR filters in FPGA-based DSP.
Xilinx • 75
DSP: DESIGNING FOR OPTIMAL RESULTS
500
400
Parallel FIR Filters (Chapter 4)
300
200
100
Sample Rate (MHz)
50
Semi-Parallel FIR Filters
Log Scale
(Chapter 5)
10
0.5
5 20 50 200 500
1 10 100 1000
The basic parallel architecture, shown in Figure 5-2, is referred to as the Direct Form Type 1.
18
h3 h2 h1 h0
18
38
UG073_c4_03_060404
76 • Xilinx
PARALLEL FIR FILTERS
This structure implements the general FIR filter equation of a summation of products as defined
in Equation 5-1.
N–1
yn = ∑ xn – i hi Equation 5-1
i=0
In Equation 5-1, a set of N coefficients is multiplied by N respective data samples. The results are
summed together to form an individual result. The values of the coefficients determine the
characteristics of the filter (e.g., a low-pass filter).
The history of data is stored in the individual registers chained together across the top of the
architecture. Each clock cycle yields a new complete result and all multiplication and arithmetic
required occurs simultaneously. In sequential FIR filter architectures, the data buffer is created using
Virtex-4 dedicated block RAMs or distributed RAMs. This demonstrates a trend; as algorithms
become faster, the memory requirement is reduced. However, the memory bandwidth increases
dramatically since all N coefficients must be processed at the same time.
The performance of the Parallel FIR filter is calculated in Equation 5-2.
M a x i m u m I n p u t S a m p l e R a t e = C l o c k S p e ed Equation 5-2
The bit growth through the filter is the same for all FIR filters and is explained in the section “Bit
Growth” in Chapter 4.
18
B B B B
h3 h2 h1 h0
0 20 P
The input data is broadcast across all the multipliers simultaneously, and the coefficients are
ordered from right to left with the first coefficient, h0, on the right. These results are fed into the
pipelined adder chain acting as a data buffer to store previously calculated inner products in the adder
chain. The rearranged structure yields identical results to the Direct Form structure, but gains from
the use of an adder chain. This different structure is easily mapped to the DSP48 slice without
Xilinx • 77
DSP: DESIGNING FOR OPTIMAL RESULTS
additional external logic. If more coefficients are required, then more DSP48 slices are required to be
added to the chain.
The configuration of the DSP48 slice for each segment of the Transposed FIR filter is shown in
Figure 5-4. Apart from the very first segment, all processing elements are to be configured as in
Figure 5-4. OPMODE is set to multiply mode with the adder combining the results from the
multiplier and from the previous DSP48 slice through the dedicated cascade input (PCIN). OPMODE
is set to binary 0010101.
PCIN PCOUT
DSP48 Slice
OPMODE = 0010101 UG073_c5_05_081104
Resource Utilization
An N coefficient filter uses “N” DSP48 slices. A design cannot use symmetry to reduce the number of
DSP48 slices when using the Transposed FIR filter structure.
78 • Xilinx
PARALLEL FIR FILTERS
B
18
h0 h1 h2 h3
18
0 20 P
The input data is fed into a cascade of registers acting as a data buffer. Each register delivers a
sample to a multiplier where it is multiplied by the respective coefficient. In contrast to the
Transposed FIR filter, the coefficients are aligned from left to right with the first coefficients on the
left side of the structure. The adder chain stores the gradually combined inner products to form the
final result. As with the Transposed FIR filter, no external logic is required to support the filter and
the structure is extendable to support any number of coefficients.
The configuration of the DSP48 slice for each segment of the Systolic FIR filter is shown in
Figure 5-6. Apart from the very first segment, all processing elements are to be configured as shown
in Figure 5-6. OPMODE is set to multiply mode with the adder combining the results from the
multiplier and from the previous DSP48 slice through the dedicated cascade input (PCIN). OPMODE
is set to binary 0010101. The dedicated cascade input (BCIN) and dedicated cascade output
(BCOUT) are used to create the necessary input data buffer cascade.
BCIN BCOUT
PCIN PCOUT
DSP48 Slice
OPMODE = 0010101 ug073_c4_07_081104
Xilinx • 79
DSP: DESIGNING FOR OPTIMAL RESULTS
Resource Utilization
An N coefficient filter uses “N” DSP48 slices.
17
B B B B
h0 h1 h2 h3
P
0 38
80 • Xilinx
PARALLEL FIR FILTERS
In this structure, DSP48 slices have been traded off for Fabric slices. From a performance
viewpoint, to achieve the full speed of the DSP48 slice, the fabric 18-bit adder has to run at the same
speed. To achieve this, register duplication can be performed on the output from the last tap that feeds
all the other multipliers.
The two register delay in the input buffer time series is implemented as an SRL16E and a register
output to save on logic area. A further benefit of the symmetric implementation is the reduction in
latency, due to the adder chain being half the length.
Figure 5-8 shows the configuration of the DSP48 slice for each segment of the Symmetric Systolic
FIR filter. Apart from the very first segment, all processing elements are to be configured as in
Figure 5-8. OPMODE is set to multiply mode with the adder combining results from the multiplier
and from the previous DSP48 slice via the dedicated cascade input (PCIN). OPMODE is set to binary
0010101.
PCIN PCOUT
DSP48 Slice
OPMODE = 0010101 UG073_c5_11_082404
Resource Utilization
An N symmetric coefficient filter uses N DSP48 slices. The slice count for the pre-adder and input
buffer time series is a factor of the input bit width (n) and N. The equation for the size in slices is:
(( n +1 ) * ( N / 2 ) ) + (n / 2 ) Equation 5-4
For the example illustrated in Figure 5-7, the size is (17+1) * 8/2 + 17/2 = 81 slices.
Rounding
The number of bits on the output of the filter is much larger than the input and must be reduced to a
manageable width. The output can be truncated by simply selecting the MSBs required from the filter.
However, truncation introduces an undesirable DC data shift. Due to the nature of two's complement
numbers, negative numbers become more negative and positive numbers also become more negative.
The DC shift can be improved with the use of symmetric rounding, where positive numbers are
rounded up and negative numbers are rounded down.
The rounding capability in the DSP48 slice maintains performance and minimizes the use of the
FPGA fabric. This is implemented in the DSP48 slice using the C input port and the Carry In port.
Rounding is achieved by:
For positive numbers: Binary Data Value + 0.10000… and then truncate
For negative numbers: Binary Data Value + 0.01111... and then truncate
Xilinx • 81
DSP: DESIGNING FOR OPTIMAL RESULTS
The actual implementation always adds 0.0111… to the data value through the C port input as
in the negative case, and then adds the extra carry in required to adjust for positive numbers. Table 5-1
illustrates some examples of symmetric rounding.
For both the Transposed and Systolic Parallel FIR filters, the C input is used at the beginning of
the adder chain to drive the carry value into the accumulated result. The final segment uses the MSB
of the PCIN as the carry-in value to determine if the accumulated product is positive or negative.
CARRYINSEL is used to select the appropriate carry-in value. If positive, the carry-in value is used,
and if negative, the result is kept the same (see Figure 5-9).
B
18
h0 h1 h2 h3
18
0.49999 C 18 P
The one problem with this solution occurs when the final accumulated inner product input to the
final DSP48 slice is very close to zero. If the value is positive and the final inner product makes the
result negative (leading to a rounding down), then an incorrect result occurs because the rounding
function assumes a positive number instead of a negative. The last coefficient in typical FIR filters is
very small, so this situation rarely occurs. However, if absolute certainty is required, an extra DSP48
82 • Xilinx
PARALLEL FIR FILTERS
slice can perform the rounding function (see Figure 5-10). A Transposed FIR filter can have exactly the
same problem as the Systolic FIR filter.
0.4999
C
B
18
h0 h1 h2 h3
18
P
C 18
0
DSP48 Slice DSP48 Slice DSP48 Slice DSP48 Slice DSP48 Slice
OPMODE = 0'b0000101 OPMODE = 0'b0010101 OPMODE = 0'b0010101 OPMODE = 0'b0010101 OPMODE = 0'b0011101
Carryinsel = 01
UG073_c4_09_061304
Performance
When examining the performance of a Virtex-4 Parallel FIR filter, a Virtex-II Pro design is a valuable
reference. Table 5-2 illustrates the ability of the Virtex-4 DSP48 slice to greatly reduce logic fabric
resources requirements while improving the speed of the design and reducing the power utilization of
the filter.
Xilinx • 83
DSP: DESIGNING FOR OPTIMAL RESULTS
Conclusion
Parallel FIR filters are commonly used in high-performance DSP applications. With the introduction
of the Virtex-4 DSP48 slice, DSPs can be achieved in a smaller area, thereby producing higher
performance with less power penalty.
Designers have tremendous flexibility in determining the desired implementation, and also have
the ability to change the implementation parameters. The ability to “tune” a filter in an existing
system or to have multiple filter settings is a distinct advantage. By making the necessary coefficient
changes in the synthesizable HDL code, the reconfigurable nature of the FPGA is fully exploited. The
coefficients can be either hardwired to the A input of the DSP48 slices or stored in small memories and
selected to change the filter characteristics. The HDL and System Generator for DSP reference designs
are easily modified to achieve specific requirements.
84 • Xilinx
Chapter 6
Overview
A large array of filtering techniques are available to signal processing engineers. A common filter
implementation to exploit available clock cycles, while still achieving moderate to high sample rates,
is the semi-parallel (also known as folded-hardware) FIR filter. In the past, this structure used the
Virtex-II embedded multipliers and slice-based arithmetic logic. However, the Virtex-4 DSP48 slice
introduces higher performance multiplication and arithmetic capabilities to enhance the use of semi-
parallel FIR filters in FPGA-based DSP designs.
Xilinx • 85
DSP: DESIGNING FOR OPTIMAL RESULTS
over numerous clock cycles to achieve the result. These techniques are often referred to as semi-parallel
and are used to maximize efficiency of the filter (see Figure 6-1).
500
400
Parallel FIR Filters (Chapter 4)
300
200
100
Sample Rate (MHz)
50
Semi-Parallel FIR Filters
Log Scale
(Chapter 5)
10
0.5
5 20 50 200 500
1 10 100 1000
The semi-parallel FIR structure implements the general FIR filter equation of a summation of
products defined as shown in Equation 6-1.
N–1
yn =
∑ xn – i hi Equation 6-1
i=0
Here a set of N coefficients is multiplied by N respective time series data samples, and the results
are summed together to form an individual result. The values of the coefficients determine the
characteristics of the filter (for example, a low-pass filter).
Along with achievable clock speed and the number of coefficients (N), the number of multipliers
(M) is also a factor in calculating semi-parallel FIR filter performance. The following equation
demonstrates how the more multipliers used, the greater the achievable performance of the filter.
86 • Xilinx
SEMI-PARALLEL FIR FILTERS
Maximum Input Sample rate = (Clock speed / Number of Coefficients) x Number of Multipliers
The above equation is rearranged to determine how many multipliers to use for a particular semi-
parallel architecture:
Number of Multipliers = (Maximum Input Sample rate x Number of Coefficients) / Clock speed
The number of clock cycles between each result of the FIR filter is determined by the following
equation:
Number of Clock cycles per result = Number of Coefficients / Number of Multipliers
The bit growth on the output of the filter is the same as for all FIR filters and is explained in “Bit
Growth” in Chapter 4. The large 48-bit internal precision of the DSP48 slice means that little concern
needs to be paid to the internal bit growth of the filter.
Figure 6-2 illustrates the main structure for the four-multiplier, semi-parallel FIR filter.
PCIN 40
0 P CE4
DSP48 Slice DSP48 Slice DSP48 Slice DSP48 Slice DSP48 Slice
OPMODE = 0110101 OPMODE = 0010101 OPMODE = 0010101 OPMODE = 0010101 OPMODE = 0010010
UG073_c5_02_081104
The DSP48 slice arithmetic units are designed to be chained together easily and efficiently due to
dedicated routing between slices. Figure 6-2 shows how the four DSP48 slice multiply-add elements
are cascaded together to form the main part of the filter structure. Figure 6-3 provides a detailed view
Xilinx • 87
DSP: DESIGNING FOR OPTIMAL RESULTS
of the main multiply-add elements. The two pipeline registers are used on the B input to compensate
for the register on the output of the coefficient memory.
PCIN PCOUT
DSP48 Slice
OPMODE = 0010101
UG073_c5_03_081104
An extra DSP48 slice is required on the end to perform the accumulation of the partial results,
thus creating the final result. A new result is created every four cycles. Every four cycles, the
accumulation must be reset to the first partial value of the next result. As in the MAC FIR Filter, this
reset (or load) is achieved by changing the OPMODE value of the DSP48 slice for a single cycle.
OPMODE is changed from binary 0010010 to binary 0010000 (just a single bit change). At the
same time, the capture register is also enabled, and the final result is stored on the output (see
Figure 6-4).
SRL16E SRL16E SRL16E SRL16E
CE CE CE1 CE1 CE2 CE2 CE3
18 B B B B
PCIN 40
0 P CE4
DSP48 Slice DSP48 Slice DSP48 Slice DSP48 Slice DSP48 Slice
OPMODE = 0110101 OPMODE = 0010101 OPMODE = 0010101 OPMODE = 0010101 OPMODE = 0010000
UG073_c5_02_081104
Figure 6-4: Four-Multiplier, Semi-Parallel FIR Filter at the Start of a New Result Cycle
Control logic is required to make this dynamic change occur. The specifics are detailed in
“Control Logic and Address Sequencing,” page 90.
88 • Xilinx
SEMI-PARALLEL FIR FILTERS
samples along the time series buffer. The extra register on the output of each data buffer is required to
match up the data buffer pipeline with the extra delay caused by the adder chain. The extra register
should not cost extra resources, because it is already present in the slice containing the SRL16E (see
Figure 6-5).
1/2 SliceM
SRL16E
Register
DIN
CE
CE CE
ADDR[3:0]
DOUT
UG073_c5_05_081904
As long as the depth does not exceed 16, the resources required for each of these input memory
buffers is determined by the bit width of the input data (n). Therefore, n/2 SliceM is required for each
memory buffer, leading to nine slices per buffer in this filter example. For depths up to 32, resources
are a little more than doubled because two SRL16Es are needed, as well as an extra output multiplexer.
For more information on SliceM, refer to the CLB section in the Virtex-4 User Guide.
Coefficient Memory
The coefficients are divided up into four groups of four. This arrangement is determined by dividing
the total number of coefficients by the number of multipliers used in the implementation. In this
example, if the total number of coefficients is 16, and the number of multipliers is four, four
coefficients per memory are needed.
Note that filters with a total number of coefficients that are integer-divisible by the required
number of multipliers are very desirable. System designers should take this into account when
designing their filters to get the optimal filter specification for the implementation used. Otherwise,
the coefficients will have to be padded with zeros to achieve a number of coefficients that are integer-
divisible by the number of multipliers.
The coefficients are simply split into groups according to their order. The first four in the first
memory, the second four in the second memory, and so on (see Figure 6-6).
Xilinx • 89
DSP: DESIGNING FOR OPTIMAL RESULTS
h0 h4 h8 h12
h1 h5 h9 h13
h2 h6 h10 h14
h3 h7 h11 h15
UG073_c5_06_060804
The adder chain architecture of the DSP48 slice means that each Multiply-Add cascade
multiplication must be delayed by a single cycle so that the results synchronize appropriately when
added together. This delay is achieved by addressing of the memories and is explained in “Control
Logic and Address Sequencing”.
Distributed RAM (refer to Chapter 2, “XtremeDSP Design Considerations,” for detailed
information on distributed RAMs) are used for the coefficient memories. The reason for their use is
that it would be an extremely inefficient usage of the larger block RAMs, especially given their
scarcity versus the smaller abundant distributed RAMs. The larger block RAM comes into play when
the number of coefficients per memory starts to increase to the point where the cost in slice resources
becomes significant (for example, greater than 64).
The total cost of the current example is 36 slices. The coefficient width is 18 bits, and distributed
RAMs cost n/2 slices (that is, nine slices per memory and four memories). For larger distributed RAMs
(larger than 16 elements), the size begins to increase as Write Enable (WE) control logic and an output
multiplexer is needed. The distributed memory v7.0 in the CORE Generator system can be easily used
to create these little distributed RAMs and get accurate size estimates.
90 • Xilinx
SEMI-PARALLEL FIR FILTERS
addr
Counter
0 -> N/M - 1
N/M - 1
Figure 6-7: Control Logic for the Four-Multiplier, Semi-Parallel FIR Filter
Figure 6-7 also shows clock enable sequencing. A relational operator is required to determine
when the count limited counter resets its count. This signal is High for one clock cycle every four
cycles, to represent the input and output data rates. The Clock Enable signal is delayed by a single
register just like the coefficient address, and each delayed version of the signal is tied to the respective
section of the filter. Refer to Figure 6-2 to see the signal connections to the element. Figure 6-8
illustrates the control logic waveforms changing over time.
Clock
Control CE
Control CE1
Control CE2
Control CE3
UG073_c5_08_082504
Resource Utilization
Table 6-2 shows the resources used by a 16-tap, four-multiplier, distributed-RAM-based, semi-
parallel FIR filter.
WE WE1 WE2
Cyclic Data Cyclic Data Cyclic Data
18 Buffer B Buffer B Buffer B
100 x 18 100 x 18 100 x 18
PCIN P 40
0 CE4
DSP48 Slice DSP48 Slice DSP48 Slice DSP48 Slice
OPMODE = 0110101 OPMODE = 0010101 OPMODE = 0010101 OPMODE = 0010010
UG073_c5_09_081104
The decision to use this implementation is based on the filter specification. The filter
specifications are described in Table 6-3.
Table 6-3: Three-Multiplier, Block RAM-Based, Semi-Parallel FIR Filter Specifications
Parameter Value
Sampling Rate 4.5 MSPS
Number of Coefficients 300
Assumed Clock Speed 450 MHz
Input Data Width 18 Bits
Output Data Width 18 Bits
92 • Xilinx
SEMI-PARALLEL FIR FILTERS
The structure is similar to the four-multiplier filter studied earlier. In this instance, the lower
sample rate of the filter specification and the larger number of taps indicates that only three multipliers
are required, each servicing 100 coefficients, leading to a new result yielded every 100 clock cycles.
Each memory buffer is required to hold 100 coefficients and also 100 input data history values.
The dedicated Virtex-4 block RAM can be used in dual-port mode with a cyclic data buffer established
in the first half of the memory to serve the shifting input data series.
Chapter 4, “MAC FIR Filters,” describes using these memories to store the input data series, the
coefficients, and also the control logic required to make the cyclic RAM buffer operate. The rest of the
control logic and data flow is identical to the first filter investigated except that only three multipliers
are serviced, therefore, the control logic can be scaled back by one element. Also note that the WE
signals are the inversion of their respective CE pair.
Table 6-4 shows the resource utilization for the 300-tap, three-multiplier, semi-parallel FIR
filter.
Xilinx • 93
DSP: DESIGNING FOR OPTIMAL RESULTS
18 Cyclic Data A
Buffer
400 x 18
43
CE
18 B
DSP48 Slice
OPMODE = 0100101
Coefficients 36
100 x 36 A
18 B
DSP48 Slice
OPMODE = 0100101
18 B
DSP48 Slice
OPMODE = 0100101
Coefficients 36
100 x 36 A
18 B
DSP48 Slice
OPMODE = 0100101 UG073_c5_10_061404
Only one data storage buffer is required, typically a block RAM. The data buffer output is also
broadcast to all DSP48 slices. Each DSP48 slice works in accumulator mode until the last cycle of the
calculation, when OPMODE changes to form an adder chain, and then passes the results to the next
DSP48 slice. Actually, four results are being calculated at one time, and the completed result is output
94 • Xilinx
SEMI-PARALLEL FIR FILTERS
from the last DSP48 slice. The previous elements are working on their respective parts of the next
results.
Figure 6-11 shows the filter structure every time the DSP48 slice OPMODE is changed, which
occurs once every result cycle.
Cycle Data A
18
Buffer
400 x 18 43
CE
18 B
DSP48 Slice
OPMODE = 0010101
Coefficients
36
100 x 36
A
Coefficients
100 x 36
18 B
DSP48 Slice
OPMODE = 0010101
18 B
DSP48 Slice
OPMODE = 0010101
36
18 B
DSP48 Slice
OPMODE = 0010101 UG073_c5_11_060804
Xilinx • 95
DSP: DESIGNING FOR OPTIMAL RESULTS
• Low latency due to the transpose nature of the filter implementation is lower than the Systolic
approach. The latency is equal to the size of one coefficient bank.
The disadvantages to using the Semi-Parallel, Transposed FIR filter are:
• Lower performance due to the broadcast nature of the data buffer output can limit
performance of the filter.
• Control logic is more difficult to understand, but is still of a compact nature.
Rounding
The number of bits on the output of the filter is much larger than the input and must be reduced to a
manageable width. The output can be truncated by simply selecting the MSBs required from the filter.
However, truncation introduces an undesirable DC shift on the data set.
Due to the nature of two’s complement numbers, negative numbers become more negative and
positive numbers also become more negative. The DC shift can be improved with the use of symmetric
rounding, where positive numbers are rounded up and negative numbers are rounded down. The
rounding capability built into the DSP48 slice maintains performance and minimizes the use of FPGA
fabric. This is ingrained in the DSP48 slice via the C input port and also the Carry-In port. Rounding
is achieved in the following manner:
For positive numbers: Binary Data Value + 0.10000… and then truncate
For negative numbers: Binary Data Value + 0.01111... and then truncate
The actual implementation always adds 0.0111… to the data value using the C port input as in
the negative case, and then adds the extra carry in required to adjust for positive numbers. Table 6-5
illustrates some examples of symmetric rounding.
In the instance of the semi-parallel FIR filter, an extra DSP48 slice is required to perform the
rounding functionality. It cannot be ingrained into the final accumulator because the rounding cannot
be done on the final result. If the C input is used and the accumulator is put into three-input add
mode, then rounding is performed on the partial result. The more multipliers in the filter, the worse
the rounding performance because even fewer inner products are included in the result. An extra
DSP48 slice is required to perform the rounding.
Due to the finite nature of the DSP48 slices, it is recommended that the symmetric rounder be
actually implemented in the fabric outside of the slices. The function is small and does not have to run
at a high frequency because the results are running at the much slower input data rate.
96 • Xilinx
SEMI-PARALLEL FIR FILTERS
Performance
It does not make sense to compare the performance of the semi-parallel FIR filter in a Virtex-4 device
with Virtex-II Pro results because completely different techniques are used to build the filters. As a
general statement though, Virtex-4 devices improve the speed of the design, shrink the area, and
reduce power drawn by the filter. All designs assume 18-bit data and 18-bit coefficient widths.
Table 6-6 through Table 6-8 compare the specifications for three filters.
Xilinx • 97
DSP: DESIGNING FOR OPTIMAL RESULTS
Conclusion
Semi-parallel FIR filters probably are the most frequently used filter techniques in Virtex-4 high-
performance DSP applications. Figure 6-12 shows the necessary implementation decisions and
provides guidelines for choosing the required structure based on the filter specifications.
Symmetric
Transposed FIR MACC FIR
500
400
Systolic FIR (symmetric & non-symmetric)
300
200
Increasing
Number of
Multipliers
100
Sample Rate (MHz)
50 Semi-Parallel
Distributed
Log Scale
Memory FIR
10-Multiplier
Semi-Parallel
FIR
10 Semi-Parallel
BRAM FIR
5
Distributed
Embedded
Memory
Control
MACC FIR
MACC FIR
1 Normal Control
Distributed Memory Block RAM
MACC FIR
0.5
5 20 50 200 500
1 10 100 1000
Figure 6-12: Selecting the Correct Filter Architecture for Semi-Parallel FIR Filters
The major lines indicate the guideline thresholds between given implementation techniques. For
instance, the shift to using block RAM is desirable when the number of taps needed to be stored in a
given memory exceeds 32. This correlates to two SRL16Es for the data buffers. If more than two
SRL16Es are used in a data buffer, it will be difficult to reach the high clock rate indicated in Chapter
4, “MAC FIR Filters,” Chapter 5, “Parallel FIR Filters,” and this chapter. However, this is only a
guideline. A great deal depends upon how many slices or block RAMs are remaining in the device, the
power requirements, and the available clock frequencies. A given filter implementation is subjective
because a different set of restrictions is provided by every application and design.
In general, the guidelines provided in the past three chapters should enable designers to make
sensible and efficient decisions when designing filters. These chapters also complete the foundations
required for filter construction in Virtex-4 devices so that more complex, multi-channel and
interpolation or decimation multi-rate filters can be constructed. The supplied referenced designs
further aid in helping to understand and utilize these filters.
98 • Xilinx
Chapter 7
This chapter illustrates the use of the advanced Virtex™-4 DSP features when implementing a
widely used DSP function known as multi-channel FIR filtering. Multi-channel filters are used to
filter multiple input sample streams in a variety of applications, including communications and
multimedia.
The main advantage of using a multi-channel filter is leveraging very fast math elements across
multiple input streams (i.e., channels) with much lower sample rates. This technique increases silicon
efficiency by a factor almost equal to the number of channels.
The Virtex-4 DSP48 slice is one of the new and highly innovative diffused elements that form the
basis of the Application Specific Modular BLock or ASMBL architecture. This modular architecture
enables Xilinx to rapidly and cost-effectively build FPGA platforms by combining different elements,
such as logic, memory, processors, I/O, and of course, DSP functionality targeting specific applications
such as wireless or video DSP.
The Virtex-4 DSP48 slice contains the basic elements of classic FIR filters: a multiplier followed
by an adder, delay or pipeline registers, plus the ability to cascade an input stream (B bus) and an
output stream (P bus) without exiting to a general slice fabric.
The resulting DSP designs can have optional pipelining that permits aggregate multi-channel
sample rates of up to 500 million samples per second, while minimizing power consumption and
external slice logic. In the implementation described in this chapter, multi-channel filtering can be
looked at as time-multiplexed, single-channel filters.
In a typical multi-channel filtering scenario, multiple input channels are filtered using a separate
digital filter for each channel. Due to the high performance of the DSP48 block within the Virtex-4
device, a single digital filter can be used to filter all eight input channels by clocking the single filter
with an 8x clock. This implementation uses 1/8th of the total FPGA resource as compared to
implementing each channel separately.
Top Level
The implementation of a six-channel, eight-tap FIR filter using DSP48 elements is depicted in
Figure 7-1. The design elements used in the implementation include the following:
Xilinx • #
DSP: DESIGNING FOR OPTIMAL RESULTS
xo(n)
x1(n)
x2(n)
Z-7 Z-7 Z-7
x3(n)
x4(n)
x5(n)
X X X X
UG073_c6_03_081804
All datapaths and coefficient paths for this example are 8 bits wide. The coefficient ROMs and
input sample delay elements are designed using SRL16Es. The SRL16E is a very compact and efficient
memory element, running at the very high 6x clock rate. For adaptive filtering, where coefficients can
be different depending upon their input signals, coefficient RAMs can be used to update the
coefficient values.
The DSP48 slices and interconnects also run at the 6x clock rate, providing unparalleled
performance for multiplication and additions in today’s FPGAs.
DSP48 Tile
The multi-channel filter block is a cascade implementation of the DSP48 tile. Each tile is
implemented as shown in Figure 7-2. An SRL16E is used to shift the input from the six channels. The
# • Xilinx
SEMI-PARALLEL FIR FILTERS
product cascade path between two DSP48 slices within the tile can be used to bring the product
output from one tap into the cascading input of the next tap for the final addition.
C1 X C2 X
Add
UG073_c6_04_081804
Counter
Shift Register
ug073_c6_05_060904
Figure 7-3: Converting Eight Input Streams to One Interleaved Input Stream
For each clock tick, the counter selects a different input stream (in order), and then supplies this
value to the SRL16E shift register. After six clock ticks, the six input samples for a given time period
are loaded sequentially, or interleaved into a single stream.
A six-to-one multiplexer must be designed carefully, as it is constructed with slice logic that must
run at the 6x clock rate. At 446 MHz, good design practices dictate connections “point-to-point,” a
maximum of one Look-Up Table (LUT) between flip-flops and RLOC techniques.
Xilinx • 15
DSP: DESIGNING FOR OPTIMAL RESULTS
To reduce the high fanouts on the selected lines of the multiplexer, the conceptual multiplexer in
Figure 7-3 is implemented as shown in Figure 7-4. This circuit is repeated for all eight bits of the
input sample width.
Shift Register
0 0 0 0 0 1
'1' '1'
X0(n)
X1(n) LUT
LUT
X2(n)
X3(n) LUT
LUT
X4(n)
X5(n) LUT LUT
'0'
UG073_c6_06_060904
Coefficient RAM
The six coefficient sets are stored in the SRL16 memories. If the same coefficient set is used for all
channels, then only a single set is stored in the SRL16. If the different channels use different
coefficients, then six sets of SRL16s are used for each tap. (Six RAMs can be used instead, one for each
channel.)
Each RAM is 8 bits wide and six deep, corresponding to the six taps. The optional Load input is
used to change or load a new coefficient set. Six clock cycles are needed to load all six RAMs. Input C1
is used to load the eight locations of RAM1 which are used for Channel1. C8 is used to load the eight
locations of RAM8 which are used for Channel8. At the eighth clock, all eight locations of the eight
RAMs are loaded; the filter then becomes an adaptive filter. The speed of the overall filter will be
reduced when the coefficients are stored in the RAM.
Control Logic
The control logic is used to ensure proper functioning of the different blocks. If the coefficient RAM
block is used, the control logic ensures that the load signal is High for six clocks. Different tap-
enabled signals are used to make sure that RAM values are read into the DSP48 correctly. For instance,
clock1 reads in the first location from RAM1, but the first location of RAM2 is read only at the clock
number equal to shift register length. The design assumes a clock is running at 6x that of the input
# • Xilinx
SEMI-PARALLEL FIR FILTERS
signals. The DCM can also be used to multiply the clock if the only available clock is running at the
input channel frequency.
The control logic also takes care of the initial latency such that the final output is enabled only
after the initial latency period is complete.
Implementation Results
The initial latency of the design is equal to the [(number of channels + 1) * number of taps] plus three
pipe stages within the DSP48. After placement and routing, the design uses 216 slices and eight
DSP48 blocks. The design has a speed of 454 MHz.
Conclusion
The available arithmetic functions within the DSP48 block, combined with fine granularity and high
speed, makes the Virtex-4 FPGA an ideal device to implement high-speed, multi-channel filter
functions. The design shows the efficient implementation of a six-channel, eight-tap filter. Due to the
high-performance capability within the DSP48 block, a single channel, eight-tap filter can be used to
implement the six-channel, eight-tap filter, reducing the area utilization by 1/6th.
Xilinx • 15
DSP: DESIGNING FOR OPTIMAL RESULTS
# • Xilinx
Appendix A
References
Xilinx • #
DSP: DESIGNING FOR OPTIMAL RESULTS
# • Xilinx
DSP Solutions – Advanced Design Guide
Edition 1.0
April, 2005