# Complex Multiplier

Document ID
AM004
Release Date
2022-09-11
Revision
1.2.1 English

## Generation of Complex Conjugates for Multiplication

The 18-bit complex multiplier that straddles two back-to-back DSP58s produces a complex product. See the complex multiplier example in DSP58 Applications for details on generation of complex conjugates and coding example.

## OPMODE Control

As shown in the Right DSP58 and Left DSP58 figures in Basic Function and Complex Adder, OPMODE controls the behavior of the X,Y,Z,W multiplexers (same as DSP58, which constitutes the DSPCPLX basic block. (See W, X, Y, and Z Multiplexers for details.)

A more detailed explanation on how OPMODE_RE and OPMODE_IM are used to determine the final result follows. The examples consider CONJUGATE_RE=CONJUGATE_IM=1’b0. See the table in 18 × 18 Complex Multiply using DSPCPLX for more information on the effect of other values assigned to these signals.

X,Y Multiplexers: OPMODE_RE[3:0] = OPMODE_IM[3:0] = 4'b0101.
This configuration selects the multiplier output in both Real and Imaginary parts to go through the X and Y multiplexers to feed the final ALU. This selection allows the required complex multiplication, therefor the X and Y multiplexer should not be used for other purposes. The only exception is the MACC extension application. The MACC extension equation is covered in the following “Z Multiplexer” section. Additional information is provided in MACC Extension.
Complex Multiplication Equation OPMODE_RE OPMODE_IM

PRE + j PIM = (ARE + j AIM ) (BRE + j BIM ) =

(ARE × BRE - AIM × BIM ) + j (ARE × BIM + AIM × BRE )

9’b00_000_01_01 9’b00_000_01_01
Z Multiplexer: PMODE_RE[6:4] = OPMODE_IM[6:4] = Kz.
The value assigned to these control signals determine the Z multiplexer output that are forwarded to the ALU. "DSPCPLX Lower" and "DSPCPLX Upper" in the table below represent a DSP cascade configuration in the complex mode (see the figure at the end of this subsection).
Complex Multiplication Equation with Addition Equation OPMODE_RE OPMODE_IM
DSPCPLX Lower

PLRE + j PLIM =

( ALRE + j ALIM ) × ( BLRE + j BLIM )

( ALRE × BLRE - ALIM × BLIM ) + j ( ALRE × BLIM + ALIM × BLRE )

9’b00_000_01_01 9’b00_000_01_01
DSPCPLX Upper

PURE + j PUIM =

( PURE + j PUIM + ( ( AURE + j AUIM ) × ( BURE + j BUIM ) ) =

( ( ALRE × BLRE + AURE × BURE ) - ( ALIM × BLIM + AUIM × BUIM ) )

+ j ( ( ALRE × BLIM + AURE × BUIM + ALIM × BLRE + AUIM × BURE ) )

9’b00_001_01_01 9’b00_001_01_01
Kz: 2'b11 - RND: Addition to the result of the current DSPCPLX; (DSP Upper) instance of a downstream DSPCPLX (DSP Lower)
Complex Multiplication with Accumulation Equation OPMODE_RE OPMODE_IM

PRE + j PIM = ( P*RE + j P*IM ) + ( ( ARE + j AIM ) × ( BRE + j BIM ) ) =

( P*RE + ( ARE × BRE - AIM × BIM ) ) + j ( P*IM + ( ARE × BIM + AIM × BRE ) )

* = value stored in the PRE and PIM registers

9’b00_010_01_01 9’b00_010_01_01
Kz: 3’b010 - P: Output accumulation acting independently on the Real and Imaginary side. Requires PREG=1.
Complex Multiplication With Addition Equation OPMODE_RE OPMODE_IM

PRE + j PIM = ( CRE + j CIM ) + ( ( ARE + j AIM ) × ( BRE + j BIM ) ) =

( CRE + ( ARE × BRE - AIM × BIM ) ) + j ( CIM + ( ARE × BIM + AIM × BRE ) )

9’b00_011_01_01 9’b00_011_01_01
Kz: 3’b011 - C: Additional complex number added independently on the Real and Imaginary side
MACC Extension Equation OPMODE_RE OPMODE_IM

PRE + j PIM = ( P*RE + j P*IM ) + ( ( ARE + j AIM ) × ( BRE + j BIM ) ) =

( P*RE + ( ARE × BRE - AIM × BIM ) ) + j ( P*IM + ( ARE × BIM + AIM × BRE ) )

* = value stored in the PRE and PIM registers

DSPCPLX Lower 9’b00_010_01_01

DSPCPLX Upper 9’b00_100_01_01

DSPCPLX Lower 9’b00_010_01_01

DSPCPLX Upper 9’b00_100_01_01

Kz: 3’b100 - P: Output accumulation acting independently on the Real and Imaginary side. In a DSPCPLX cascade designed for MACC extension, the upper DSPCPLX must have:
• PREG=1
• OPMODE_RE[1:0]=OPMODE_IM[1:0]=2'b00
• OPMODE_RE[3:2]=OPMODE_IM[3:2]=2'b10
• OPMODE_RE[8:7]=OPMODE_IM[8:7]=2’b00
The cases for 3’b101 and 3’b110 are for wide multiplier and not recommended to be used in DSPCPLX.

See MACC Extension for details on MACC operation usage.

W Multiplexer: OPMODE_RE[8:7] = OPMODE_IM[8:7] = Kw
The value assigned to these control signals determine the Z multiplexer output that is forwarded to the ALU.
Complex Multiplication with Accumulation Equation OPMODE_RE OPMODE_IM

PRE + j PIM = ( P*RE + j P*IM ) + ( ( ARE + j AIM ) × ( BRE + j BIM ) ) =

( P*RE + ( ARE × BRE - AIM × BIM ) ) + j ( P*IM + ( ARE × BIM + AIM × BRE ) )

* = value stored in the PRE and PIM registers

9’b01_000_01_01 9’b01_000_01_01
Kw: 2’b01 - P: Output accumulation acting independently on the Real and Imaginary side. Requires PREG=1.
Complex Multiplication with Addition Equation OPMODE_RE OPMODE_IM

PRE + j PIM = ( CRE + j CIM ) + ( ( ARE + j AIM ) × ( BRE + j BIM ) ) =

( CRE + ( ARE × BRE - AIM × BIM ) ) + j ( CIM + ( ARE × BIM + AIM × BRE ) )

9’b10_000_01_01 9’b10_000_01_01
Kw: 2’b10 - C: Additional complex number added independently on the Real and Imaginary side
Complex Multiplication with Addition Equation OPMODE_RE OPMODE_IM

PRE + j PIM = ( RNDRE + j RND IM ) + ( ( ARE + j AIM ) × ( BRE + j BIM ) ) =

( RND + ( ARE × BRE - AIM × BIM ) ) + j ( RND + ( ARE × BIM + AIM × BRE ) )

9’b11_000_01_01 9’b11_000_01_01
Kw: 2’b11 - RND: Additional complex parameter (defined at compile time) used mostly for rounding. Parameter added independently on the Real and Imaginary side.

## ALUMODE Control

ALUMODE controls the operations performed by the final ALU (see the table in ALUMODE Inputs for details). ALUMODE_RE controls the operation performed by the ALU in the Real part of the DSPCPLX, similarly ALUMODE_IM with the Imaginary part.

For the main operations summarized in the previous OPMODE section (complex multiplication, complex multiplication with accumulation, and complex multiplication with addition) it is required that ALUMODE_RE = ALUMODE_IM = 4'b0000. In some other cases it might be necessary to set ALUMODE_RE ≠ ALUMODE_IM. The following shows an example operation:

PRE + j PIM = ( CRE - j CIM ) + ( ( ARE + j AIM ) × ( BRE + j BIM ) ) =

( CRE + ( ARE × BRE - AIM × BIM ) ) + j ( -CIM + ( ARE × BIM + AIM × BRE ) )

Table 1. Complex Conjugates for Multiplication
Port Description
OPMODE_RE = 9'b00_011_01_01 Mux: X,Y = M
Mux: Z = C
OPMODE_IM = 9'b00_011_01_01 Mux: X,Y = M
Mux: Z = C
ALUMODE_RE = 4’b0000 PRE = ZRE + WRE + XRE + YRE + CINRE
ALUMODE_IM = 4’b0001 PIM = -ZIM + WIM + XIM + YIM + CINIM - 1
CIN_RE = 1’b0 PRE = CRE + MRE
CIN_IM = 1’b1 PRE = -CIM + MIM
(CIN_IM = 1’b1 to compensate the -1 introduced by the ALUMODE_IM selection)
To understand which ALUMODE value is required for your application, please consider the following:
1. Use the OPMODE selection as described above to define the X,Y,Z,W multiplexers input/output relationships.
2. See the table in ALUMODE Inputs and replace the output values for the X,Y,Z,W multiplexers in the equations as described in the previous step.
Figure 1. DSPCPLX Modes